v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
objects-definitions.h
Go to the documentation of this file.
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 an 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 mirror
22
// their encoding in the instance_type field of the map. The other
23
// representations (e.g. CONS, EXTERNAL) are explicitly mentioned. Finally,
24
// the string is either a STRING_TYPE (if it is a normal string) or an
25
// INTERNALIZED_STRING_TYPE (if it is an internalized string).
26
//
27
// NOTE: The following things are some that depend on the string types having
28
// instance_types that are less than those of all other types:
29
// HeapObject::Size, HeapObject::IterateBody, the typeof operator, and
30
// Object::IsString.
31
#define INSTANCE_TYPE_LIST_BASE(V) \
32
V(INTERNALIZED_TWO_BYTE_STRING_TYPE) \
33
V(EXTERNAL_INTERNALIZED_TWO_BYTE_STRING_TYPE) \
34
V(INTERNALIZED_ONE_BYTE_STRING_TYPE) \
35
V(EXTERNAL_INTERNALIZED_ONE_BYTE_STRING_TYPE) \
36
V(UNCACHED_EXTERNAL_INTERNALIZED_TWO_BYTE_STRING_TYPE) \
37
V(UNCACHED_EXTERNAL_INTERNALIZED_ONE_BYTE_STRING_TYPE) \
38
V(SEQ_TWO_BYTE_STRING_TYPE) \
39
V(CONS_TWO_BYTE_STRING_TYPE) \
40
V(EXTERNAL_TWO_BYTE_STRING_TYPE) \
41
V(SLICED_TWO_BYTE_STRING_TYPE) \
42
V(THIN_TWO_BYTE_STRING_TYPE) \
43
V(SEQ_ONE_BYTE_STRING_TYPE) \
44
V(CONS_ONE_BYTE_STRING_TYPE) \
45
V(EXTERNAL_ONE_BYTE_STRING_TYPE) \
46
V(SLICED_ONE_BYTE_STRING_TYPE) \
47
V(THIN_ONE_BYTE_STRING_TYPE) \
48
V(UNCACHED_EXTERNAL_TWO_BYTE_STRING_TYPE) \
49
V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE) \
50
V(SHARED_SEQ_TWO_BYTE_STRING_TYPE) \
51
V(SHARED_EXTERNAL_TWO_BYTE_STRING_TYPE) \
52
V(SHARED_SEQ_ONE_BYTE_STRING_TYPE) \
53
V(SHARED_EXTERNAL_ONE_BYTE_STRING_TYPE) \
54
V(SHARED_UNCACHED_EXTERNAL_TWO_BYTE_STRING_TYPE) \
55
V(SHARED_UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE)
56
57
#define INSTANCE_TYPE_LIST(V) \
58
INSTANCE_TYPE_LIST_BASE(V) \
59
TORQUE_ASSIGNED_INSTANCE_TYPE_LIST(V)
60
61
// Since string types are not consecutive, this macro is used to iterate over
62
// them. The order matters for read only heap layout. The maps are placed such
63
// that string types map to address ranges of maps.
64
#define STRING_TYPE_LIST(V) \
65
/* Start sequential strings*/
\
66
V(SEQ_TWO_BYTE_STRING_TYPE, kVariableSizeSentinel, seq_two_byte_string, \
67
SeqTwoByteString) \
68
V(SEQ_ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, seq_one_byte_string, \
69
SeqOneByteString) \
70
V(SHARED_SEQ_TWO_BYTE_STRING_TYPE, kVariableSizeSentinel, \
71
shared_seq_two_byte_string, SharedSeqTwoByteString) \
72
V(SHARED_SEQ_ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, \
73
shared_seq_one_byte_string, SharedSeqOneByteString) \
74
/* Start internalized strings*/
\
75
V(INTERNALIZED_TWO_BYTE_STRING_TYPE, kVariableSizeSentinel, \
76
internalized_two_byte_string, InternalizedTwoByteString) \
77
V(INTERNALIZED_ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, \
78
internalized_one_byte_string, InternalizedOneByteString) \
79
/* End sequential strings*/
\
80
/* Start external strings*/
\
81
V(EXTERNAL_INTERNALIZED_TWO_BYTE_STRING_TYPE, sizeof(ExternalTwoByteString), \
82
external_internalized_two_byte_string, ExternalInternalizedTwoByteString) \
83
V(EXTERNAL_INTERNALIZED_ONE_BYTE_STRING_TYPE, sizeof(ExternalOneByteString), \
84
external_internalized_one_byte_string, ExternalInternalizedOneByteString) \
85
/* Start uncached external strings*/
\
86
V(UNCACHED_EXTERNAL_INTERNALIZED_TWO_BYTE_STRING_TYPE, \
87
sizeof(UncachedExternalString), \
88
uncached_external_internalized_two_byte_string, \
89
UncachedExternalInternalizedTwoByteString) \
90
V(UNCACHED_EXTERNAL_INTERNALIZED_ONE_BYTE_STRING_TYPE, \
91
sizeof(UncachedExternalString), \
92
uncached_external_internalized_one_byte_string, \
93
UncachedExternalInternalizedOneByteString) \
94
/* End internalized strings*/
\
95
V(UNCACHED_EXTERNAL_TWO_BYTE_STRING_TYPE, sizeof(UncachedExternalString), \
96
uncached_external_two_byte_string, UncachedExternalTwoByteString) \
97
V(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE, sizeof(UncachedExternalString), \
98
uncached_external_one_byte_string, UncachedExternalOneByteString) \
99
V(SHARED_UNCACHED_EXTERNAL_TWO_BYTE_STRING_TYPE, \
100
sizeof(UncachedExternalString), shared_uncached_external_two_byte_string, \
101
SharedUncachedExternalTwoByteString) \
102
V(SHARED_UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE, \
103
sizeof(UncachedExternalString), shared_uncached_external_one_byte_string, \
104
SharedUncachedExternalOneByteString) \
105
/* End uncached external strings*/
\
106
V(EXTERNAL_TWO_BYTE_STRING_TYPE, sizeof(ExternalTwoByteString), \
107
external_two_byte_string, ExternalTwoByteString) \
108
V(EXTERNAL_ONE_BYTE_STRING_TYPE, sizeof(ExternalOneByteString), \
109
external_one_byte_string, ExternalOneByteString) \
110
V(SHARED_EXTERNAL_TWO_BYTE_STRING_TYPE, sizeof(ExternalTwoByteString), \
111
shared_external_two_byte_string, SharedExternalTwoByteString) \
112
V(SHARED_EXTERNAL_ONE_BYTE_STRING_TYPE, sizeof(ExternalOneByteString), \
113
shared_external_one_byte_string, SharedExternalOneByteString) \
114
/* End external strings*/
\
115
\
116
V(CONS_TWO_BYTE_STRING_TYPE, sizeof(ConsString), cons_two_byte_string, \
117
ConsTwoByteString) \
118
V(CONS_ONE_BYTE_STRING_TYPE, sizeof(ConsString), cons_one_byte_string, \
119
ConsOneByteString) \
120
V(SLICED_TWO_BYTE_STRING_TYPE, sizeof(SlicedString), sliced_two_byte_string, \
121
SlicedTwoByteString) \
122
V(SLICED_ONE_BYTE_STRING_TYPE, sizeof(SlicedString), sliced_one_byte_string, \
123
SlicedOneByteString) \
124
V(THIN_TWO_BYTE_STRING_TYPE, sizeof(ThinString), thin_two_byte_string, \
125
ThinTwoByteString) \
126
V(THIN_ONE_BYTE_STRING_TYPE, sizeof(ThinString), thin_one_byte_string, \
127
ThinOneByteString)
128
129
// A struct is a simple object a set of object-valued fields. Including an
130
// object type in this causes the compiler to generate most of the boilerplate
131
// code for the class including allocation and garbage collection routines,
132
// casts and predicates. All you need to define is the class, methods and
133
// object verification routines. Easy, no?
134
#define STRUCT_LIST_GENERATOR(V, _) \
135
V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \
136
promise_fulfill_reaction_job_task) \
137
V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \
138
promise_reject_reaction_job_task) \
139
V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \
140
V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \
141
V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \
142
promise_resolve_thenable_job_task) \
143
V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \
144
V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \
145
V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \
146
aliased_arguments_entry) \
147
V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \
148
V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \
149
array_boilerplate_description) \
150
IF_WASM(V, _, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \
151
V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \
152
async_generator_request) \
153
V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \
154
V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \
155
V(_, BYTECODE_WRAPPER_TYPE, BytecodeWrapper, bytecode_wrapper) \
156
V(_, CALL_SITE_INFO_TYPE, CallSiteInfo, call_site_info) \
157
V(_, CLASS_BOILERPLATE_TYPE, ClassBoilerplate, class_boilerplate) \
158
V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \
159
V(_, CODE_WRAPPER_TYPE, CodeWrapper, code_wrapper) \
160
V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \
161
V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \
162
V(_, ERROR_STACK_DATA_TYPE, ErrorStackData, error_stack_data) \
163
V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \
164
function_template_rare_data) \
165
V(_, MODULE_REQUEST_TYPE, ModuleRequest, module_request) \
166
V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \
167
V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \
168
V(_, PROPERTY_DESCRIPTOR_OBJECT_TYPE, PropertyDescriptorObject, \
169
property_descriptor_object) \
170
V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \
171
V(_, REG_EXP_BOILERPLATE_DESCRIPTION_TYPE, RegExpBoilerplateDescription, \
172
regexp_boilerplate_description) \
173
V(_, REG_EXP_DATA_WRAPPER_TYPE, RegExpDataWrapper, regexp_data_wrapper) \
174
V(_, SCRIPT_TYPE, Script, script) \
175
V(_, SCRIPT_OR_MODULE_TYPE, ScriptOrModule, script_or_module) \
176
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
177
module_info_entry) \
178
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \
179
V(_, STACK_TRACE_INFO_TYPE, StackTraceInfo, stack_trace_info) \
180
V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \
181
template_object_description) \
182
V(_, TUPLE2_TYPE, Tuple2, tuple2) \
183
IF_WASM(V, _, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag)
184
185
// Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_LIST entry
186
#define STRUCT_LIST_ADAPTER(V, NAME, Name, name) V(NAME, Name, name)
187
188
// Produces (NAME, Name, name) entries.
189
#define STRUCT_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_LIST_ADAPTER, V)
190
191
// Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry
192
#define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \
193
V(Map, name##_map, Name##Map)
194
195
// Produces (Map, struct_name_map, StructNameMap) entries
196
#define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V)
197
198
//
199
// The following macros define list of allocation size objects and list of
200
// their maps.
201
//
202
#define ALLOCATION_SITE_LIST(V, _) \
203
V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithWeakNext, allocation_site) \
204
V(_, ALLOCATION_SITE_TYPE, AllocationSite, WithoutWeakNext, \
205
allocation_site_without_weaknext)
206
207
// Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry
208
#define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \
209
V(Map, name_size##_map, Name##Size##Map)
210
211
// Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries
212
#define ALLOCATION_SITE_MAPS_LIST(V) \
213
ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAPS_LIST_ADAPTER, V)
214
215
//
216
// The following macros define list of data handler objects and list of their
217
// maps.
218
//
219
#define DATA_HANDLER_LIST(V, _) \
220
V(_, LOAD_HANDLER_TYPE, LoadHandler, 1, load_handler1) \
221
V(_, LOAD_HANDLER_TYPE, LoadHandler, 2, load_handler2) \
222
V(_, LOAD_HANDLER_TYPE, LoadHandler, 3, load_handler3) \
223
V(_, STORE_HANDLER_TYPE, StoreHandler, 0, store_handler0) \
224
V(_, STORE_HANDLER_TYPE, StoreHandler, 1, store_handler1) \
225
V(_, STORE_HANDLER_TYPE, StoreHandler, 2, store_handler2) \
226
V(_, STORE_HANDLER_TYPE, StoreHandler, 3, store_handler3)
227
228
// Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry.
229
#define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \
230
V(Map, name_size##_map, Name##Size##Map)
231
232
// Produces (Map, handler_name_map, HandlerNameMap) entries
233
#define DATA_HANDLER_MAPS_LIST(V) \
234
DATA_HANDLER_LIST(DATA_HANDLER_MAPS_LIST_ADAPTER, V)
235
236
}
// namespace internal
237
}
// namespace v8
238
239
#endif
// V8_OBJECTS_OBJECTS_DEFINITIONS_H_
heap-symbols.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
src
objects
objects-definitions.h
Generated on Sun Apr 6 2025 21:08:56 for v8 by
1.12.0