Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: src/objects.h

Issue 2108203002: Implement immutable prototype chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: IsImmutableProto Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 Object* value, 2340 Object* value,
2341 WriteBarrierMode mode 2341 WriteBarrierMode mode
2342 = UPDATE_WRITE_BARRIER); 2342 = UPDATE_WRITE_BARRIER);
2343 2343
2344 // Set the object's prototype (only JSReceiver and null are allowed values). 2344 // Set the object's prototype (only JSReceiver and null are allowed values).
2345 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object, 2345 MUST_USE_RESULT static Maybe<bool> SetPrototype(Handle<JSObject> object,
2346 Handle<Object> value, 2346 Handle<Object> value,
2347 bool from_javascript, 2347 bool from_javascript,
2348 ShouldThrow should_throw); 2348 ShouldThrow should_throw);
2349 2349
2350 // Makes the object prototype immutable
2351 // Never called from JavaScript
2352 static void SetImmutableProto(Handle<JSObject> object);
2353
2350 // Initializes the body starting at |start_offset|. It is responsibility of 2354 // Initializes the body starting at |start_offset|. It is responsibility of
2351 // the caller to initialize object header. Fill the pre-allocated fields with 2355 // the caller to initialize object header. Fill the pre-allocated fields with
2352 // pre_allocated_value and the rest with filler_value. 2356 // pre_allocated_value and the rest with filler_value.
2353 // Note: this call does not update write barrier, the caller is responsible 2357 // Note: this call does not update write barrier, the caller is responsible
2354 // to ensure that |filler_value| can be collected without WB here. 2358 // to ensure that |filler_value| can be collected without WB here.
2355 inline void InitializeBody(Map* map, int start_offset, 2359 inline void InitializeBody(Map* map, int start_offset,
2356 Object* pre_allocated_value, Object* filler_value); 2360 Object* pre_allocated_value, Object* filler_value);
2357 2361
2358 // Check whether this object references another object 2362 // Check whether this object references another object
2359 bool ReferencesObject(Object* obj); 2363 bool ReferencesObject(Object* obj);
(...skipping 3287 matching lines...) Expand 10 before | Expand all | Expand 10 after
5647 0, kDescriptorIndexBitCount> {}; // NOLINT 5651 0, kDescriptorIndexBitCount> {}; // NOLINT
5648 class NumberOfOwnDescriptorsBits: public BitField<int, 5652 class NumberOfOwnDescriptorsBits: public BitField<int,
5649 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT 5653 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT
5650 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); 5654 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20);
5651 class DictionaryMap : public BitField<bool, 20, 1> {}; 5655 class DictionaryMap : public BitField<bool, 20, 1> {};
5652 class OwnsDescriptors : public BitField<bool, 21, 1> {}; 5656 class OwnsDescriptors : public BitField<bool, 21, 1> {};
5653 class HasHiddenPrototype : public BitField<bool, 22, 1> {}; 5657 class HasHiddenPrototype : public BitField<bool, 22, 1> {};
5654 class Deprecated : public BitField<bool, 23, 1> {}; 5658 class Deprecated : public BitField<bool, 23, 1> {};
5655 class IsUnstable : public BitField<bool, 24, 1> {}; 5659 class IsUnstable : public BitField<bool, 24, 1> {};
5656 class IsMigrationTarget : public BitField<bool, 25, 1> {}; 5660 class IsMigrationTarget : public BitField<bool, 25, 1> {};
5657 // Bit 26 is free. 5661 class ImmutablePrototype : public BitField<bool, 26, 1> {};
5658 class NewTargetIsBase : public BitField<bool, 27, 1> {}; 5662 class NewTargetIsBase : public BitField<bool, 27, 1> {};
5659 // Bit 28 is free. 5663 // Bit 28 is free.
5660 5664
5661 // Keep this bit field at the very end for better code in 5665 // Keep this bit field at the very end for better code in
5662 // Builtins::kJSConstructStubGeneric stub. 5666 // Builtins::kJSConstructStubGeneric stub.
5663 // This counter is used for in-object slack tracking. 5667 // This counter is used for in-object slack tracking.
5664 // The in-object slack tracking is considered enabled when the counter is 5668 // The in-object slack tracking is considered enabled when the counter is
5665 // non zero. The counter only has a valid count for initial maps. For 5669 // non zero. The counter only has a valid count for initial maps. For
5666 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject 5670 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject
5667 // slack tracking already finished for the transition tree. Any other value 5671 // slack tracking already finished for the transition tree. Any other value
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
5935 bool OnlyHasSimpleProperties(); 5939 bool OnlyHasSimpleProperties();
5936 inline int EnumLength(); 5940 inline int EnumLength();
5937 inline void SetEnumLength(int length); 5941 inline void SetEnumLength(int length);
5938 5942
5939 inline bool owns_descriptors(); 5943 inline bool owns_descriptors();
5940 inline void set_owns_descriptors(bool owns_descriptors); 5944 inline void set_owns_descriptors(bool owns_descriptors);
5941 inline void mark_unstable(); 5945 inline void mark_unstable();
5942 inline bool is_stable(); 5946 inline bool is_stable();
5943 inline void set_migration_target(bool value); 5947 inline void set_migration_target(bool value);
5944 inline bool is_migration_target(); 5948 inline bool is_migration_target();
5949 inline void set_immutable_proto(bool value);
5950 inline bool is_immutable_proto();
5945 inline void set_construction_counter(int value); 5951 inline void set_construction_counter(int value);
5946 inline int construction_counter(); 5952 inline int construction_counter();
5947 inline void deprecate(); 5953 inline void deprecate();
5948 inline bool is_deprecated(); 5954 inline bool is_deprecated();
5949 inline bool CanBeDeprecated(); 5955 inline bool CanBeDeprecated();
5950 // Returns a non-deprecated version of the input. If the input was not 5956 // Returns a non-deprecated version of the input. If the input was not
5951 // deprecated, it is directly returned. Otherwise, the non-deprecated version 5957 // deprecated, it is directly returned. Otherwise, the non-deprecated version
5952 // is found by re-transitioning from the root of the transition tree using the 5958 // is found by re-transitioning from the root of the transition tree using the
5953 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map 5959 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map
5954 // is found. 5960 // is found.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
6107 void VerifyOmittedMapChecks(); 6113 void VerifyOmittedMapChecks();
6108 #endif 6114 #endif
6109 6115
6110 inline int visitor_id(); 6116 inline int visitor_id();
6111 inline void set_visitor_id(int visitor_id); 6117 inline void set_visitor_id(int visitor_id);
6112 6118
6113 static Handle<Map> TransitionToPrototype(Handle<Map> map, 6119 static Handle<Map> TransitionToPrototype(Handle<Map> map,
6114 Handle<Object> prototype, 6120 Handle<Object> prototype,
6115 PrototypeOptimizationMode mode); 6121 PrototypeOptimizationMode mode);
6116 6122
6123 static Handle<Map> TransitionToImmutableProto(Handle<Map> map);
6124
6117 static const int kMaxPreAllocatedPropertyFields = 255; 6125 static const int kMaxPreAllocatedPropertyFields = 255;
6118 6126
6119 // Layout description. 6127 // Layout description.
6120 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 6128 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
6121 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 6129 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
6122 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize; 6130 static const int kBitField3Offset = kInstanceAttributesOffset + kIntSize;
6123 static const int kPrototypeOffset = kBitField3Offset + kPointerSize; 6131 static const int kPrototypeOffset = kBitField3Offset + kPointerSize;
6124 static const int kConstructorOrBackPointerOffset = 6132 static const int kConstructorOrBackPointerOffset =
6125 kPrototypeOffset + kPointerSize; 6133 kPrototypeOffset + kPointerSize;
6126 // When there is only one transition, it is stored directly in this field; 6134 // When there is only one transition, it is stored directly in this field;
(...skipping 4527 matching lines...) Expand 10 before | Expand all | Expand 10 after
10654 static const int kDoNotCacheBit = 5; 10662 static const int kDoNotCacheBit = 5;
10655 static const int kAcceptAnyReceiver = 6; 10663 static const int kAcceptAnyReceiver = 6;
10656 10664
10657 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); 10665 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo);
10658 }; 10666 };
10659 10667
10660 10668
10661 class ObjectTemplateInfo: public TemplateInfo { 10669 class ObjectTemplateInfo: public TemplateInfo {
10662 public: 10670 public:
10663 DECL_ACCESSORS(constructor, Object) 10671 DECL_ACCESSORS(constructor, Object)
10664 DECL_ACCESSORS(internal_field_count, Object) 10672 DECL_ACCESSORS(data, Object)
10673 DECL_INT_ACCESSORS(internal_field_count)
10674 DECL_BOOLEAN_ACCESSORS(immutable_proto)
10665 10675
10666 DECLARE_CAST(ObjectTemplateInfo) 10676 DECLARE_CAST(ObjectTemplateInfo)
10667 10677
10668 // Dispatched behavior. 10678 // Dispatched behavior.
10669 DECLARE_PRINTER(ObjectTemplateInfo) 10679 DECLARE_PRINTER(ObjectTemplateInfo)
10670 DECLARE_VERIFIER(ObjectTemplateInfo) 10680 DECLARE_VERIFIER(ObjectTemplateInfo)
10671 10681
10672 static const int kConstructorOffset = TemplateInfo::kHeaderSize; 10682 static const int kConstructorOffset = TemplateInfo::kHeaderSize;
10673 static const int kInternalFieldCountOffset = 10683 // LSB is for immutable_proto, higher bits for internal_field_count
10674 kConstructorOffset + kPointerSize; 10684 static const int kDataOffset = kConstructorOffset + kPointerSize;
10675 static const int kSize = kInternalFieldCountOffset + kPointerSize; 10685 static const int kSize = kDataOffset + kPointerSize;
10686
10687 private:
10688 class IsImmutablePrototype : public BitField<bool, 0, 1> {};
10689 class InternalFieldCount
10690 : public BitField<int, IsImmutablePrototype::kNext, 29> {};
10676 }; 10691 };
10677 10692
10678 10693
10679 // The DebugInfo class holds additional information for a function being 10694 // The DebugInfo class holds additional information for a function being
10680 // debugged. 10695 // debugged.
10681 class DebugInfo: public Struct { 10696 class DebugInfo: public Struct {
10682 public: 10697 public:
10683 // The shared function info for the source being debugged. 10698 // The shared function info for the source being debugged.
10684 DECL_ACCESSORS(shared, SharedFunctionInfo) 10699 DECL_ACCESSORS(shared, SharedFunctionInfo)
10685 // Code object for the patched code. This code object is the code object 10700 // 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
10898 } 10913 }
10899 return value; 10914 return value;
10900 } 10915 }
10901 }; 10916 };
10902 10917
10903 10918
10904 } // NOLINT, false-positive due to second-order macros. 10919 } // NOLINT, false-positive due to second-order macros.
10905 } // NOLINT, false-positive due to second-order macros. 10920 } // NOLINT, false-positive due to second-order macros.
10906 10921
10907 #endif // V8_OBJECTS_H_ 10922 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698