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 54 #define INSTANCE_TYPE_LIST(V) \ 55 INSTANCE_TYPE_LIST_BASE(V) \ 56 TORQUE_ASSIGNED_INSTANCE_TYPE_LIST(V) 57 58 // Since string types are not consecutive, this macro is used to 59 // iterate over them. 60 #define STRING_TYPE_LIST(V) \ 61 V(STRING_TYPE, kVariableSizeSentinel, string, String) \ 62 V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ 63 OneByteString) \ 64 V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \ 65 V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \ 66 ConsOneByteString) \ 67 V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \ 68 V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \ 69 SlicedOneByteString) \ 70 V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \ 71 ExternalString) \ 72 V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \ 73 external_one_byte_string, ExternalOneByteString) \ 74 V(UNCACHED_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kUncachedSize, \ 75 uncached_external_string, UncachedExternalString) \ 76 V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE, \ 77 ExternalOneByteString::kUncachedSize, uncached_external_one_byte_string, \ 78 UncachedExternalOneByteString) \ 79 \ 80 V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \ 81 InternalizedString) \ 82 V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \ 83 one_byte_internalized_string, OneByteInternalizedString) \ 84 V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \ 85 external_internalized_string, ExternalInternalizedString) \ 86 V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \ 87 external_one_byte_internalized_string, ExternalOneByteInternalizedString) \ 88 V(UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE, \ 89 ExternalTwoByteString::kUncachedSize, \ 90 uncached_external_internalized_string, UncachedExternalInternalizedString) \ 91 V(UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \ 92 ExternalOneByteString::kUncachedSize, \ 93 uncached_external_one_byte_internalized_string, \ 94 UncachedExternalOneByteInternalizedString) \ 95 V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \ 96 V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \ 97 ThinOneByteString) 98 99 // A struct is a simple object a set of object-valued fields. Including an 100 // object type in this causes the compiler to generate most of the boilerplate 101 // code for the class including allocation and garbage collection routines, 102 // casts and predicates. All you need to define is the class, methods and 103 // object verification routines. Easy, no? 104 #define STRUCT_LIST_GENERATOR_BASE(V, _) \ 105 V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \ 106 promise_fulfill_reaction_job_task) \ 107 V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \ 108 promise_reject_reaction_job_task) \ 109 V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \ 110 V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \ 111 V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \ 112 promise_resolve_thenable_job_task) \ 113 V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \ 114 function_template_info) \ 115 V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \ 116 V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \ 117 V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \ 118 V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \ 119 V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \ 120 aliased_arguments_entry) \ 121 V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \ 122 V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \ 123 array_boilerplate_description) \ 124 V(_, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \ 125 V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \ 126 async_generator_request) \ 127 V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \ 128 V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \ 129 V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \ 130 cached_template_object) \ 131 V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \ 132 V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \ 133 V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \ 134 V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \ 135 function_template_rare_data) \ 136 V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \ 137 V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \ 138 V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \ 139 V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \ 140 V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \ 141 V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \ 142 property_descriptor_object) \ 143 V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \ 144 V(_, SCRIPT_TYPE, Script, script) \ 145 V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \ 146 module_info_entry) \ 147 V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \ 148 V(_, STACK_TRACE_FRAME_TYPE, StackTraceFrame, stack_trace_frame) \ 149 V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \ 150 template_object_description) \ 151 V(_, TUPLE2_TYPE, Tuple2, tuple2) \ 152 V(_, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \ 153 V(_, WASM_EXPORTED_FUNCTION_DATA_TYPE, WasmExportedFunctionData, \ 154 wasm_exported_function_data) \ 155 V(_, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \ 156 wasm_indirect_function_table) \ 157 V(_, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, wasm_js_function_data) \ 158 V(_, WASM_VALUE_TYPE, WasmValue, wasm_value) 159 160 #define STRUCT_LIST_GENERATOR(V, _) STRUCT_LIST_GENERATOR_BASE(V, _) 161 162 // Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_LIST entry 163 #define STRUCT_LIST_ADAPTER(V, NAME, Name, name) V(NAME, Name, name) 164 165 // Produces (NAME, Name, name) entries. 166 #define STRUCT_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_LIST_ADAPTER, V) 167 168 // Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry 169 #define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \ 170 V(Map, name##_map, Name##Map) 171 172 // Produces (Map, struct_name_map, StructNameMap) entries 173 #define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V) 174 175 // 176 // The following macros define list of allocation size objects and list of 177 // their maps. 178 // 179 #define ALLOCATION_SITE_LIST(V, _) \ 180 V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithWeakNext, allocation_site) \ 181 V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithoutWeakNext, \ 182 allocation_site_without_weaknext) 183 184 // Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry 185 #define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 186 V(Map, name_size##_map, Name##Size##Map) 187 188 // Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries 189 #define ALLOCATION_SITE_MAPS_LIST(V) \ 190 ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAPS_LIST_ADAPTER, V) 191 192 // 193 // The following macros define list of data handler objects and list of their 194 // maps. 195 // 196 #define DATA_HANDLER_LIST(V, _) \ 197 V(_, LOAD_HANDLER_TYPE, LoadHandler, 1, load_handler1) \ 198 V(_, LOAD_HANDLER_TYPE, LoadHandler, 2, load_handler2) \ 199 V(_, LOAD_HANDLER_TYPE, LoadHandler, 3, load_handler3) \ 200 V(_, STORE_HANDLER_TYPE, StoreHandler, 0, store_handler0) \ 201 V(_, STORE_HANDLER_TYPE, StoreHandler, 1, store_handler1) \ 202 V(_, STORE_HANDLER_TYPE, StoreHandler, 2, store_handler2) \ 203 V(_, STORE_HANDLER_TYPE, StoreHandler, 3, store_handler3) 204 205 // Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry. 206 #define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 207 V(Map, name_size##_map, Name##Size##Map) 208 209 // Produces (Map, handler_name_map, HandlerNameMap) entries 210 #define DATA_HANDLER_MAPS_LIST(V) \ 211 DATA_HANDLER_LIST(DATA_HANDLER_MAPS_LIST_ADAPTER, V) 212 213 } // namespace internal 214 } // namespace v8 215 216 #endif // V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 217