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

Side by Side Diff: src/objects.h

Issue 2534613002: [ic] Use validity cells to protect keyed element stores against object's prototype chain modificati… (Closed)
Patch Set: Created 4 years 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
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 #include <memory> 9 #include <memory>
10 10
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 V(TYPE_SWITCH_INFO_TYPE) \ 395 V(TYPE_SWITCH_INFO_TYPE) \
396 V(ALLOCATION_MEMENTO_TYPE) \ 396 V(ALLOCATION_MEMENTO_TYPE) \
397 V(ALLOCATION_SITE_TYPE) \ 397 V(ALLOCATION_SITE_TYPE) \
398 V(SCRIPT_TYPE) \ 398 V(SCRIPT_TYPE) \
399 V(TYPE_FEEDBACK_INFO_TYPE) \ 399 V(TYPE_FEEDBACK_INFO_TYPE) \
400 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ 400 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
401 V(BOX_TYPE) \ 401 V(BOX_TYPE) \
402 V(PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE) \ 402 V(PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE) \
403 V(PROMISE_REACTION_JOB_INFO_TYPE) \ 403 V(PROMISE_REACTION_JOB_INFO_TYPE) \
404 V(PROTOTYPE_INFO_TYPE) \ 404 V(PROTOTYPE_INFO_TYPE) \
405 V(TUPLE2_TYPE) \
405 V(TUPLE3_TYPE) \ 406 V(TUPLE3_TYPE) \
406 V(CONTEXT_EXTENSION_TYPE) \ 407 V(CONTEXT_EXTENSION_TYPE) \
407 V(MODULE_TYPE) \ 408 V(MODULE_TYPE) \
408 V(MODULE_INFO_ENTRY_TYPE) \ 409 V(MODULE_INFO_ENTRY_TYPE) \
409 \ 410 \
410 V(FIXED_ARRAY_TYPE) \ 411 V(FIXED_ARRAY_TYPE) \
411 V(FIXED_DOUBLE_ARRAY_TYPE) \ 412 V(FIXED_DOUBLE_ARRAY_TYPE) \
412 V(SHARED_FUNCTION_INFO_TYPE) \ 413 V(SHARED_FUNCTION_INFO_TYPE) \
413 V(WEAK_CELL_TYPE) \ 414 V(WEAK_CELL_TYPE) \
414 V(TRANSITION_ARRAY_TYPE) \ 415 V(TRANSITION_ARRAY_TYPE) \
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 563 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
563 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 564 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
564 V(SCRIPT, Script, script) \ 565 V(SCRIPT, Script, script) \
565 V(ALLOCATION_SITE, AllocationSite, allocation_site) \ 566 V(ALLOCATION_SITE, AllocationSite, allocation_site) \
566 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \ 567 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
567 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \ 568 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \
568 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \ 569 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \
569 V(DEBUG_INFO, DebugInfo, debug_info) \ 570 V(DEBUG_INFO, DebugInfo, debug_info) \
570 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \ 571 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
571 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \ 572 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
573 V(TUPLE2, Tuple2, tuple2) \
572 V(TUPLE3, Tuple3, tuple3) \ 574 V(TUPLE3, Tuple3, tuple3) \
573 V(MODULE, Module, module) \ 575 V(MODULE, Module, module) \
574 V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \ 576 V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \
575 V(CONTEXT_EXTENSION, ContextExtension, context_extension) 577 V(CONTEXT_EXTENSION, ContextExtension, context_extension)
576 578
577 // We use the full 8 bits of the instance_type field to encode heap object 579 // We use the full 8 bits of the instance_type field to encode heap object
578 // instance types. The high-order bit (bit 7) is set if the object is not a 580 // instance types. The high-order bit (bit 7) is set if the object is not a
579 // string, and cleared if it is a string. 581 // string, and cleared if it is a string.
580 const uint32_t kIsNotStringMask = 0x80; 582 const uint32_t kIsNotStringMask = 0x80;
581 const uint32_t kStringTag = 0x0; 583 const uint32_t kStringTag = 0x0;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 PROMISE_REACTION_JOB_INFO_TYPE, 743 PROMISE_REACTION_JOB_INFO_TYPE,
742 DEBUG_INFO_TYPE, 744 DEBUG_INFO_TYPE,
743 BREAK_POINT_INFO_TYPE, 745 BREAK_POINT_INFO_TYPE,
744 FIXED_ARRAY_TYPE, 746 FIXED_ARRAY_TYPE,
745 SHARED_FUNCTION_INFO_TYPE, 747 SHARED_FUNCTION_INFO_TYPE,
746 CELL_TYPE, 748 CELL_TYPE,
747 WEAK_CELL_TYPE, 749 WEAK_CELL_TYPE,
748 TRANSITION_ARRAY_TYPE, 750 TRANSITION_ARRAY_TYPE,
749 PROPERTY_CELL_TYPE, 751 PROPERTY_CELL_TYPE,
750 PROTOTYPE_INFO_TYPE, 752 PROTOTYPE_INFO_TYPE,
753 TUPLE2_TYPE,
751 TUPLE3_TYPE, 754 TUPLE3_TYPE,
752 CONTEXT_EXTENSION_TYPE, 755 CONTEXT_EXTENSION_TYPE,
753 MODULE_TYPE, 756 MODULE_TYPE,
754 MODULE_INFO_ENTRY_TYPE, 757 MODULE_INFO_ENTRY_TYPE,
755 758
756 // All the following types are subtypes of JSReceiver, which corresponds to 759 // All the following types are subtypes of JSReceiver, which corresponds to
757 // objects in the JS sense. The first and the last type in this range are 760 // objects in the JS sense. The first and the last type in this range are
758 // the two forms of function. This organization enables using the same 761 // the two forms of function. This organization enables using the same
759 // compares for checking the JS_RECEIVER and the NONCALLABLE_JS_OBJECT range. 762 // compares for checking the JS_RECEIVER and the NONCALLABLE_JS_OBJECT range.
760 JS_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE 763 JS_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE
(...skipping 3257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4018 class SeededNumberDictionary 4021 class SeededNumberDictionary
4019 : public Dictionary<SeededNumberDictionary, 4022 : public Dictionary<SeededNumberDictionary,
4020 SeededNumberDictionaryShape, 4023 SeededNumberDictionaryShape,
4021 uint32_t> { 4024 uint32_t> {
4022 public: 4025 public:
4023 DECLARE_CAST(SeededNumberDictionary) 4026 DECLARE_CAST(SeededNumberDictionary)
4024 4027
4025 // Type specific at put (default NONE attributes is used when adding). 4028 // Type specific at put (default NONE attributes is used when adding).
4026 MUST_USE_RESULT static Handle<SeededNumberDictionary> AtNumberPut( 4029 MUST_USE_RESULT static Handle<SeededNumberDictionary> AtNumberPut(
4027 Handle<SeededNumberDictionary> dictionary, uint32_t key, 4030 Handle<SeededNumberDictionary> dictionary, uint32_t key,
4028 Handle<Object> value, bool used_as_prototype); 4031 Handle<Object> value, Handle<JSObject> dictionary_holder);
4029 MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry( 4032 MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry(
4030 Handle<SeededNumberDictionary> dictionary, uint32_t key, 4033 Handle<SeededNumberDictionary> dictionary, uint32_t key,
4031 Handle<Object> value, PropertyDetails details, bool used_as_prototype); 4034 Handle<Object> value, PropertyDetails details,
4035 Handle<JSObject> dictionary_holder);
4032 4036
4033 // Set an existing entry or add a new one if needed. 4037 // Set an existing entry or add a new one if needed.
4034 // Return the updated dictionary. 4038 // Return the updated dictionary.
4035 MUST_USE_RESULT static Handle<SeededNumberDictionary> Set( 4039 MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
4036 Handle<SeededNumberDictionary> dictionary, uint32_t key, 4040 Handle<SeededNumberDictionary> dictionary, uint32_t key,
4037 Handle<Object> value, PropertyDetails details, bool used_as_prototype); 4041 Handle<Object> value, PropertyDetails details,
4042 Handle<JSObject> dictionary_holder);
4038 4043
4039 void UpdateMaxNumberKey(uint32_t key, bool used_as_prototype); 4044 void UpdateMaxNumberKey(uint32_t key, Handle<JSObject> dictionary_holder);
4040 4045
4041 // Returns true if the dictionary contains any elements that are non-writable, 4046 // Returns true if the dictionary contains any elements that are non-writable,
4042 // non-configurable, non-enumerable, or have getters/setters. 4047 // non-configurable, non-enumerable, or have getters/setters.
4043 bool HasComplexElements(); 4048 bool HasComplexElements();
4044 4049
4045 // If slow elements are required we will never go back to fast-case 4050 // If slow elements are required we will never go back to fast-case
4046 // for the elements kept in this dictionary. We require slow 4051 // for the elements kept in this dictionary. We require slow
4047 // elements if an element has been added at an index larger than 4052 // elements if an element has been added at an index larger than
4048 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called 4053 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called
4049 // when defining a getter or setter with a number key. 4054 // when defining a getter or setter with a number key.
(...skipping 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6966 6971
6967 // Bit field usage. 6972 // Bit field usage.
6968 static const int kShouldBeFastBit = 0; 6973 static const int kShouldBeFastBit = 0;
6969 6974
6970 private: 6975 private:
6971 DECL_ACCESSORS(object_create_map, Object) 6976 DECL_ACCESSORS(object_create_map, Object)
6972 6977
6973 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo); 6978 DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
6974 }; 6979 };
6975 6980
6976 class Tuple3 : public Struct { 6981 class Tuple2 : public Struct {
6977 public: 6982 public:
6978 DECL_ACCESSORS(value1, Object) 6983 DECL_ACCESSORS(value1, Object)
6979 DECL_ACCESSORS(value2, Object) 6984 DECL_ACCESSORS(value2, Object)
6985
6986 DECLARE_CAST(Tuple2)
6987
6988 // Dispatched behavior.
6989 DECLARE_PRINTER(Tuple2)
6990 DECLARE_VERIFIER(Tuple2)
6991
6992 static const int kValue1Offset = HeapObject::kHeaderSize;
6993 static const int kValue2Offset = kValue1Offset + kPointerSize;
6994 static const int kSize = kValue2Offset + kPointerSize;
6995
6996 private:
6997 DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple2);
6998 };
6999
7000 class Tuple3 : public Tuple2 {
7001 public:
6980 DECL_ACCESSORS(value3, Object) 7002 DECL_ACCESSORS(value3, Object)
6981 7003
6982 DECLARE_CAST(Tuple3) 7004 DECLARE_CAST(Tuple3)
6983 7005
6984 // Dispatched behavior. 7006 // Dispatched behavior.
6985 DECLARE_PRINTER(Tuple3) 7007 DECLARE_PRINTER(Tuple3)
6986 DECLARE_VERIFIER(Tuple3) 7008 DECLARE_VERIFIER(Tuple3)
6987 7009
6988 static const int kValue1Offset = HeapObject::kHeaderSize; 7010 static const int kValue3Offset = Tuple2::kSize;
6989 static const int kValue2Offset = kValue1Offset + kPointerSize;
6990 static const int kValue3Offset = kValue2Offset + kPointerSize;
6991 static const int kSize = kValue3Offset + kPointerSize; 7011 static const int kSize = kValue3Offset + kPointerSize;
6992 7012
6993 private: 7013 private:
6994 DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple3); 7014 DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple3);
6995 }; 7015 };
6996 7016
6997 // Pair used to store both a ScopeInfo and an extension object in the extension 7017 // Pair used to store both a ScopeInfo and an extension object in the extension
6998 // slot of a block, catch, or with context. Needed in the rare case where a 7018 // slot of a block, catch, or with context. Needed in the rare case where a
6999 // declaration block scope (a "varblock" as used to desugar parameter 7019 // declaration block scope (a "varblock" as used to desugar parameter
7000 // destructuring) also contains a sloppy direct eval, or for with and catch 7020 // destructuring) also contains a sloppy direct eval, or for with and catch
(...skipping 4876 matching lines...) Expand 10 before | Expand all | Expand 10 after
11877 } 11897 }
11878 return value; 11898 return value;
11879 } 11899 }
11880 }; 11900 };
11881 11901
11882 11902
11883 } // NOLINT, false-positive due to second-order macros. 11903 } // NOLINT, false-positive due to second-order macros.
11884 } // NOLINT, false-positive due to second-order macros. 11904 } // NOLINT, false-positive due to second-order macros.
11885 11905
11886 #endif // V8_OBJECTS_H_ 11906 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698