OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 2328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 Object* value, | 2339 Object* value, |
2340 WriteBarrierMode mode | 2340 WriteBarrierMode mode |
2341 = UPDATE_WRITE_BARRIER); | 2341 = UPDATE_WRITE_BARRIER); |
2342 | 2342 |
2343 // Set the object's prototype (only JSReceiver and null are allowed values). | 2343 // Set the object's prototype (only JSReceiver and null are allowed values). |
2344 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object, | 2344 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object, |
2345 Handle<Object> value, | 2345 Handle<Object> value, |
2346 bool from_javascript, | 2346 bool from_javascript, |
2347 ShouldThrow should_throw); | 2347 ShouldThrow should_throw); |
2348 | 2348 |
| 2349 // Makes the object prototype immutable |
| 2350 // Never called from JavaScript |
| 2351 static void SetImmutableProto(Handle<JSObject> object); |
| 2352 |
2349 // Initializes the body starting at |start_offset|. It is responsibility of | 2353 // Initializes the body starting at |start_offset|. It is responsibility of |
2350 // the caller to initialize object header. Fill the pre-allocated fields with | 2354 // the caller to initialize object header. Fill the pre-allocated fields with |
2351 // pre_allocated_value and the rest with filler_value. | 2355 // pre_allocated_value and the rest with filler_value. |
2352 // Note: this call does not update write barrier, the caller is responsible | 2356 // Note: this call does not update write barrier, the caller is responsible |
2353 // to ensure that |filler_value| can be collected without WB here. | 2357 // to ensure that |filler_value| can be collected without WB here. |
2354 inline void InitializeBody(Map* map, int start_offset, | 2358 inline void InitializeBody(Map* map, int start_offset, |
2355 Object* pre_allocated_value, Object* filler_value); | 2359 Object* pre_allocated_value, Object* filler_value); |
2356 | 2360 |
2357 // Check whether this object references another object | 2361 // Check whether this object references another object |
2358 bool ReferencesObject(Object* obj); | 2362 bool ReferencesObject(Object* obj); |
(...skipping 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5695 0, kDescriptorIndexBitCount> {}; // NOLINT | 5699 0, kDescriptorIndexBitCount> {}; // NOLINT |
5696 class NumberOfOwnDescriptorsBits: public BitField<int, | 5700 class NumberOfOwnDescriptorsBits: public BitField<int, |
5697 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT | 5701 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT |
5698 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); | 5702 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); |
5699 class DictionaryMap : public BitField<bool, 20, 1> {}; | 5703 class DictionaryMap : public BitField<bool, 20, 1> {}; |
5700 class OwnsDescriptors : public BitField<bool, 21, 1> {}; | 5704 class OwnsDescriptors : public BitField<bool, 21, 1> {}; |
5701 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; | 5705 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; |
5702 class Deprecated : public BitField<bool, 23, 1> {}; | 5706 class Deprecated : public BitField<bool, 23, 1> {}; |
5703 class IsUnstable : public BitField<bool, 24, 1> {}; | 5707 class IsUnstable : public BitField<bool, 24, 1> {}; |
5704 class IsMigrationTarget : public BitField<bool, 25, 1> {}; | 5708 class IsMigrationTarget : public BitField<bool, 25, 1> {}; |
5705 // Bit 26 is free. | 5709 class ImmutablePrototype : public BitField<bool, 26, 1> {}; |
5706 class NewTargetIsBase : public BitField<bool, 27, 1> {}; | 5710 class NewTargetIsBase : public BitField<bool, 27, 1> {}; |
5707 // Bit 28 is free. | 5711 // Bit 28 is free. |
5708 | 5712 |
5709 // Keep this bit field at the very end for better code in | 5713 // Keep this bit field at the very end for better code in |
5710 // Builtins::kJSConstructStubGeneric stub. | 5714 // Builtins::kJSConstructStubGeneric stub. |
5711 // This counter is used for in-object slack tracking. | 5715 // This counter is used for in-object slack tracking. |
5712 // The in-object slack tracking is considered enabled when the counter is | 5716 // The in-object slack tracking is considered enabled when the counter is |
5713 // non zero. The counter only has a valid count for initial maps. For | 5717 // non zero. The counter only has a valid count for initial maps. For |
5714 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject | 5718 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject |
5715 // slack tracking already finished for the transition tree. Any other value | 5719 // slack tracking already finished for the transition tree. Any other value |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5983 bool OnlyHasSimpleProperties(); | 5987 bool OnlyHasSimpleProperties(); |
5984 inline int EnumLength(); | 5988 inline int EnumLength(); |
5985 inline void SetEnumLength(int length); | 5989 inline void SetEnumLength(int length); |
5986 | 5990 |
5987 inline bool owns_descriptors(); | 5991 inline bool owns_descriptors(); |
5988 inline void set_owns_descriptors(bool owns_descriptors); | 5992 inline void set_owns_descriptors(bool owns_descriptors); |
5989 inline void mark_unstable(); | 5993 inline void mark_unstable(); |
5990 inline bool is_stable(); | 5994 inline bool is_stable(); |
5991 inline void set_migration_target(bool value); | 5995 inline void set_migration_target(bool value); |
5992 inline bool is_migration_target(); | 5996 inline bool is_migration_target(); |
| 5997 inline void set_immutable_proto(bool value); |
| 5998 inline bool is_immutable_proto(); |
5993 inline void set_construction_counter(int value); | 5999 inline void set_construction_counter(int value); |
5994 inline int construction_counter(); | 6000 inline int construction_counter(); |
5995 inline void deprecate(); | 6001 inline void deprecate(); |
5996 inline bool is_deprecated(); | 6002 inline bool is_deprecated(); |
5997 inline bool CanBeDeprecated(); | 6003 inline bool CanBeDeprecated(); |
5998 // Returns a non-deprecated version of the input. If the input was not | 6004 // Returns a non-deprecated version of the input. If the input was not |
5999 // deprecated, it is directly returned. Otherwise, the non-deprecated version | 6005 // deprecated, it is directly returned. Otherwise, the non-deprecated version |
6000 // is found by re-transitioning from the root of the transition tree using the | 6006 // is found by re-transitioning from the root of the transition tree using the |
6001 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map | 6007 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map |
6002 // is found. | 6008 // is found. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6155 void VerifyOmittedMapChecks(); | 6161 void VerifyOmittedMapChecks(); |
6156 #endif | 6162 #endif |
6157 | 6163 |
6158 inline int visitor_id(); | 6164 inline int visitor_id(); |
6159 inline void set_visitor_id(int visitor_id); | 6165 inline void set_visitor_id(int visitor_id); |
6160 | 6166 |
6161 static Handle<Map> TransitionToPrototype(Handle<Map> map, | 6167 static Handle<Map> TransitionToPrototype(Handle<Map> map, |
6162 Handle<Object> prototype, | 6168 Handle<Object> prototype, |
6163 PrototypeOptimizationMode mode); | 6169 PrototypeOptimizationMode mode); |
6164 | 6170 |
| 6171 static Handle<Map> TransitionToImmutableProto(Handle<Map> map); |
| 6172 |
6165 static const int kMaxPreAllocatedPropertyFields = 255; | 6173 static const int kMaxPreAllocatedPropertyFields = 255; |
6166 | 6174 |
6167 // Layout description. | 6175 // Layout description. |
6168 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 6176 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
6169 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 6177 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
6170 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; | 6178 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; |
6171 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; | 6179 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; |
6172 static const int kConstructorOrBackPointerOffset = | 6180 static const int kConstructorOrBackPointerOffset = |
6173 kPrototypeOffset + kPointerSize; | 6181 kPrototypeOffset + kPointerSize; |
6174 // When there is only one transition, it is stored directly in this field; | 6182 // When there is only one transition, it is stored directly in this field; |
(...skipping 4526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10701 static const int kDoNotCacheBit = 5; | 10709 static const int kDoNotCacheBit = 5; |
10702 static const int kAcceptAnyReceiver = 6; | 10710 static const int kAcceptAnyReceiver = 6; |
10703 | 10711 |
10704 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); | 10712 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); |
10705 }; | 10713 }; |
10706 | 10714 |
10707 | 10715 |
10708 class ObjectTemplateInfo: public TemplateInfo { | 10716 class ObjectTemplateInfo: public TemplateInfo { |
10709 public: | 10717 public: |
10710 DECL_ACCESSORS(constructor, Object) | 10718 DECL_ACCESSORS(constructor, Object) |
10711 DECL_ACCESSORS(internal_field_count, Object) | 10719 DECL_ACCESSORS(data, Object) |
| 10720 DECL_INT_ACCESSORS(internal_field_count) |
| 10721 DECL_BOOLEAN_ACCESSORS(immutable_proto) |
10712 | 10722 |
10713 DECLARE_CAST(ObjectTemplateInfo) | 10723 DECLARE_CAST(ObjectTemplateInfo) |
10714 | 10724 |
10715 // Dispatched behavior. | 10725 // Dispatched behavior. |
10716 DECLARE_PRINTER(ObjectTemplateInfo) | 10726 DECLARE_PRINTER(ObjectTemplateInfo) |
10717 DECLARE_VERIFIER(ObjectTemplateInfo) | 10727 DECLARE_VERIFIER(ObjectTemplateInfo) |
10718 | 10728 |
10719 static const int kConstructorOffset = TemplateInfo::kHeaderSize; | 10729 static const int kConstructorOffset = TemplateInfo::kHeaderSize; |
10720 static const int kInternalFieldCountOffset = | 10730 // LSB is for immutable_proto, higher bits for internal_field_count |
10721 kConstructorOffset + kPointerSize; | 10731 static const int kDataOffset = kConstructorOffset + kPointerSize; |
10722 static const int kSize = kInternalFieldCountOffset + kPointerSize; | 10732 static const int kSize = kDataOffset + kPointerSize; |
| 10733 |
| 10734 private: |
| 10735 class IsImmutablePrototype : public BitField<bool, 0, 1> {}; |
| 10736 class InternalFieldCount |
| 10737 : public BitField<int, IsImmutablePrototype::kNext, 29> {}; |
10723 }; | 10738 }; |
10724 | 10739 |
10725 | 10740 |
10726 // The DebugInfo class holds additional information for a function being | 10741 // The DebugInfo class holds additional information for a function being |
10727 // debugged. | 10742 // debugged. |
10728 class DebugInfo: public Struct { | 10743 class DebugInfo: public Struct { |
10729 public: | 10744 public: |
10730 // The shared function info for the source being debugged. | 10745 // The shared function info for the source being debugged. |
10731 DECL_ACCESSORS(shared, SharedFunctionInfo) | 10746 DECL_ACCESSORS(shared, SharedFunctionInfo) |
10732 // Code object for the patched code. This code object is the code object | 10747 // Code object for the patched code. This code object is the code object |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10945 } | 10960 } |
10946 return value; | 10961 return value; |
10947 } | 10962 } |
10948 }; | 10963 }; |
10949 | 10964 |
10950 | 10965 |
10951 } // NOLINT, false-positive due to second-order macros. | 10966 } // NOLINT, false-positive due to second-order macros. |
10952 } // NOLINT, false-positive due to second-order macros. | 10967 } // NOLINT, false-positive due to second-order macros. |
10953 | 10968 |
10954 #endif // V8_OBJECTS_H_ | 10969 #endif // V8_OBJECTS_H_ |
OLD | NEW |