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 MUST_USE_RESULT static Maybe<bool> SetImmutableProto( |
| 2351 Handle<JSObject> object, bool from_javascript, ShouldThrow should_throw); |
| 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 3337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5696 0, kDescriptorIndexBitCount> {}; // NOLINT | 5700 0, kDescriptorIndexBitCount> {}; // NOLINT |
5697 class NumberOfOwnDescriptorsBits: public BitField<int, | 5701 class NumberOfOwnDescriptorsBits: public BitField<int, |
5698 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT | 5702 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT |
5699 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); | 5703 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); |
5700 class DictionaryMap : public BitField<bool, 20, 1> {}; | 5704 class DictionaryMap : public BitField<bool, 20, 1> {}; |
5701 class OwnsDescriptors : public BitField<bool, 21, 1> {}; | 5705 class OwnsDescriptors : public BitField<bool, 21, 1> {}; |
5702 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; | 5706 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; |
5703 class Deprecated : public BitField<bool, 23, 1> {}; | 5707 class Deprecated : public BitField<bool, 23, 1> {}; |
5704 class IsUnstable : public BitField<bool, 24, 1> {}; | 5708 class IsUnstable : public BitField<bool, 24, 1> {}; |
5705 class IsMigrationTarget : public BitField<bool, 25, 1> {}; | 5709 class IsMigrationTarget : public BitField<bool, 25, 1> {}; |
5706 // Bit 26 is free. | 5710 class ImmutablePrototype : public BitField<bool, 26, 1> {}; |
5707 class NewTargetIsBase : public BitField<bool, 27, 1> {}; | 5711 class NewTargetIsBase : public BitField<bool, 27, 1> {}; |
5708 // Bit 28 is free. | 5712 // Bit 28 is free. |
5709 | 5713 |
5710 // Keep this bit field at the very end for better code in | 5714 // Keep this bit field at the very end for better code in |
5711 // Builtins::kJSConstructStubGeneric stub. | 5715 // Builtins::kJSConstructStubGeneric stub. |
5712 // This counter is used for in-object slack tracking. | 5716 // This counter is used for in-object slack tracking. |
5713 // The in-object slack tracking is considered enabled when the counter is | 5717 // The in-object slack tracking is considered enabled when the counter is |
5714 // non zero. The counter only has a valid count for initial maps. For | 5718 // non zero. The counter only has a valid count for initial maps. For |
5715 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject | 5719 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject |
5716 // slack tracking already finished for the transition tree. Any other value | 5720 // slack tracking already finished for the transition tree. Any other value |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5984 bool OnlyHasSimpleProperties(); | 5988 bool OnlyHasSimpleProperties(); |
5985 inline int EnumLength(); | 5989 inline int EnumLength(); |
5986 inline void SetEnumLength(int length); | 5990 inline void SetEnumLength(int length); |
5987 | 5991 |
5988 inline bool owns_descriptors(); | 5992 inline bool owns_descriptors(); |
5989 inline void set_owns_descriptors(bool owns_descriptors); | 5993 inline void set_owns_descriptors(bool owns_descriptors); |
5990 inline void mark_unstable(); | 5994 inline void mark_unstable(); |
5991 inline bool is_stable(); | 5995 inline bool is_stable(); |
5992 inline void set_migration_target(bool value); | 5996 inline void set_migration_target(bool value); |
5993 inline bool is_migration_target(); | 5997 inline bool is_migration_target(); |
| 5998 inline void set_immutable_proto(bool value); |
| 5999 inline bool is_immutable_proto(); |
5994 inline void set_construction_counter(int value); | 6000 inline void set_construction_counter(int value); |
5995 inline int construction_counter(); | 6001 inline int construction_counter(); |
5996 inline void deprecate(); | 6002 inline void deprecate(); |
5997 inline bool is_deprecated(); | 6003 inline bool is_deprecated(); |
5998 inline bool CanBeDeprecated(); | 6004 inline bool CanBeDeprecated(); |
5999 // Returns a non-deprecated version of the input. If the input was not | 6005 // Returns a non-deprecated version of the input. If the input was not |
6000 // deprecated, it is directly returned. Otherwise, the non-deprecated version | 6006 // deprecated, it is directly returned. Otherwise, the non-deprecated version |
6001 // is found by re-transitioning from the root of the transition tree using the | 6007 // is found by re-transitioning from the root of the transition tree using the |
6002 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map | 6008 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map |
6003 // is found. | 6009 // is found. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6156 void VerifyOmittedMapChecks(); | 6162 void VerifyOmittedMapChecks(); |
6157 #endif | 6163 #endif |
6158 | 6164 |
6159 inline int visitor_id(); | 6165 inline int visitor_id(); |
6160 inline void set_visitor_id(int visitor_id); | 6166 inline void set_visitor_id(int visitor_id); |
6161 | 6167 |
6162 static Handle<Map> TransitionToPrototype(Handle<Map> map, | 6168 static Handle<Map> TransitionToPrototype(Handle<Map> map, |
6163 Handle<Object> prototype, | 6169 Handle<Object> prototype, |
6164 PrototypeOptimizationMode mode); | 6170 PrototypeOptimizationMode mode); |
6165 | 6171 |
| 6172 static Handle<Map> TransitionToImmutableProto(Handle<Map> map); |
| 6173 |
6166 static const int kMaxPreAllocatedPropertyFields = 255; | 6174 static const int kMaxPreAllocatedPropertyFields = 255; |
6167 | 6175 |
6168 // Layout description. | 6176 // Layout description. |
6169 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 6177 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
6170 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 6178 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
6171 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; | 6179 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; |
6172 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; | 6180 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; |
6173 static const int kConstructorOrBackPointerOffset = | 6181 static const int kConstructorOrBackPointerOffset = |
6174 kPrototypeOffset + kPointerSize; | 6182 kPrototypeOffset + kPointerSize; |
6175 // When there is only one transition, it is stored directly in this field; | 6183 // When there is only one transition, it is stored directly in this field; |
(...skipping 4502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10678 static const int kDoNotCacheBit = 5; | 10686 static const int kDoNotCacheBit = 5; |
10679 static const int kAcceptAnyReceiver = 6; | 10687 static const int kAcceptAnyReceiver = 6; |
10680 | 10688 |
10681 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); | 10689 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); |
10682 }; | 10690 }; |
10683 | 10691 |
10684 | 10692 |
10685 class ObjectTemplateInfo: public TemplateInfo { | 10693 class ObjectTemplateInfo: public TemplateInfo { |
10686 public: | 10694 public: |
10687 DECL_ACCESSORS(constructor, Object) | 10695 DECL_ACCESSORS(constructor, Object) |
10688 DECL_ACCESSORS(internal_field_count, Object) | 10696 DECL_ACCESSORS(data, Object) |
| 10697 DECL_INT_ACCESSORS(internal_field_count) |
| 10698 DECL_BOOLEAN_ACCESSORS(immutable_proto) |
10689 | 10699 |
10690 DECLARE_CAST(ObjectTemplateInfo) | 10700 DECLARE_CAST(ObjectTemplateInfo) |
10691 | 10701 |
10692 // Dispatched behavior. | 10702 // Dispatched behavior. |
10693 DECLARE_PRINTER(ObjectTemplateInfo) | 10703 DECLARE_PRINTER(ObjectTemplateInfo) |
10694 DECLARE_VERIFIER(ObjectTemplateInfo) | 10704 DECLARE_VERIFIER(ObjectTemplateInfo) |
10695 | 10705 |
10696 static const int kConstructorOffset = TemplateInfo::kHeaderSize; | 10706 static const int kConstructorOffset = TemplateInfo::kHeaderSize; |
10697 static const int kInternalFieldCountOffset = | 10707 // LSB is for immutable_proto, higher bits for internal_field_count |
10698 kConstructorOffset + kPointerSize; | 10708 static const int kDataOffset = kConstructorOffset + kPointerSize; |
10699 static const int kSize = kInternalFieldCountOffset + kPointerSize; | 10709 static const int kSize = kDataOffset + kPointerSize; |
10700 }; | 10710 }; |
10701 | 10711 |
10702 | 10712 |
10703 // The DebugInfo class holds additional information for a function being | 10713 // The DebugInfo class holds additional information for a function being |
10704 // debugged. | 10714 // debugged. |
10705 class DebugInfo: public Struct { | 10715 class DebugInfo: public Struct { |
10706 public: | 10716 public: |
10707 // The shared function info for the source being debugged. | 10717 // The shared function info for the source being debugged. |
10708 DECL_ACCESSORS(shared, SharedFunctionInfo) | 10718 DECL_ACCESSORS(shared, SharedFunctionInfo) |
10709 // Code object for the patched code. This code object is the code object | 10719 // 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... |
10922 } | 10932 } |
10923 return value; | 10933 return value; |
10924 } | 10934 } |
10925 }; | 10935 }; |
10926 | 10936 |
10927 | 10937 |
10928 } // NOLINT, false-positive due to second-order macros. | 10938 } // NOLINT, false-positive due to second-order macros. |
10929 } // NOLINT, false-positive due to second-order macros. | 10939 } // NOLINT, false-positive due to second-order macros. |
10930 | 10940 |
10931 #endif // V8_OBJECTS_H_ | 10941 #endif // V8_OBJECTS_H_ |
OLD | NEW |