vector-slot-pair.h 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_VECTOR_SLOT_PAIR_H_
#define V8_VECTOR_SLOT_PAIR_H_

#include "src/globals.h"
#include "src/handles.h"
#include "src/utils.h"

namespace v8 {
namespace internal {

class FeedbackVector;

// Defines a pair of {FeedbackVector} and {FeedbackSlot}, which
// is used to access the type feedback for a certain {Node}.
class V8_EXPORT_PRIVATE VectorSlotPair {
 public:
  VectorSlotPair();
22 23 24
  VectorSlotPair(Handle<FeedbackVector> vector, FeedbackSlot slot,
                 InlineCacheState ic_state)
      : vector_(vector), slot_(slot), ic_state_(ic_state) {}
25 26 27 28 29

  bool IsValid() const { return !vector_.is_null() && !slot_.IsInvalid(); }

  Handle<FeedbackVector> vector() const { return vector_; }
  FeedbackSlot slot() const { return slot_; }
30
  InlineCacheState ic_state() const { return ic_state_; }
31 32 33 34

  int index() const;

 private:
35 36
  Handle<FeedbackVector> vector_;
  FeedbackSlot slot_;
37
  InlineCacheState ic_state_ = UNINITIALIZED;
38 39 40 41 42
};

bool operator==(VectorSlotPair const&, VectorSlotPair const&);
bool operator!=(VectorSlotPair const&, VectorSlotPair const&);

43 44
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
                                           VectorSlotPair const&);
45

46 47 48 49 50 51
size_t hash_value(VectorSlotPair const&);

}  // namespace internal
}  // namespace v8

#endif  // V8_VECTOR_SLOT_PAIR_H_