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 <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 Object* pre_allocated_value, | 2108 Object* pre_allocated_value, |
2109 Object* filler_value); | 2109 Object* filler_value); |
2110 | 2110 |
2111 // Check whether this object references another object | 2111 // Check whether this object references another object |
2112 bool ReferencesObject(Object* obj); | 2112 bool ReferencesObject(Object* obj); |
2113 | 2113 |
2114 // Disalow further properties to be added to the object. | 2114 // Disalow further properties to be added to the object. |
2115 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions( | 2115 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions( |
2116 Handle<JSObject> object); | 2116 Handle<JSObject> object); |
2117 | 2117 |
| 2118 // ES5 Object.seal |
| 2119 MUST_USE_RESULT static MaybeHandle<Object> Seal(Handle<JSObject> object); |
| 2120 |
2118 // ES5 Object.freeze | 2121 // ES5 Object.freeze |
2119 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); | 2122 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); |
2120 | 2123 |
2121 // Called the first time an object is observed with ES7 Object.observe. | 2124 // Called the first time an object is observed with ES7 Object.observe. |
2122 static void SetObserved(Handle<JSObject> object); | 2125 static void SetObserved(Handle<JSObject> object); |
2123 | 2126 |
2124 // Copy object. | 2127 // Copy object. |
2125 enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 }; | 2128 enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 }; |
2126 | 2129 |
2127 static Handle<JSObject> Copy(Handle<JSObject> object); | 2130 static Handle<JSObject> Copy(Handle<JSObject> object); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 // Set the hidden property backing store to either a hash table or | 2400 // Set the hidden property backing store to either a hash table or |
2398 // the inline-stored identity hash. | 2401 // the inline-stored identity hash. |
2399 static Handle<Object> SetHiddenPropertiesHashTable( | 2402 static Handle<Object> SetHiddenPropertiesHashTable( |
2400 Handle<JSObject> object, | 2403 Handle<JSObject> object, |
2401 Handle<Object> value); | 2404 Handle<Object> value); |
2402 | 2405 |
2403 MUST_USE_RESULT Object* GetIdentityHash(); | 2406 MUST_USE_RESULT Object* GetIdentityHash(); |
2404 | 2407 |
2405 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSObject> object); | 2408 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSObject> object); |
2406 | 2409 |
| 2410 static Handle<SeededNumberDictionary> GetNormalizedElementDictionary( |
| 2411 Handle<JSObject> object); |
| 2412 |
| 2413 // Helper for fast versions of preventExtensions, seal, and freeze. |
| 2414 // attrs is one of NONE, SEALED, or FROZEN (depending on the operation). |
| 2415 template <PropertyAttributes attrs> |
| 2416 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensionsWithTransition( |
| 2417 Handle<JSObject> object); |
| 2418 |
2407 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 2419 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
2408 }; | 2420 }; |
2409 | 2421 |
2410 | 2422 |
2411 // Common superclass for FixedArrays that allow implementations to share | 2423 // Common superclass for FixedArrays that allow implementations to share |
2412 // common accessors and some code paths. | 2424 // common accessors and some code paths. |
2413 class FixedArrayBase: public HeapObject { | 2425 class FixedArrayBase: public HeapObject { |
2414 public: | 2426 public: |
2415 // [length]: length of the array. | 2427 // [length]: length of the array. |
2416 inline int length() const; | 2428 inline int length() const; |
(...skipping 3252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5669 | 5681 |
5670 class EnumLengthBits: public BitField<int, | 5682 class EnumLengthBits: public BitField<int, |
5671 0, kDescriptorIndexBitCount> {}; // NOLINT | 5683 0, kDescriptorIndexBitCount> {}; // NOLINT |
5672 class NumberOfOwnDescriptorsBits: public BitField<int, | 5684 class NumberOfOwnDescriptorsBits: public BitField<int, |
5673 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT | 5685 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT |
5674 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); | 5686 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); |
5675 class DictionaryMap : public BitField<bool, 20, 1> {}; | 5687 class DictionaryMap : public BitField<bool, 20, 1> {}; |
5676 class OwnsDescriptors : public BitField<bool, 21, 1> {}; | 5688 class OwnsDescriptors : public BitField<bool, 21, 1> {}; |
5677 class HasInstanceCallHandler : public BitField<bool, 22, 1> {}; | 5689 class HasInstanceCallHandler : public BitField<bool, 22, 1> {}; |
5678 class Deprecated : public BitField<bool, 23, 1> {}; | 5690 class Deprecated : public BitField<bool, 23, 1> {}; |
5679 class IsFrozen : public BitField<bool, 24, 1> {}; | 5691 class IsUnstable : public BitField<bool, 24, 1> {}; |
5680 class IsUnstable : public BitField<bool, 25, 1> {}; | 5692 class IsMigrationTarget : public BitField<bool, 25, 1> {}; |
5681 class IsMigrationTarget : public BitField<bool, 26, 1> {}; | 5693 // Bits 26 and 27 are free. |
5682 // Bit 27 is free. | |
5683 | 5694 |
5684 // Keep this bit field at the very end for better code in | 5695 // Keep this bit field at the very end for better code in |
5685 // Builtins::kJSConstructStubGeneric stub. | 5696 // Builtins::kJSConstructStubGeneric stub. |
5686 // This counter is used for in-object slack tracking and for map aging. | 5697 // This counter is used for in-object slack tracking and for map aging. |
5687 // The in-object slack tracking is considered enabled when the counter is | 5698 // The in-object slack tracking is considered enabled when the counter is |
5688 // in the range [kSlackTrackingCounterStart, kSlackTrackingCounterEnd]. | 5699 // in the range [kSlackTrackingCounterStart, kSlackTrackingCounterEnd]. |
5689 class Counter : public BitField<int, 28, 4> {}; | 5700 class Counter : public BitField<int, 28, 4> {}; |
5690 static const int kSlackTrackingCounterStart = 14; | 5701 static const int kSlackTrackingCounterStart = 14; |
5691 static const int kSlackTrackingCounterEnd = 8; | 5702 static const int kSlackTrackingCounterEnd = 8; |
5692 static const int kRetainingCounterStart = kSlackTrackingCounterEnd - 1; | 5703 static const int kRetainingCounterStart = kSlackTrackingCounterEnd - 1; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6022 DCHECK(length == 0 || instance_descriptors()->HasEnumCache()); | 6033 DCHECK(length == 0 || instance_descriptors()->HasEnumCache()); |
6023 DCHECK(length <= NumberOfOwnDescriptors()); | 6034 DCHECK(length <= NumberOfOwnDescriptors()); |
6024 } | 6035 } |
6025 set_bit_field3(EnumLengthBits::update(bit_field3(), length)); | 6036 set_bit_field3(EnumLengthBits::update(bit_field3(), length)); |
6026 } | 6037 } |
6027 | 6038 |
6028 inline bool owns_descriptors(); | 6039 inline bool owns_descriptors(); |
6029 inline void set_owns_descriptors(bool owns_descriptors); | 6040 inline void set_owns_descriptors(bool owns_descriptors); |
6030 inline bool has_instance_call_handler(); | 6041 inline bool has_instance_call_handler(); |
6031 inline void set_has_instance_call_handler(); | 6042 inline void set_has_instance_call_handler(); |
6032 inline void freeze(); | |
6033 inline bool is_frozen(); | |
6034 inline void mark_unstable(); | 6043 inline void mark_unstable(); |
6035 inline bool is_stable(); | 6044 inline bool is_stable(); |
6036 inline void set_migration_target(bool value); | 6045 inline void set_migration_target(bool value); |
6037 inline bool is_migration_target(); | 6046 inline bool is_migration_target(); |
6038 inline void set_counter(int value); | 6047 inline void set_counter(int value); |
6039 inline int counter(); | 6048 inline int counter(); |
6040 inline void deprecate(); | 6049 inline void deprecate(); |
6041 inline bool is_deprecated(); | 6050 inline bool is_deprecated(); |
6042 inline bool CanBeDeprecated(); | 6051 inline bool CanBeDeprecated(); |
6043 // Returns a non-deprecated version of the input. If the input was not | 6052 // Returns a non-deprecated version of the input. If the input was not |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6081 ElementsKind to_kind); | 6090 ElementsKind to_kind); |
6082 | 6091 |
6083 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); | 6092 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); |
6084 | 6093 |
6085 static Handle<Map> CopyAsElementsKind(Handle<Map> map, | 6094 static Handle<Map> CopyAsElementsKind(Handle<Map> map, |
6086 ElementsKind kind, | 6095 ElementsKind kind, |
6087 TransitionFlag flag); | 6096 TransitionFlag flag); |
6088 | 6097 |
6089 static Handle<Map> CopyForObserved(Handle<Map> map); | 6098 static Handle<Map> CopyForObserved(Handle<Map> map); |
6090 | 6099 |
6091 static Handle<Map> CopyForFreeze(Handle<Map> map); | 6100 static Handle<Map> CopyForPreventExtensions(Handle<Map> map, |
| 6101 PropertyAttributes attrs_to_add, |
| 6102 Handle<Symbol> transition_marker, |
| 6103 const char* reason); |
6092 // Maximal number of fast properties. Used to restrict the number of map | 6104 // Maximal number of fast properties. Used to restrict the number of map |
6093 // transitions to avoid an explosion in the number of maps for objects used as | 6105 // transitions to avoid an explosion in the number of maps for objects used as |
6094 // dictionaries. | 6106 // dictionaries. |
6095 inline bool TooManyFastProperties(StoreFromKeyed store_mode); | 6107 inline bool TooManyFastProperties(StoreFromKeyed store_mode); |
6096 static Handle<Map> TransitionToDataProperty(Handle<Map> map, | 6108 static Handle<Map> TransitionToDataProperty(Handle<Map> map, |
6097 Handle<Name> name, | 6109 Handle<Name> name, |
6098 Handle<Object> value, | 6110 Handle<Object> value, |
6099 PropertyAttributes attributes, | 6111 PropertyAttributes attributes, |
6100 StoreFromKeyed store_mode); | 6112 StoreFromKeyed store_mode); |
6101 static Handle<Map> TransitionToAccessorProperty( | 6113 static Handle<Map> TransitionToAccessorProperty( |
(...skipping 4920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11022 } else { | 11034 } else { |
11023 value &= ~(1 << bit_position); | 11035 value &= ~(1 << bit_position); |
11024 } | 11036 } |
11025 return value; | 11037 return value; |
11026 } | 11038 } |
11027 }; | 11039 }; |
11028 | 11040 |
11029 } } // namespace v8::internal | 11041 } } // namespace v8::internal |
11030 | 11042 |
11031 #endif // V8_OBJECTS_H_ | 11043 #endif // V8_OBJECTS_H_ |
OLD | NEW |