1 // Copyright 2018 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 6 #define V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 7 8 #include "src/init/heap-symbols.h" 9 #include "torque-generated/instance-types.h" 10 11 namespace v8 { 12 13 namespace internal { 14 15 // All Maps have a field instance_type containing a InstanceType. 16 // It describes the type of the instances. 17 // 18 // As an example, a JavaScript object is a heap object and its map 19 // instance_type is JS_OBJECT_TYPE. 20 // 21 // The names of the string instance types are intended to systematically 22 // mirror their encoding in the instance_type field of the map. The default 23 // encoding is considered TWO_BYTE. It is not mentioned in the name. ONE_BYTE 24 // encoding is mentioned explicitly in the name. Likewise, the default 25 // representation is considered sequential. It is not mentioned in the 26 // name. The other representations (e.g. CONS, EXTERNAL) are explicitly 27 // mentioned. Finally, the string is either a STRING_TYPE (if it is a normal 28 // string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string). 29 // 30 // NOTE: The following things are some that depend on the string types having 31 // instance_types that are less than those of all other types: 32 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and 33 // Object::IsString. 34 #define INSTANCE_TYPE_LIST_BASE(V) \ 35 V(INTERNALIZED_STRING_TYPE) \ 36 V(EXTERNAL_INTERNALIZED_STRING_TYPE) \ 37 V(ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 38 V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 39 V(UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE) \ 40 V(UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 41 V(STRING_TYPE) \ 42 V(CONS_STRING_TYPE) \ 43 V(EXTERNAL_STRING_TYPE) \ 44 V(SLICED_STRING_TYPE) \ 45 V(THIN_STRING_TYPE) \ 46 V(ONE_BYTE_STRING_TYPE) \ 47 V(CONS_ONE_BYTE_STRING_TYPE) \ 48 V(EXTERNAL_ONE_BYTE_STRING_TYPE) \ 49 V(SLICED_ONE_BYTE_STRING_TYPE) \ 50 V(THIN_ONE_BYTE_STRING_TYPE) \ 51 V(UNCACHED_EXTERNAL_STRING_TYPE) \ 52 V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE) \ 53 V(SHARED_STRING_TYPE) \ 54 V(SHARED_THIN_STRING_TYPE) \ 55 V(SHARED_ONE_BYTE_STRING_TYPE) \ 56 V(SHARED_THIN_ONE_BYTE_STRING_TYPE) 57 58 #define INSTANCE_TYPE_LIST(V) \ 59 INSTANCE_TYPE_LIST_BASE(V) \ 60 TORQUE_ASSIGNED_INSTANCE_TYPE_LIST(V) 61 62 // Since string types are not consecutive, this macro is used to 63 // iterate over them. 64 #define STRING_TYPE_LIST(V) \ 65 V(STRING_TYPE, kVariableSizeSentinel, string, String) \ 66 V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ 67 OneByteString) \ 68 V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \ 69 V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \ 70 ConsOneByteString) \ 71 V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \ 72 V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \ 73 SlicedOneByteString) \ 74 V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \ 75 ExternalString) \ 76 V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \ 77 external_one_byte_string, ExternalOneByteString) \ 78 V(UNCACHED_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kUncachedSize, \ 79 uncached_external_string, UncachedExternalString) \ 80 V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE, \ 81 ExternalOneByteString::kUncachedSize, uncached_external_one_byte_string, \ 82 UncachedExternalOneByteString) \ 83 \ 84 V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \ 85 InternalizedString) \ 86 V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \ 87 one_byte_internalized_string, OneByteInternalizedString) \ 88 V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \ 89 external_internalized_string, ExternalInternalizedString) \ 90 V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \ 91 external_one_byte_internalized_string, ExternalOneByteInternalizedString) \ 92 V(UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE, \ 93 ExternalTwoByteString::kUncachedSize, \ 94 uncached_external_internalized_string, UncachedExternalInternalizedString) \ 95 V(UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \ 96 ExternalOneByteString::kUncachedSize, \ 97 uncached_external_one_byte_internalized_string, \ 98 UncachedExternalOneByteInternalizedString) \ 99 V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \ 100 V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \ 101 ThinOneByteString) \ 102 \ 103 V(SHARED_STRING_TYPE, kVariableSizeSentinel, shared_string, SharedString) \ 104 V(SHARED_ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, \ 105 shared_one_byte_string, SharedOneByteString) \ 106 V(SHARED_THIN_STRING_TYPE, ThinString::kSize, shared_thin_string, \ 107 SharedThinString) \ 108 V(SHARED_THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, \ 109 shared_thin_one_byte_string, SharedThinOneByteString) 110 111 // A struct is a simple object a set of object-valued fields. Including an 112 // object type in this causes the compiler to generate most of the boilerplate 113 // code for the class including allocation and garbage collection routines, 114 // casts and predicates. All you need to define is the class, methods and 115 // object verification routines. Easy, no? 116 #define STRUCT_LIST_GENERATOR(V, _) \ 117 V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \ 118 promise_fulfill_reaction_job_task) \ 119 V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \ 120 promise_reject_reaction_job_task) \ 121 V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \ 122 V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \ 123 V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \ 124 promise_resolve_thenable_job_task) \ 125 V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \ 126 function_template_info) \ 127 V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \ 128 V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \ 129 V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \ 130 V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \ 131 V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \ 132 aliased_arguments_entry) \ 133 V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \ 134 V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \ 135 array_boilerplate_description) \ 136 IF_WASM(V, _, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \ 137 V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \ 138 async_generator_request) \ 139 V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \ 140 V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \ 141 V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \ 142 cached_template_object) \ 143 V(_, CALL_SITE_INFO_TYPE, CallSiteInfo, call_site_info) \ 144 V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \ 145 V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \ 146 V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \ 147 V(_, ERROR_STACK_DATA_TYPE, ErrorStackData, error_stack_data) \ 148 V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \ 149 function_template_rare_data) \ 150 V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \ 151 V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \ 152 V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \ 153 V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \ 154 V(_, PROMISE_ON_STACK_TYPE, PromiseOnStack, promise_on_stack) \ 155 V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \ 156 V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \ 157 property_descriptor_object) \ 158 V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \ 159 V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \ 160 regexp_boilerplate_description) \ 161 V(_, SCRIPT_TYPE, Script, script) \ 162 V(_, SCRIPT_OR_MODULE_TYPE, ScriptOrModule, script_or_module) \ 163 V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \ 164 module_info_entry) \ 165 V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \ 166 V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \ 167 template_object_description) \ 168 V(_, TUPLE2_TYPE, Tuple2, tuple2) \ 169 IF_WASM(V, _, WASM_CONTINUATION_OBJECT_TYPE, WasmContinuationObject, \ 170 wasm_continuation_object) \ 171 IF_WASM(V, _, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \ 172 IF_WASM(V, _, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \ 173 wasm_indirect_function_table) 174 175 // Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_LIST entry 176 #define STRUCT_LIST_ADAPTER(V, NAME, Name, name) V(NAME, Name, name) 177 178 // Produces (NAME, Name, name) entries. 179 #define STRUCT_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_LIST_ADAPTER, V) 180 181 // Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry 182 #define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \ 183 V(Map, name##_map, Name##Map) 184 185 // Produces (Map, struct_name_map, StructNameMap) entries 186 #define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V) 187 188 // 189 // The following macros define list of allocation size objects and list of 190 // their maps. 191 // 192 #define ALLOCATION_SITE_LIST(V, _) \ 193 V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithWeakNext, allocation_site) \ 194 V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithoutWeakNext, \ 195 allocation_site_without_weaknext) 196 197 // Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry 198 #define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 199 V(Map, name_size##_map, Name##Size##Map) 200 201 // Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries 202 #define ALLOCATION_SITE_MAPS_LIST(V) \ 203 ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAPS_LIST_ADAPTER, V) 204 205 // 206 // The following macros define list of data handler objects and list of their 207 // maps. 208 // 209 #define DATA_HANDLER_LIST(V, _) \ 210 V(_, LOAD_HANDLER_TYPE, LoadHandler, 1, load_handler1) \ 211 V(_, LOAD_HANDLER_TYPE, LoadHandler, 2, load_handler2) \ 212 V(_, LOAD_HANDLER_TYPE, LoadHandler, 3, load_handler3) \ 213 V(_, STORE_HANDLER_TYPE, StoreHandler, 0, store_handler0) \ 214 V(_, STORE_HANDLER_TYPE, StoreHandler, 1, store_handler1) \ 215 V(_, STORE_HANDLER_TYPE, StoreHandler, 2, store_handler2) \ 216 V(_, STORE_HANDLER_TYPE, StoreHandler, 3, store_handler3) 217 218 // Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry. 219 #define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 220 V(Map, name_size##_map, Name##Size##Map) 221 222 // Produces (Map, handler_name_map, HandlerNameMap) entries 223 #define DATA_HANDLER_MAPS_LIST(V) \ 224 DATA_HANDLER_LIST(DATA_HANDLER_MAPS_LIST_ADAPTER, V) 225 226 } // namespace internal 227 } // namespace v8 228 229 #endif // V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 230