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

Side by Side Diff: src/objects.h

Issue 2581683003: Introduce {ConstantElementsPair} struct for type safety. (Closed)
Patch Set: Rebased. 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
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/objects-debug.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 #include <memory> 9 #include <memory>
10 10
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 V(SCRIPT_TYPE) \ 384 V(SCRIPT_TYPE) \
385 V(TYPE_FEEDBACK_INFO_TYPE) \ 385 V(TYPE_FEEDBACK_INFO_TYPE) \
386 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ 386 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
387 V(BOX_TYPE) \ 387 V(BOX_TYPE) \
388 V(PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE) \ 388 V(PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE) \
389 V(PROMISE_REACTION_JOB_INFO_TYPE) \ 389 V(PROMISE_REACTION_JOB_INFO_TYPE) \
390 V(PROTOTYPE_INFO_TYPE) \ 390 V(PROTOTYPE_INFO_TYPE) \
391 V(TUPLE2_TYPE) \ 391 V(TUPLE2_TYPE) \
392 V(TUPLE3_TYPE) \ 392 V(TUPLE3_TYPE) \
393 V(CONTEXT_EXTENSION_TYPE) \ 393 V(CONTEXT_EXTENSION_TYPE) \
394 V(CONSTANT_ELEMENTS_PAIR_TYPE) \
394 V(MODULE_TYPE) \ 395 V(MODULE_TYPE) \
395 V(MODULE_INFO_ENTRY_TYPE) \ 396 V(MODULE_INFO_ENTRY_TYPE) \
396 \ 397 \
397 V(FIXED_ARRAY_TYPE) \ 398 V(FIXED_ARRAY_TYPE) \
398 V(FIXED_DOUBLE_ARRAY_TYPE) \ 399 V(FIXED_DOUBLE_ARRAY_TYPE) \
399 V(SHARED_FUNCTION_INFO_TYPE) \ 400 V(SHARED_FUNCTION_INFO_TYPE) \
400 V(WEAK_CELL_TYPE) \ 401 V(WEAK_CELL_TYPE) \
401 V(TRANSITION_ARRAY_TYPE) \ 402 V(TRANSITION_ARRAY_TYPE) \
402 \ 403 \
403 V(JS_MESSAGE_OBJECT_TYPE) \ 404 V(JS_MESSAGE_OBJECT_TYPE) \
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \ 553 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
553 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \ 554 V(TYPE_FEEDBACK_INFO, TypeFeedbackInfo, type_feedback_info) \
554 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \ 555 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \
555 V(DEBUG_INFO, DebugInfo, debug_info) \ 556 V(DEBUG_INFO, DebugInfo, debug_info) \
556 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \ 557 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
557 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \ 558 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
558 V(TUPLE2, Tuple2, tuple2) \ 559 V(TUPLE2, Tuple2, tuple2) \
559 V(TUPLE3, Tuple3, tuple3) \ 560 V(TUPLE3, Tuple3, tuple3) \
560 V(MODULE, Module, module) \ 561 V(MODULE, Module, module) \
561 V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \ 562 V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \
562 V(CONTEXT_EXTENSION, ContextExtension, context_extension) 563 V(CONTEXT_EXTENSION, ContextExtension, context_extension) \
564 V(CONSTANT_ELEMENTS_PAIR, ConstantElementsPair, constant_elements_pair)
563 565
564 // We use the full 8 bits of the instance_type field to encode heap object 566 // We use the full 8 bits of the instance_type field to encode heap object
565 // instance types. The high-order bit (bit 7) is set if the object is not a 567 // instance types. The high-order bit (bit 7) is set if the object is not a
566 // string, and cleared if it is a string. 568 // string, and cleared if it is a string.
567 const uint32_t kIsNotStringMask = 0x80; 569 const uint32_t kIsNotStringMask = 0x80;
568 const uint32_t kStringTag = 0x0; 570 const uint32_t kStringTag = 0x0;
569 const uint32_t kNotStringTag = 0x80; 571 const uint32_t kNotStringTag = 0x80;
570 572
571 // Bit 6 indicates that the object is an internalized string (if set) or not. 573 // Bit 6 indicates that the object is an internalized string (if set) or not.
572 // Bit 7 has to be clear as well. 574 // Bit 7 has to be clear as well.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 FIXED_ARRAY_TYPE, 733 FIXED_ARRAY_TYPE,
732 SHARED_FUNCTION_INFO_TYPE, 734 SHARED_FUNCTION_INFO_TYPE,
733 CELL_TYPE, 735 CELL_TYPE,
734 WEAK_CELL_TYPE, 736 WEAK_CELL_TYPE,
735 TRANSITION_ARRAY_TYPE, 737 TRANSITION_ARRAY_TYPE,
736 PROPERTY_CELL_TYPE, 738 PROPERTY_CELL_TYPE,
737 PROTOTYPE_INFO_TYPE, 739 PROTOTYPE_INFO_TYPE,
738 TUPLE2_TYPE, 740 TUPLE2_TYPE,
739 TUPLE3_TYPE, 741 TUPLE3_TYPE,
740 CONTEXT_EXTENSION_TYPE, 742 CONTEXT_EXTENSION_TYPE,
743 CONSTANT_ELEMENTS_PAIR_TYPE,
741 MODULE_TYPE, 744 MODULE_TYPE,
742 MODULE_INFO_ENTRY_TYPE, 745 MODULE_INFO_ENTRY_TYPE,
743 746
744 // All the following types are subtypes of JSReceiver, which corresponds to 747 // All the following types are subtypes of JSReceiver, which corresponds to
745 // objects in the JS sense. The first and the last type in this range are 748 // objects in the JS sense. The first and the last type in this range are
746 // the two forms of function. This organization enables using the same 749 // the two forms of function. This organization enables using the same
747 // compares for checking the JS_RECEIVER and the NONCALLABLE_JS_OBJECT range. 750 // compares for checking the JS_RECEIVER and the NONCALLABLE_JS_OBJECT range.
748 JS_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE 751 JS_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE
749 JS_GLOBAL_OBJECT_TYPE, // FIRST_JS_OBJECT_TYPE 752 JS_GLOBAL_OBJECT_TYPE, // FIRST_JS_OBJECT_TYPE
750 JS_GLOBAL_PROXY_TYPE, 753 JS_GLOBAL_PROXY_TYPE,
(...skipping 6301 matching lines...) Expand 10 before | Expand all | Expand 10 after
7052 DECLARE_VERIFIER(ContextExtension) 7055 DECLARE_VERIFIER(ContextExtension)
7053 7056
7054 static const int kScopeInfoOffset = HeapObject::kHeaderSize; 7057 static const int kScopeInfoOffset = HeapObject::kHeaderSize;
7055 static const int kExtensionOffset = kScopeInfoOffset + kPointerSize; 7058 static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
7056 static const int kSize = kExtensionOffset + kPointerSize; 7059 static const int kSize = kExtensionOffset + kPointerSize;
7057 7060
7058 private: 7061 private:
7059 DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension); 7062 DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension);
7060 }; 7063 };
7061 7064
7065 // Pair of {ElementsKind} and an array of constant values for {ArrayLiteral}
7066 // expressions. Used to communicate with the runtime for literal boilerplate
7067 // creation within the {Runtime_CreateArrayLiteral} method.
7068 class ConstantElementsPair : public Struct {
7069 public:
7070 DECL_INT_ACCESSORS(elements_kind)
7071 DECL_ACCESSORS(constant_values, FixedArrayBase)
7072
7073 DECLARE_CAST(ConstantElementsPair)
7074
7075 // Dispatched behavior.
7076 DECLARE_PRINTER(ConstantElementsPair)
7077 DECLARE_VERIFIER(ConstantElementsPair)
7078
7079 static const int kElementsKindOffset = HeapObject::kHeaderSize;
7080 static const int kConstantValuesOffset = kElementsKindOffset + kPointerSize;
7081 static const int kSize = kConstantValuesOffset + kPointerSize;
7082
7083 private:
7084 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantElementsPair);
7085 };
7062 7086
7063 // Script describes a script which has been added to the VM. 7087 // Script describes a script which has been added to the VM.
7064 class Script: public Struct { 7088 class Script: public Struct {
7065 public: 7089 public:
7066 // Script types. 7090 // Script types.
7067 enum Type { 7091 enum Type {
7068 TYPE_NATIVE = 0, 7092 TYPE_NATIVE = 0,
7069 TYPE_EXTENSION = 1, 7093 TYPE_EXTENSION = 1,
7070 TYPE_NORMAL = 2, 7094 TYPE_NORMAL = 2,
7071 TYPE_WASM = 3, 7095 TYPE_WASM = 3,
(...skipping 4918 matching lines...) Expand 10 before | Expand all | Expand 10 after
11990 } 12014 }
11991 return value; 12015 return value;
11992 } 12016 }
11993 }; 12017 };
11994 12018
11995 12019
11996 } // NOLINT, false-positive due to second-order macros. 12020 } // NOLINT, false-positive due to second-order macros.
11997 } // NOLINT, false-positive due to second-order macros. 12021 } // NOLINT, false-positive due to second-order macros.
11998 12022
11999 #endif // V8_OBJECTS_H_ 12023 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698