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_DEFINITIONS_H_ 6 #define V8_OBJECTS_DEFINITIONS_H_ 7 8 #include "src/heap-symbols.h" 9 10 namespace v8 { 11 12 namespace internal { 13 14 // All Maps have a field instance_type containing a InstanceType. 15 // It describes the type of the instances. 16 // 17 // As an example, a JavaScript object is a heap object and its map 18 // instance_type is JS_OBJECT_TYPE. 19 // 20 // The names of the string instance types are intended to systematically 21 // mirror their encoding in the instance_type field of the map. The default 22 // encoding is considered TWO_BYTE. It is not mentioned in the name. ONE_BYTE 23 // encoding is mentioned explicitly in the name. Likewise, the default 24 // representation is considered sequential. It is not mentioned in the 25 // name. The other representations (e.g. CONS, EXTERNAL) are explicitly 26 // mentioned. Finally, the string is either a STRING_TYPE (if it is a normal 27 // string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string). 28 // 29 // NOTE: The following things are some that depend on the string types having 30 // instance_types that are less than those of all other types: 31 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and 32 // Object::IsString. 33 // 34 // NOTE: Everything following JS_VALUE_TYPE is considered a 35 // JSObject for GC purposes. The first four entries here have typeof 36 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. 37 // 38 // NOTE: List had to be split into two, because of conditional item(s) from 39 // INTL namespace. They can't just be appended to the end, because of the 40 // checks we do in tests (expecting JS_FUNCTION_TYPE to be last). 41 #define INSTANCE_TYPE_LIST_BEFORE_INTL(V) \ 42 V(INTERNALIZED_STRING_TYPE) \ 43 V(EXTERNAL_INTERNALIZED_STRING_TYPE) \ 44 V(ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 45 V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 46 V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ 47 V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \ 48 V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 49 V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ 50 V(STRING_TYPE) \ 51 V(CONS_STRING_TYPE) \ 52 V(EXTERNAL_STRING_TYPE) \ 53 V(SLICED_STRING_TYPE) \ 54 V(THIN_STRING_TYPE) \ 55 V(ONE_BYTE_STRING_TYPE) \ 56 V(CONS_ONE_BYTE_STRING_TYPE) \ 57 V(EXTERNAL_ONE_BYTE_STRING_TYPE) \ 58 V(SLICED_ONE_BYTE_STRING_TYPE) \ 59 V(THIN_ONE_BYTE_STRING_TYPE) \ 60 V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \ 61 V(SHORT_EXTERNAL_STRING_TYPE) \ 62 V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE) \ 63 V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \ 64 \ 65 V(SYMBOL_TYPE) \ 66 V(HEAP_NUMBER_TYPE) \ 67 V(BIGINT_TYPE) \ 68 V(ODDBALL_TYPE) \ 69 \ 70 V(MAP_TYPE) \ 71 V(CODE_TYPE) \ 72 V(MUTABLE_HEAP_NUMBER_TYPE) \ 73 V(FOREIGN_TYPE) \ 74 V(BYTE_ARRAY_TYPE) \ 75 V(BYTECODE_ARRAY_TYPE) \ 76 V(FREE_SPACE_TYPE) \ 77 \ 78 V(FIXED_INT8_ARRAY_TYPE) \ 79 V(FIXED_UINT8_ARRAY_TYPE) \ 80 V(FIXED_INT16_ARRAY_TYPE) \ 81 V(FIXED_UINT16_ARRAY_TYPE) \ 82 V(FIXED_INT32_ARRAY_TYPE) \ 83 V(FIXED_UINT32_ARRAY_TYPE) \ 84 V(FIXED_FLOAT32_ARRAY_TYPE) \ 85 V(FIXED_FLOAT64_ARRAY_TYPE) \ 86 V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \ 87 V(FIXED_BIGINT64_ARRAY_TYPE) \ 88 V(FIXED_BIGUINT64_ARRAY_TYPE) \ 89 \ 90 V(FIXED_DOUBLE_ARRAY_TYPE) \ 91 V(FEEDBACK_METADATA_TYPE) \ 92 V(FILLER_TYPE) \ 93 \ 94 V(ACCESS_CHECK_INFO_TYPE) \ 95 V(ACCESSOR_INFO_TYPE) \ 96 V(ACCESSOR_PAIR_TYPE) \ 97 V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ 98 V(ALLOCATION_MEMENTO_TYPE) \ 99 V(ASYNC_GENERATOR_REQUEST_TYPE) \ 100 V(DEBUG_INFO_TYPE) \ 101 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 102 V(INTERCEPTOR_INFO_TYPE) \ 103 V(INTERPRETER_DATA_TYPE) \ 104 V(MODULE_INFO_ENTRY_TYPE) \ 105 V(MODULE_TYPE) \ 106 V(OBJECT_TEMPLATE_INFO_TYPE) \ 107 V(PROMISE_CAPABILITY_TYPE) \ 108 V(PROMISE_REACTION_TYPE) \ 109 V(PROTOTYPE_INFO_TYPE) \ 110 V(SCRIPT_TYPE) \ 111 V(STACK_FRAME_INFO_TYPE) \ 112 V(TUPLE2_TYPE) \ 113 V(TUPLE3_TYPE) \ 114 V(ARRAY_BOILERPLATE_DESCRIPTION_TYPE) \ 115 V(WASM_DEBUG_INFO_TYPE) \ 116 V(WASM_EXPORTED_FUNCTION_DATA_TYPE) \ 117 \ 118 V(CALLABLE_TASK_TYPE) \ 119 V(CALLBACK_TASK_TYPE) \ 120 V(PROMISE_FULFILL_REACTION_JOB_TASK_TYPE) \ 121 V(PROMISE_REJECT_REACTION_JOB_TASK_TYPE) \ 122 V(PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE) \ 123 \ 124 V(ALLOCATION_SITE_TYPE) \ 125 \ 126 V(FIXED_ARRAY_TYPE) \ 127 V(OBJECT_BOILERPLATE_DESCRIPTION_TYPE) \ 128 V(HASH_TABLE_TYPE) \ 129 V(ORDERED_HASH_MAP_TYPE) \ 130 V(ORDERED_HASH_SET_TYPE) \ 131 V(NAME_DICTIONARY_TYPE) \ 132 V(GLOBAL_DICTIONARY_TYPE) \ 133 V(NUMBER_DICTIONARY_TYPE) \ 134 V(SIMPLE_NUMBER_DICTIONARY_TYPE) \ 135 V(STRING_TABLE_TYPE) \ 136 V(EPHEMERON_HASH_TABLE_TYPE) \ 137 V(SCOPE_INFO_TYPE) \ 138 V(SCRIPT_CONTEXT_TABLE_TYPE) \ 139 \ 140 V(BLOCK_CONTEXT_TYPE) \ 141 V(CATCH_CONTEXT_TYPE) \ 142 V(DEBUG_EVALUATE_CONTEXT_TYPE) \ 143 V(EVAL_CONTEXT_TYPE) \ 144 V(FUNCTION_CONTEXT_TYPE) \ 145 V(MODULE_CONTEXT_TYPE) \ 146 V(NATIVE_CONTEXT_TYPE) \ 147 V(SCRIPT_CONTEXT_TYPE) \ 148 V(WITH_CONTEXT_TYPE) \ 149 \ 150 V(WEAK_FIXED_ARRAY_TYPE) \ 151 V(DESCRIPTOR_ARRAY_TYPE) \ 152 V(TRANSITION_ARRAY_TYPE) \ 153 \ 154 V(CALL_HANDLER_INFO_TYPE) \ 155 V(CELL_TYPE) \ 156 V(CODE_DATA_CONTAINER_TYPE) \ 157 V(FEEDBACK_CELL_TYPE) \ 158 V(FEEDBACK_VECTOR_TYPE) \ 159 V(LOAD_HANDLER_TYPE) \ 160 V(PRE_PARSED_SCOPE_DATA_TYPE) \ 161 V(PROPERTY_ARRAY_TYPE) \ 162 V(PROPERTY_CELL_TYPE) \ 163 V(SHARED_FUNCTION_INFO_TYPE) \ 164 V(SMALL_ORDERED_HASH_MAP_TYPE) \ 165 V(SMALL_ORDERED_HASH_SET_TYPE) \ 166 V(STORE_HANDLER_TYPE) \ 167 V(UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE) \ 168 V(UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE) \ 169 V(WEAK_ARRAY_LIST_TYPE) \ 170 \ 171 V(JS_PROXY_TYPE) \ 172 V(JS_GLOBAL_OBJECT_TYPE) \ 173 V(JS_GLOBAL_PROXY_TYPE) \ 174 V(JS_MODULE_NAMESPACE_TYPE) \ 175 V(JS_SPECIAL_API_OBJECT_TYPE) \ 176 V(JS_VALUE_TYPE) \ 177 V(JS_API_OBJECT_TYPE) \ 178 V(JS_OBJECT_TYPE) \ 179 \ 180 V(JS_ARGUMENTS_TYPE) \ 181 V(JS_ARRAY_BUFFER_TYPE) \ 182 V(JS_ARRAY_ITERATOR_TYPE) \ 183 V(JS_ARRAY_TYPE) \ 184 V(JS_ASYNC_FROM_SYNC_ITERATOR_TYPE) \ 185 V(JS_ASYNC_GENERATOR_OBJECT_TYPE) \ 186 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ 187 V(JS_DATE_TYPE) \ 188 V(JS_ERROR_TYPE) \ 189 V(JS_GENERATOR_OBJECT_TYPE) \ 190 V(JS_MAP_TYPE) \ 191 V(JS_MAP_KEY_ITERATOR_TYPE) \ 192 V(JS_MAP_KEY_VALUE_ITERATOR_TYPE) \ 193 V(JS_MAP_VALUE_ITERATOR_TYPE) \ 194 V(JS_MESSAGE_OBJECT_TYPE) \ 195 V(JS_PROMISE_TYPE) \ 196 V(JS_REGEXP_TYPE) \ 197 V(JS_REGEXP_STRING_ITERATOR_TYPE) \ 198 V(JS_SET_TYPE) \ 199 V(JS_SET_KEY_VALUE_ITERATOR_TYPE) \ 200 V(JS_SET_VALUE_ITERATOR_TYPE) \ 201 V(JS_STRING_ITERATOR_TYPE) \ 202 V(JS_WEAK_MAP_TYPE) \ 203 V(JS_WEAK_SET_TYPE) \ 204 V(JS_TYPED_ARRAY_TYPE) \ 205 V(JS_DATA_VIEW_TYPE) 206 207 #define INSTANCE_TYPE_LIST_AFTER_INTL(V) \ 208 V(WASM_GLOBAL_TYPE) \ 209 V(WASM_INSTANCE_TYPE) \ 210 V(WASM_MEMORY_TYPE) \ 211 V(WASM_MODULE_TYPE) \ 212 V(WASM_TABLE_TYPE) \ 213 V(JS_BOUND_FUNCTION_TYPE) \ 214 V(JS_FUNCTION_TYPE) 215 216 #ifdef V8_INTL_SUPPORT 217 #define INSTANCE_TYPE_LIST(V) \ 218 INSTANCE_TYPE_LIST_BEFORE_INTL(V) \ 219 V(JS_INTL_COLLATOR_TYPE) \ 220 V(JS_INTL_LIST_FORMAT_TYPE) \ 221 V(JS_INTL_LOCALE_TYPE) \ 222 V(JS_INTL_PLURAL_RULES_TYPE) \ 223 V(JS_INTL_RELATIVE_TIME_FORMAT_TYPE) \ 224 INSTANCE_TYPE_LIST_AFTER_INTL(V) 225 #else 226 #define INSTANCE_TYPE_LIST(V) \ 227 INSTANCE_TYPE_LIST_BEFORE_INTL(V) \ 228 INSTANCE_TYPE_LIST_AFTER_INTL(V) 229 #endif // V8_INTL_SUPPORT 230 231 // Since string types are not consecutive, this macro is used to 232 // iterate over them. 233 #define STRING_TYPE_LIST(V) \ 234 V(STRING_TYPE, kVariableSizeSentinel, string, String) \ 235 V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ 236 OneByteString) \ 237 V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \ 238 V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \ 239 ConsOneByteString) \ 240 V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \ 241 V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \ 242 SlicedOneByteString) \ 243 V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \ 244 ExternalString) \ 245 V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \ 246 external_one_byte_string, ExternalOneByteString) \ 247 V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, ExternalTwoByteString::kSize, \ 248 external_string_with_one_byte_data, ExternalStringWithOneByteData) \ 249 V(SHORT_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kShortSize, \ 250 short_external_string, ShortExternalString) \ 251 V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kShortSize, \ 252 short_external_one_byte_string, ShortExternalOneByteString) \ 253 V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \ 254 ExternalTwoByteString::kShortSize, \ 255 short_external_string_with_one_byte_data, \ 256 ShortExternalStringWithOneByteData) \ 257 \ 258 V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \ 259 InternalizedString) \ 260 V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \ 261 one_byte_internalized_string, OneByteInternalizedString) \ 262 V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \ 263 external_internalized_string, ExternalInternalizedString) \ 264 V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \ 265 external_one_byte_internalized_string, ExternalOneByteInternalizedString) \ 266 V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \ 267 ExternalTwoByteString::kSize, \ 268 external_internalized_string_with_one_byte_data, \ 269 ExternalInternalizedStringWithOneByteData) \ 270 V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE, \ 271 ExternalTwoByteString::kShortSize, short_external_internalized_string, \ 272 ShortExternalInternalizedString) \ 273 V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \ 274 ExternalOneByteString::kShortSize, \ 275 short_external_one_byte_internalized_string, \ 276 ShortExternalOneByteInternalizedString) \ 277 V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \ 278 ExternalTwoByteString::kShortSize, \ 279 short_external_internalized_string_with_one_byte_data, \ 280 ShortExternalInternalizedStringWithOneByteData) \ 281 V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \ 282 V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \ 283 ThinOneByteString) 284 285 // A struct is a simple object a set of object-valued fields. Including an 286 // object type in this causes the compiler to generate most of the boilerplate 287 // code for the class including allocation and garbage collection routines, 288 // casts and predicates. All you need to define is the class, methods and 289 // object verification routines. Easy, no? 290 // 291 // Note that for subtle reasons related to the ordering or numerical values of 292 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 293 // manually. 294 #define STRUCT_LIST(V) \ 295 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 296 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 297 V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \ 298 V(ALIASED_ARGUMENTS_ENTRY, AliasedArgumentsEntry, aliased_arguments_entry) \ 299 V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \ 300 V(ASYNC_GENERATOR_REQUEST, AsyncGeneratorRequest, async_generator_request) \ 301 V(DEBUG_INFO, DebugInfo, debug_info) \ 302 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 303 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 304 V(INTERPRETER_DATA, InterpreterData, interpreter_data) \ 305 V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \ 306 V(MODULE, Module, module) \ 307 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 308 V(PROMISE_CAPABILITY, PromiseCapability, promise_capability) \ 309 V(PROMISE_REACTION, PromiseReaction, promise_reaction) \ 310 V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \ 311 V(SCRIPT, Script, script) \ 312 V(STACK_FRAME_INFO, StackFrameInfo, stack_frame_info) \ 313 V(TUPLE2, Tuple2, tuple2) \ 314 V(TUPLE3, Tuple3, tuple3) \ 315 V(ARRAY_BOILERPLATE_DESCRIPTION, ArrayBoilerplateDescription, \ 316 array_boilerplate_description) \ 317 V(WASM_DEBUG_INFO, WasmDebugInfo, wasm_debug_info) \ 318 V(WASM_EXPORTED_FUNCTION_DATA, WasmExportedFunctionData, \ 319 wasm_exported_function_data) \ 320 V(CALLABLE_TASK, CallableTask, callable_task) \ 321 V(CALLBACK_TASK, CallbackTask, callback_task) \ 322 V(PROMISE_FULFILL_REACTION_JOB_TASK, PromiseFulfillReactionJobTask, \ 323 promise_fulfill_reaction_job_task) \ 324 V(PROMISE_REJECT_REACTION_JOB_TASK, PromiseRejectReactionJobTask, \ 325 promise_reject_reaction_job_task) \ 326 V(PROMISE_RESOLVE_THENABLE_JOB_TASK, PromiseResolveThenableJobTask, \ 327 promise_resolve_thenable_job_task) 328 329 #define ALLOCATION_SITE_LIST(V) \ 330 V(ALLOCATION_SITE, AllocationSite, WithWeakNext, allocation_site) \ 331 V(ALLOCATION_SITE, AllocationSite, WithoutWeakNext, \ 332 allocation_site_without_weaknext) 333 334 #define DATA_HANDLER_LIST(V) \ 335 V(LOAD_HANDLER, LoadHandler, 1, load_handler1) \ 336 V(LOAD_HANDLER, LoadHandler, 2, load_handler2) \ 337 V(LOAD_HANDLER, LoadHandler, 3, load_handler3) \ 338 V(STORE_HANDLER, StoreHandler, 0, store_handler0) \ 339 V(STORE_HANDLER, StoreHandler, 1, store_handler1) \ 340 V(STORE_HANDLER, StoreHandler, 2, store_handler2) \ 341 V(STORE_HANDLER, StoreHandler, 3, store_handler3) 342 343 } // namespace internal 344 } // namespace v8 345 346 #endif // V8_OBJECTS_DEFINITIONS_H_ 347