11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 61cb0ef41Sopenharmony_ci#define V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/init/heap-symbols.h" 91cb0ef41Sopenharmony_ci#include "torque-generated/instance-types.h" 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cinamespace v8 { 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace internal { 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// All Maps have a field instance_type containing a InstanceType. 161cb0ef41Sopenharmony_ci// It describes the type of the instances. 171cb0ef41Sopenharmony_ci// 181cb0ef41Sopenharmony_ci// As an example, a JavaScript object is a heap object and its map 191cb0ef41Sopenharmony_ci// instance_type is JS_OBJECT_TYPE. 201cb0ef41Sopenharmony_ci// 211cb0ef41Sopenharmony_ci// The names of the string instance types are intended to systematically 221cb0ef41Sopenharmony_ci// mirror their encoding in the instance_type field of the map. The default 231cb0ef41Sopenharmony_ci// encoding is considered TWO_BYTE. It is not mentioned in the name. ONE_BYTE 241cb0ef41Sopenharmony_ci// encoding is mentioned explicitly in the name. Likewise, the default 251cb0ef41Sopenharmony_ci// representation is considered sequential. It is not mentioned in the 261cb0ef41Sopenharmony_ci// name. The other representations (e.g. CONS, EXTERNAL) are explicitly 271cb0ef41Sopenharmony_ci// mentioned. Finally, the string is either a STRING_TYPE (if it is a normal 281cb0ef41Sopenharmony_ci// string) or a INTERNALIZED_STRING_TYPE (if it is a internalized string). 291cb0ef41Sopenharmony_ci// 301cb0ef41Sopenharmony_ci// NOTE: The following things are some that depend on the string types having 311cb0ef41Sopenharmony_ci// instance_types that are less than those of all other types: 321cb0ef41Sopenharmony_ci// HeapObject::Size, HeapObject::IterateBody, the typeof operator, and 331cb0ef41Sopenharmony_ci// Object::IsString. 341cb0ef41Sopenharmony_ci#define INSTANCE_TYPE_LIST_BASE(V) \ 351cb0ef41Sopenharmony_ci V(INTERNALIZED_STRING_TYPE) \ 361cb0ef41Sopenharmony_ci V(EXTERNAL_INTERNALIZED_STRING_TYPE) \ 371cb0ef41Sopenharmony_ci V(ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 381cb0ef41Sopenharmony_ci V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 391cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE) \ 401cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \ 411cb0ef41Sopenharmony_ci V(STRING_TYPE) \ 421cb0ef41Sopenharmony_ci V(CONS_STRING_TYPE) \ 431cb0ef41Sopenharmony_ci V(EXTERNAL_STRING_TYPE) \ 441cb0ef41Sopenharmony_ci V(SLICED_STRING_TYPE) \ 451cb0ef41Sopenharmony_ci V(THIN_STRING_TYPE) \ 461cb0ef41Sopenharmony_ci V(ONE_BYTE_STRING_TYPE) \ 471cb0ef41Sopenharmony_ci V(CONS_ONE_BYTE_STRING_TYPE) \ 481cb0ef41Sopenharmony_ci V(EXTERNAL_ONE_BYTE_STRING_TYPE) \ 491cb0ef41Sopenharmony_ci V(SLICED_ONE_BYTE_STRING_TYPE) \ 501cb0ef41Sopenharmony_ci V(THIN_ONE_BYTE_STRING_TYPE) \ 511cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_STRING_TYPE) \ 521cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE) \ 531cb0ef41Sopenharmony_ci V(SHARED_STRING_TYPE) \ 541cb0ef41Sopenharmony_ci V(SHARED_THIN_STRING_TYPE) \ 551cb0ef41Sopenharmony_ci V(SHARED_ONE_BYTE_STRING_TYPE) \ 561cb0ef41Sopenharmony_ci V(SHARED_THIN_ONE_BYTE_STRING_TYPE) 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci#define INSTANCE_TYPE_LIST(V) \ 591cb0ef41Sopenharmony_ci INSTANCE_TYPE_LIST_BASE(V) \ 601cb0ef41Sopenharmony_ci TORQUE_ASSIGNED_INSTANCE_TYPE_LIST(V) 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci// Since string types are not consecutive, this macro is used to 631cb0ef41Sopenharmony_ci// iterate over them. 641cb0ef41Sopenharmony_ci#define STRING_TYPE_LIST(V) \ 651cb0ef41Sopenharmony_ci V(STRING_TYPE, kVariableSizeSentinel, string, String) \ 661cb0ef41Sopenharmony_ci V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \ 671cb0ef41Sopenharmony_ci OneByteString) \ 681cb0ef41Sopenharmony_ci V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \ 691cb0ef41Sopenharmony_ci V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \ 701cb0ef41Sopenharmony_ci ConsOneByteString) \ 711cb0ef41Sopenharmony_ci V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \ 721cb0ef41Sopenharmony_ci V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \ 731cb0ef41Sopenharmony_ci SlicedOneByteString) \ 741cb0ef41Sopenharmony_ci V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \ 751cb0ef41Sopenharmony_ci ExternalString) \ 761cb0ef41Sopenharmony_ci V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \ 771cb0ef41Sopenharmony_ci external_one_byte_string, ExternalOneByteString) \ 781cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kUncachedSize, \ 791cb0ef41Sopenharmony_ci uncached_external_string, UncachedExternalString) \ 801cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE, \ 811cb0ef41Sopenharmony_ci ExternalOneByteString::kUncachedSize, uncached_external_one_byte_string, \ 821cb0ef41Sopenharmony_ci UncachedExternalOneByteString) \ 831cb0ef41Sopenharmony_ci \ 841cb0ef41Sopenharmony_ci V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \ 851cb0ef41Sopenharmony_ci InternalizedString) \ 861cb0ef41Sopenharmony_ci V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \ 871cb0ef41Sopenharmony_ci one_byte_internalized_string, OneByteInternalizedString) \ 881cb0ef41Sopenharmony_ci V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \ 891cb0ef41Sopenharmony_ci external_internalized_string, ExternalInternalizedString) \ 901cb0ef41Sopenharmony_ci V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \ 911cb0ef41Sopenharmony_ci external_one_byte_internalized_string, ExternalOneByteInternalizedString) \ 921cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE, \ 931cb0ef41Sopenharmony_ci ExternalTwoByteString::kUncachedSize, \ 941cb0ef41Sopenharmony_ci uncached_external_internalized_string, UncachedExternalInternalizedString) \ 951cb0ef41Sopenharmony_ci V(UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \ 961cb0ef41Sopenharmony_ci ExternalOneByteString::kUncachedSize, \ 971cb0ef41Sopenharmony_ci uncached_external_one_byte_internalized_string, \ 981cb0ef41Sopenharmony_ci UncachedExternalOneByteInternalizedString) \ 991cb0ef41Sopenharmony_ci V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \ 1001cb0ef41Sopenharmony_ci V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \ 1011cb0ef41Sopenharmony_ci ThinOneByteString) \ 1021cb0ef41Sopenharmony_ci \ 1031cb0ef41Sopenharmony_ci V(SHARED_STRING_TYPE, kVariableSizeSentinel, shared_string, SharedString) \ 1041cb0ef41Sopenharmony_ci V(SHARED_ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, \ 1051cb0ef41Sopenharmony_ci shared_one_byte_string, SharedOneByteString) \ 1061cb0ef41Sopenharmony_ci V(SHARED_THIN_STRING_TYPE, ThinString::kSize, shared_thin_string, \ 1071cb0ef41Sopenharmony_ci SharedThinString) \ 1081cb0ef41Sopenharmony_ci V(SHARED_THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, \ 1091cb0ef41Sopenharmony_ci shared_thin_one_byte_string, SharedThinOneByteString) 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci// A struct is a simple object a set of object-valued fields. Including an 1121cb0ef41Sopenharmony_ci// object type in this causes the compiler to generate most of the boilerplate 1131cb0ef41Sopenharmony_ci// code for the class including allocation and garbage collection routines, 1141cb0ef41Sopenharmony_ci// casts and predicates. All you need to define is the class, methods and 1151cb0ef41Sopenharmony_ci// object verification routines. Easy, no? 1161cb0ef41Sopenharmony_ci#define STRUCT_LIST_GENERATOR(V, _) \ 1171cb0ef41Sopenharmony_ci V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \ 1181cb0ef41Sopenharmony_ci promise_fulfill_reaction_job_task) \ 1191cb0ef41Sopenharmony_ci V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \ 1201cb0ef41Sopenharmony_ci promise_reject_reaction_job_task) \ 1211cb0ef41Sopenharmony_ci V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \ 1221cb0ef41Sopenharmony_ci V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \ 1231cb0ef41Sopenharmony_ci V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \ 1241cb0ef41Sopenharmony_ci promise_resolve_thenable_job_task) \ 1251cb0ef41Sopenharmony_ci V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \ 1261cb0ef41Sopenharmony_ci function_template_info) \ 1271cb0ef41Sopenharmony_ci V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \ 1281cb0ef41Sopenharmony_ci V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \ 1291cb0ef41Sopenharmony_ci V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \ 1301cb0ef41Sopenharmony_ci V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \ 1311cb0ef41Sopenharmony_ci V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \ 1321cb0ef41Sopenharmony_ci aliased_arguments_entry) \ 1331cb0ef41Sopenharmony_ci V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \ 1341cb0ef41Sopenharmony_ci V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \ 1351cb0ef41Sopenharmony_ci array_boilerplate_description) \ 1361cb0ef41Sopenharmony_ci IF_WASM(V, _, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \ 1371cb0ef41Sopenharmony_ci V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \ 1381cb0ef41Sopenharmony_ci async_generator_request) \ 1391cb0ef41Sopenharmony_ci V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \ 1401cb0ef41Sopenharmony_ci V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \ 1411cb0ef41Sopenharmony_ci V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \ 1421cb0ef41Sopenharmony_ci cached_template_object) \ 1431cb0ef41Sopenharmony_ci V(_, CALL_SITE_INFO_TYPE, CallSiteInfo, call_site_info) \ 1441cb0ef41Sopenharmony_ci V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \ 1451cb0ef41Sopenharmony_ci V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \ 1461cb0ef41Sopenharmony_ci V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \ 1471cb0ef41Sopenharmony_ci V(_, ERROR_STACK_DATA_TYPE, ErrorStackData, error_stack_data) \ 1481cb0ef41Sopenharmony_ci V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \ 1491cb0ef41Sopenharmony_ci function_template_rare_data) \ 1501cb0ef41Sopenharmony_ci V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \ 1511cb0ef41Sopenharmony_ci V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \ 1521cb0ef41Sopenharmony_ci V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \ 1531cb0ef41Sopenharmony_ci V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \ 1541cb0ef41Sopenharmony_ci V(_, PROMISE_ON_STACK_TYPE, PromiseOnStack, promise_on_stack) \ 1551cb0ef41Sopenharmony_ci V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \ 1561cb0ef41Sopenharmony_ci V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \ 1571cb0ef41Sopenharmony_ci property_descriptor_object) \ 1581cb0ef41Sopenharmony_ci V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \ 1591cb0ef41Sopenharmony_ci V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \ 1601cb0ef41Sopenharmony_ci regexp_boilerplate_description) \ 1611cb0ef41Sopenharmony_ci V(_, SCRIPT_TYPE, Script, script) \ 1621cb0ef41Sopenharmony_ci V(_, SCRIPT_OR_MODULE_TYPE, ScriptOrModule, script_or_module) \ 1631cb0ef41Sopenharmony_ci V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \ 1641cb0ef41Sopenharmony_ci module_info_entry) \ 1651cb0ef41Sopenharmony_ci V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \ 1661cb0ef41Sopenharmony_ci V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \ 1671cb0ef41Sopenharmony_ci template_object_description) \ 1681cb0ef41Sopenharmony_ci V(_, TUPLE2_TYPE, Tuple2, tuple2) \ 1691cb0ef41Sopenharmony_ci IF_WASM(V, _, WASM_CONTINUATION_OBJECT_TYPE, WasmContinuationObject, \ 1701cb0ef41Sopenharmony_ci wasm_continuation_object) \ 1711cb0ef41Sopenharmony_ci IF_WASM(V, _, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \ 1721cb0ef41Sopenharmony_ci IF_WASM(V, _, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \ 1731cb0ef41Sopenharmony_ci wasm_indirect_function_table) 1741cb0ef41Sopenharmony_ci 1751cb0ef41Sopenharmony_ci// Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_LIST entry 1761cb0ef41Sopenharmony_ci#define STRUCT_LIST_ADAPTER(V, NAME, Name, name) V(NAME, Name, name) 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_ci// Produces (NAME, Name, name) entries. 1791cb0ef41Sopenharmony_ci#define STRUCT_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_LIST_ADAPTER, V) 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci// Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry 1821cb0ef41Sopenharmony_ci#define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \ 1831cb0ef41Sopenharmony_ci V(Map, name##_map, Name##Map) 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci// Produces (Map, struct_name_map, StructNameMap) entries 1861cb0ef41Sopenharmony_ci#define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V) 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ci// 1891cb0ef41Sopenharmony_ci// The following macros define list of allocation size objects and list of 1901cb0ef41Sopenharmony_ci// their maps. 1911cb0ef41Sopenharmony_ci// 1921cb0ef41Sopenharmony_ci#define ALLOCATION_SITE_LIST(V, _) \ 1931cb0ef41Sopenharmony_ci V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithWeakNext, allocation_site) \ 1941cb0ef41Sopenharmony_ci V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithoutWeakNext, \ 1951cb0ef41Sopenharmony_ci allocation_site_without_weaknext) 1961cb0ef41Sopenharmony_ci 1971cb0ef41Sopenharmony_ci// Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry 1981cb0ef41Sopenharmony_ci#define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 1991cb0ef41Sopenharmony_ci V(Map, name_size##_map, Name##Size##Map) 2001cb0ef41Sopenharmony_ci 2011cb0ef41Sopenharmony_ci// Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries 2021cb0ef41Sopenharmony_ci#define ALLOCATION_SITE_MAPS_LIST(V) \ 2031cb0ef41Sopenharmony_ci ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAPS_LIST_ADAPTER, V) 2041cb0ef41Sopenharmony_ci 2051cb0ef41Sopenharmony_ci// 2061cb0ef41Sopenharmony_ci// The following macros define list of data handler objects and list of their 2071cb0ef41Sopenharmony_ci// maps. 2081cb0ef41Sopenharmony_ci// 2091cb0ef41Sopenharmony_ci#define DATA_HANDLER_LIST(V, _) \ 2101cb0ef41Sopenharmony_ci V(_, LOAD_HANDLER_TYPE, LoadHandler, 1, load_handler1) \ 2111cb0ef41Sopenharmony_ci V(_, LOAD_HANDLER_TYPE, LoadHandler, 2, load_handler2) \ 2121cb0ef41Sopenharmony_ci V(_, LOAD_HANDLER_TYPE, LoadHandler, 3, load_handler3) \ 2131cb0ef41Sopenharmony_ci V(_, STORE_HANDLER_TYPE, StoreHandler, 0, store_handler0) \ 2141cb0ef41Sopenharmony_ci V(_, STORE_HANDLER_TYPE, StoreHandler, 1, store_handler1) \ 2151cb0ef41Sopenharmony_ci V(_, STORE_HANDLER_TYPE, StoreHandler, 2, store_handler2) \ 2161cb0ef41Sopenharmony_ci V(_, STORE_HANDLER_TYPE, StoreHandler, 3, store_handler3) 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_ci// Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry. 2191cb0ef41Sopenharmony_ci#define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ 2201cb0ef41Sopenharmony_ci V(Map, name_size##_map, Name##Size##Map) 2211cb0ef41Sopenharmony_ci 2221cb0ef41Sopenharmony_ci// Produces (Map, handler_name_map, HandlerNameMap) entries 2231cb0ef41Sopenharmony_ci#define DATA_HANDLER_MAPS_LIST(V) \ 2241cb0ef41Sopenharmony_ci DATA_HANDLER_LIST(DATA_HANDLER_MAPS_LIST_ADAPTER, V) 2251cb0ef41Sopenharmony_ci 2261cb0ef41Sopenharmony_ci} // namespace internal 2271cb0ef41Sopenharmony_ci} // namespace v8 2281cb0ef41Sopenharmony_ci 2291cb0ef41Sopenharmony_ci#endif // V8_OBJECTS_OBJECTS_DEFINITIONS_H_ 230