5 #ifndef V8_FIELD_INDEX_H_ 6 #define V8_FIELD_INDEX_H_ 8 #include "src/property-details.h" 22 enum Encoding { kTagged, kDouble, kWord32 };
27 const Map map,
int index,
29 static FieldIndex ForInObjectOffset(
int offset, Encoding encoding);
30 static FieldIndex ForDescriptor(
const Map map,
int descriptor_index);
32 int GetLoadByFieldIndex()
const;
34 bool is_inobject()
const {
35 return IsInObjectBits::decode(bit_field_);
38 bool is_hidden_field()
const {
return IsHiddenField::decode(bit_field_); }
40 bool is_double()
const {
return EncodingBits::decode(bit_field_) == kDouble; }
42 int offset()
const {
return OffsetBits::decode(bit_field_); }
46 DCHECK_EQ(0, offset() % kPointerSize);
47 return offset() / kPointerSize;
50 int outobject_array_index()
const {
51 DCHECK(!is_inobject());
52 return index() - first_inobject_property_offset() / kPointerSize;
57 int property_index()
const {
58 DCHECK(!is_hidden_field());
59 int result = index() - first_inobject_property_offset() / kPointerSize;
61 result += InObjectPropertyBits::decode(bit_field_);
66 int GetFieldAccessStubKey()
const {
68 (IsInObjectBits::kMask | EncodingBits::kMask | OffsetBits::kMask);
71 bool operator==(
FieldIndex const& other)
const {
72 return bit_field_ == other.bit_field_;
74 bool operator!=(
FieldIndex const& other)
const {
return !(*
this == other); }
77 FieldIndex(
bool is_inobject,
int offset, Encoding encoding,
78 int inobject_properties,
int first_inobject_property_offset,
79 bool is_hidden =
false) {
80 DCHECK_EQ(first_inobject_property_offset & (kPointerSize - 1), 0);
81 bit_field_ = IsInObjectBits::encode(is_inobject) |
82 EncodingBits::encode(encoding) |
83 FirstInobjectPropertyOffsetBits::encode(
84 first_inobject_property_offset) |
85 IsHiddenField::encode(is_hidden) | OffsetBits::encode(offset) |
86 InObjectPropertyBits::encode(inobject_properties);
90 switch (representation.kind()) {
91 case Representation::kNone:
92 case Representation::kSmi:
93 case Representation::kHeapObject:
94 case Representation::kTagged:
96 case Representation::kDouble:
101 PrintF(
"%s\n", representation.Mnemonic());
106 int first_inobject_property_offset()
const {
107 DCHECK(!is_hidden_field());
108 return FirstInobjectPropertyOffsetBits::decode(bit_field_);
111 static const int kOffsetBitsSize =
112 (kDescriptorIndexBitCount + 1 + kPointerSizeLog2);
115 class OffsetBits :
public BitField64<int, 0, kOffsetBitsSize> {};
116 class IsInObjectBits :
public BitField64<bool, OffsetBits::kNext, 1> {};
117 class EncodingBits :
public BitField64<Encoding, IsInObjectBits::kNext, 2> {};
119 class InObjectPropertyBits
120 :
public BitField64<int, EncodingBits::kNext, kDescriptorIndexBitCount> {
123 class FirstInobjectPropertyOffsetBits
124 :
public BitField64<int, InObjectPropertyBits::kNext,
125 kFirstInobjectPropertyOffsetBitCount> {};
127 :
public BitField64<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {};
128 STATIC_ASSERT(IsHiddenField::kNext <= 64);
136 #endif // V8_FIELD_INDEX_H_