| 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/utils.h" | 8 #include "src/utils.h" |
| 9 #include "src/property-details.h" | 9 #include "src/property-details.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 V8_FINAL { | 20 class FieldIndex V8_FINAL { |
| 21 public: | 21 public: |
| 22 static FieldIndex ForPropertyIndex(Map* map, | 22 static FieldIndex ForPropertyIndex(Map* map, |
| 23 int index, | 23 int index, |
| 24 bool is_double = false); | 24 bool is_double = false); |
| 25 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); | 25 static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); |
| 26 static FieldIndex ForLookupResult(const LookupResult* result); | 26 static FieldIndex ForLookupResult(const LookupResult* result); |
| 27 static FieldIndex ForDescriptor(Map* map, int descriptor_index); | 27 static FieldIndex ForDescriptor(Map* map, int descriptor_index); |
| 28 static FieldIndex ForLoadByFieldIndex(Map* map, int index); | 28 static FieldIndex ForLoadByFieldIndex(Map* map, int index); |
| 29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index) { | 29 static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index); |
| 30 return ForPropertyIndex(map, index); | |
| 31 } | |
| 32 | 30 |
| 33 bool is_inobject() const { | 31 bool is_inobject() const { |
| 34 return IsInObjectBits::decode(bit_field_); | 32 return IsInObjectBits::decode(bit_field_); |
| 35 } | 33 } |
| 36 | 34 |
| 37 bool is_double() const { | 35 bool is_double() const { |
| 38 return IsDoubleBits::decode(bit_field_); | 36 return IsDoubleBits::decode(bit_field_); |
| 39 } | 37 } |
| 40 | 38 |
| 41 int offset() const { | 39 int offset() const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 // The index itself is shifted up by one bit, the lower-most bit | 66 // The index itself is shifted up by one bit, the lower-most bit |
| 69 // signifying if the field is a mutable double box (1) or not (0). | 67 // signifying if the field is a mutable double box (1) or not (0). |
| 70 int result = index() - first_inobject_property_offset() / kPointerSize; | 68 int result = index() - first_inobject_property_offset() / kPointerSize; |
| 71 if (!is_inobject()) { | 69 if (!is_inobject()) { |
| 72 result = -result - 1; | 70 result = -result - 1; |
| 73 } | 71 } |
| 74 result <<= 1; | 72 result <<= 1; |
| 75 return is_double() ? (result | 1) : result; | 73 return is_double() ? (result | 1) : result; |
| 76 } | 74 } |
| 77 | 75 |
| 78 int GetKeyedLookupCacheIndex() const { | 76 int GetKeyedLookupCacheIndex() const; |
| 79 return property_index(); | |
| 80 } | |
| 81 | 77 |
| 82 int GetLoadFieldStubKey() const { | 78 int GetLoadFieldStubKey() const { |
| 83 return bit_field_ & | 79 return bit_field_ & |
| 84 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); | 80 (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask); |
| 85 } | 81 } |
| 86 | 82 |
| 87 private: | 83 private: |
| 88 FieldIndex(bool is_inobject, int local_index, bool is_double, | 84 FieldIndex(bool is_inobject, int local_index, bool is_double, |
| 89 int inobject_properties, int first_inobject_property_offset, | 85 int inobject_properties, int first_inobject_property_offset, |
| 90 bool is_hidden = false) { | 86 bool is_hidden = false) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 114 class IsHiddenField: | 110 class IsHiddenField: |
| 115 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; | 111 public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {}; |
| 116 STATIC_ASSERT(IsHiddenField::kNext <= 32); | 112 STATIC_ASSERT(IsHiddenField::kNext <= 32); |
| 117 | 113 |
| 118 int bit_field_; | 114 int bit_field_; |
| 119 }; | 115 }; |
| 120 | 116 |
| 121 } } // namespace v8::internal | 117 } } // namespace v8::internal |
| 122 | 118 |
| 123 #endif | 119 #endif |
| OLD | NEW |