OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FIELD_INDEX_H_ | 5 #ifndef V8_FIELD_INDEX_H_ |
6 #define V8_FIELD_INDEX_H_ | 6 #define V8_FIELD_INDEX_H_ |
7 | 7 |
8 #include "src/property-details.h" | 8 #include "src/property-details.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 class Map; | 14 class Map; |
15 | 15 |
16 // Wrapper class to hold a field index, usually but not necessarily generated | 16 // Wrapper class to hold a field index, usually but not necessarily generated |
17 // from a property index. When available, the wrapper class captures additional | 17 // from a property index. When available, the wrapper class captures additional |
18 // information to allow the field index to be translated back into the property | 18 // information to allow the field index to be translated back into the property |
19 // index it was originally generated from. | 19 // index it was originally generated from. |
20 class FieldIndex final { | 20 class FieldIndex final { |
21 public: | 21 public: |
22 FieldIndex() : bit_field_(0) {} | 22 FieldIndex() : bit_field_(0) {} |
23 | 23 |
24 static FieldIndex ForPropertyIndex(Map* map, | 24 static FieldIndex ForPropertyIndex(Map* map, |
25 int index, | 25 int index, |
26 bool is_double = false); | 26 bool is_double = false); |
27 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); | 27 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); |
28 static FieldIndex ForDescriptor(Map* map, int descriptor_index); | 28 static FieldIndex ForDescriptor(Map* map, int descriptor_index); |
29 static FieldIndex ForLoadByFieldIndex(Map* map, int index); | 29 static FieldIndex ForLoadByFieldIndex(Map* map, int index); |
30 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index); | |
31 static FieldIndex FromFieldAccessStubKey(int key); | 30 static FieldIndex FromFieldAccessStubKey(int key); |
32 | 31 |
33 int GetLoadByFieldIndex() const; | 32 int GetLoadByFieldIndex() const; |
34 | 33 |
35 bool is_inobject() const { | 34 bool is_inobject() const { |
36 return IsInObjectBits::decode(bit_field_); | 35 return IsInObjectBits::decode(bit_field_); |
37 } | 36 } |
38 | 37 |
39 bool is_hidden_field() const { return IsHiddenField::decode(bit_field_); } | 38 bool is_hidden_field() const { return IsHiddenField::decode(bit_field_); } |
40 | 39 |
(...skipping 19 matching lines...) Expand all Loading... |
60 // properties. | 59 // properties. |
61 int property_index() const { | 60 int property_index() const { |
62 DCHECK(!is_hidden_field()); | 61 DCHECK(!is_hidden_field()); |
63 int result = index() - first_inobject_property_offset() / kPointerSize; | 62 int result = index() - first_inobject_property_offset() / kPointerSize; |
64 if (!is_inobject()) { | 63 if (!is_inobject()) { |
65 result += InObjectPropertyBits::decode(bit_field_); | 64 result += InObjectPropertyBits::decode(bit_field_); |
66 } | 65 } |
67 return result; | 66 return result; |
68 } | 67 } |
69 | 68 |
70 int GetKeyedLookupCacheIndex() const; | |
71 | |
72 int GetFieldAccessStubKey() const { | 69 int GetFieldAccessStubKey() const { |
73 return bit_field_ & | 70 return bit_field_ & |
74 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); | 71 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); |
75 } | 72 } |
76 | 73 |
77 bool operator==(FieldIndex const& other) const { | 74 bool operator==(FieldIndex const& other) const { |
78 return bit_field_ == other.bit_field_; | 75 return bit_field_ == other.bit_field_; |
79 } | 76 } |
80 bool operator!=(FieldIndex const& other) const { return !(*this == other); } | 77 bool operator!=(FieldIndex const& other) const { return !(*this == other); } |
81 | 78 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 : public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; | 112 : public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; |
116 STATIC_ASSERT(IsHiddenField::kNext <= 32); | 113 STATIC_ASSERT(IsHiddenField::kNext <= 32); |
117 | 114 |
118 int bit_field_; | 115 int bit_field_; |
119 }; | 116 }; |
120 | 117 |
121 } // namespace internal | 118 } // namespace internal |
122 } // namespace v8 | 119 } // namespace v8 |
123 | 120 |
124 #endif | 121 #endif |
OLD | NEW |