| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "assert-scope.h" | 9 #include "assert-scope.h" |
| 10 #include "builtins.h" | 10 #include "builtins.h" |
| (...skipping 6066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6077 | 6077 |
| 6078 inline bool is_observed() { | 6078 inline bool is_observed() { |
| 6079 return ((1 << kIsObserved) & bit_field()) != 0; | 6079 return ((1 << kIsObserved) & bit_field()) != 0; |
| 6080 } | 6080 } |
| 6081 | 6081 |
| 6082 inline void set_is_extensible(bool value); | 6082 inline void set_is_extensible(bool value); |
| 6083 inline bool is_extensible(); | 6083 inline bool is_extensible(); |
| 6084 | 6084 |
| 6085 inline void set_elements_kind(ElementsKind elements_kind) { | 6085 inline void set_elements_kind(ElementsKind elements_kind) { |
| 6086 ASSERT(elements_kind < kElementsKindCount); | 6086 ASSERT(elements_kind < kElementsKindCount); |
| 6087 ASSERT(kElementsKindCount <= (1 << kElementsKindBitCount)); | 6087 ASSERT(kElementsKindCount <= (1 << Map::ElementsKindBits::kSize)); |
| 6088 set_bit_field2((bit_field2() & ~kElementsKindMask) | | 6088 set_bit_field2(Map::ElementsKindBits::update(bit_field2(), elements_kind)); |
| 6089 (elements_kind << kElementsKindShift)); | |
| 6090 ASSERT(this->elements_kind() == elements_kind); | 6089 ASSERT(this->elements_kind() == elements_kind); |
| 6091 } | 6090 } |
| 6092 | 6091 |
| 6093 inline ElementsKind elements_kind() { | 6092 inline ElementsKind elements_kind() { |
| 6094 return static_cast<ElementsKind>( | 6093 return Map::ElementsKindBits::decode(bit_field2()); |
| 6095 (bit_field2() & kElementsKindMask) >> kElementsKindShift); | |
| 6096 } | 6094 } |
| 6097 | 6095 |
| 6098 // Tells whether the instance has fast elements that are only Smis. | 6096 // Tells whether the instance has fast elements that are only Smis. |
| 6099 inline bool has_fast_smi_elements() { | 6097 inline bool has_fast_smi_elements() { |
| 6100 return IsFastSmiElementsKind(elements_kind()); | 6098 return IsFastSmiElementsKind(elements_kind()); |
| 6101 } | 6099 } |
| 6102 | 6100 |
| 6103 // Tells whether the instance has fast elements. | 6101 // Tells whether the instance has fast elements. |
| 6104 inline bool has_fast_object_elements() { | 6102 inline bool has_fast_object_elements() { |
| 6105 return IsFastObjectElementsKind(elements_kind()); | 6103 return IsFastObjectElementsKind(elements_kind()); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6566 static const int kHasIndexedInterceptor = 3; | 6564 static const int kHasIndexedInterceptor = 3; |
| 6567 static const int kIsUndetectable = 4; | 6565 static const int kIsUndetectable = 4; |
| 6568 static const int kIsObserved = 5; | 6566 static const int kIsObserved = 5; |
| 6569 static const int kIsAccessCheckNeeded = 6; | 6567 static const int kIsAccessCheckNeeded = 6; |
| 6570 class FunctionWithPrototype: public BitField<bool, 7, 1> {}; | 6568 class FunctionWithPrototype: public BitField<bool, 7, 1> {}; |
| 6571 | 6569 |
| 6572 // Bit positions for bit field 2 | 6570 // Bit positions for bit field 2 |
| 6573 static const int kIsExtensible = 0; | 6571 static const int kIsExtensible = 0; |
| 6574 static const int kStringWrapperSafeForDefaultValueOf = 1; | 6572 static const int kStringWrapperSafeForDefaultValueOf = 1; |
| 6575 // Currently bit 2 is not used. | 6573 // Currently bit 2 is not used. |
| 6576 // No bits can be used after kElementsKindFirstBit, they are all reserved for | 6574 class ElementsKindBits: public BitField<ElementsKind, 3, 5> {}; |
| 6577 // storing ElementKind. | |
| 6578 static const int kElementsKindShift = 3; | |
| 6579 static const int kElementsKindBitCount = 5; | |
| 6580 | 6575 |
| 6581 // Derived values from bit field 2 | 6576 // Derived values from bit field 2 |
| 6582 static const int kElementsKindMask = (-1 << kElementsKindShift) & | |
| 6583 ((1 << (kElementsKindShift + kElementsKindBitCount)) - 1); | |
| 6584 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( | 6577 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( |
| 6585 (FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1; | 6578 (FAST_ELEMENTS + 1) << Map::ElementsKindBits::kShift) - 1; |
| 6586 static const int8_t kMaximumBitField2FastSmiElementValue = | 6579 static const int8_t kMaximumBitField2FastSmiElementValue = |
| 6587 static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) << | 6580 static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) << |
| 6588 Map::kElementsKindShift) - 1; | 6581 Map::ElementsKindBits::kShift) - 1; |
| 6589 static const int8_t kMaximumBitField2FastHoleyElementValue = | 6582 static const int8_t kMaximumBitField2FastHoleyElementValue = |
| 6590 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << | 6583 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << |
| 6591 Map::kElementsKindShift) - 1; | 6584 Map::ElementsKindBits::kShift) - 1; |
| 6592 static const int8_t kMaximumBitField2FastHoleySmiElementValue = | 6585 static const int8_t kMaximumBitField2FastHoleySmiElementValue = |
| 6593 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << | 6586 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << |
| 6594 Map::kElementsKindShift) - 1; | 6587 Map::ElementsKindBits::kShift) - 1; |
| 6595 | 6588 |
| 6596 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 6589 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| 6597 kPointerFieldsEndOffset, | 6590 kPointerFieldsEndOffset, |
| 6598 kSize> BodyDescriptor; | 6591 kSize> BodyDescriptor; |
| 6599 | 6592 |
| 6600 // Compares this map to another to see if they describe equivalent objects. | 6593 // Compares this map to another to see if they describe equivalent objects. |
| 6601 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if | 6594 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if |
| 6602 // it had exactly zero inobject properties. | 6595 // it had exactly zero inobject properties. |
| 6603 // The "shared" flags of both this map and |other| are ignored. | 6596 // The "shared" flags of both this map and |other| are ignored. |
| 6604 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); | 6597 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); |
| (...skipping 4465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11070 } else { | 11063 } else { |
| 11071 value &= ~(1 << bit_position); | 11064 value &= ~(1 << bit_position); |
| 11072 } | 11065 } |
| 11073 return value; | 11066 return value; |
| 11074 } | 11067 } |
| 11075 }; | 11068 }; |
| 11076 | 11069 |
| 11077 } } // namespace v8::internal | 11070 } } // namespace v8::internal |
| 11078 | 11071 |
| 11079 #endif // V8_OBJECTS_H_ | 11072 #endif // V8_OBJECTS_H_ |
| OLD | NEW |