v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
object-list-macros.h
Go to the documentation of this file.
1// Copyright 2019 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_OBJECT_LIST_MACROS_H_
6#define V8_OBJECTS_OBJECT_LIST_MACROS_H_
7
8#include "src/base/macros.h" // For IF_WASM.
9#include "torque-generated/instance-types.h"
10
11namespace v8 {
12namespace internal {
13
14// SIMPLE_HEAP_OBJECT_LIST1 and SIMPLE_HEAP_OBJECT_LIST2 are intended to
15// simplify type-related boilerplate. How to use these lists: add types here,
16// and don't add them in other related macro lists below (e.g.
17// HEAP_OBJECT_ORDINARY_TYPE_LIST), and don't add them in various other spots
18// (e.g. Map::GetVisitorId). Easy.
19//
20// All types in these lists, the 'simple' types, must satisfy the following
21// conditions. They:
22//
23// - are an 'ordinary type' (HEAP_OBJECT_ORDINARY_TYPE_LIST)
24// - define TypeCamelCase::AllocatedSize()
25// - define TypeCamelCase::BodyDescriptor
26// - have an associated visitor id kVisit##TypeCamelCase
27// - have an associated instance type TYPE_UPPER_CASE##_TYPE
28//
29// Also don't forget about DYNAMICALLY_SIZED_HEAP_OBJECT_LIST.
30//
31// Note these lists are split into multiple lists for historic/pragmatic
32// reasons since many users pass a macro `V` that expects exactly one argument.
33//
34// TODO(jgruber): Extend this list. There's more we can move here from
35// HEAP_OBJECT_ORDINARY_TYPE_LIST.
36// TODO(jgruber): Consider merging this file with objects-definitions.h.
37#define SIMPLE_HEAP_OBJECT_LIST_GENERATOR(APPLY, V) \
38 APPLY(V, ArrayList, ARRAY_LIST) \
39 APPLY(V, ByteArray, BYTE_ARRAY) \
40 APPLY(V, ClosureFeedbackCellArray, CLOSURE_FEEDBACK_CELL_ARRAY) \
41 APPLY(V, FixedArray, FIXED_ARRAY) \
42 APPLY(V, FixedDoubleArray, FIXED_DOUBLE_ARRAY) \
43 APPLY(V, ObjectBoilerplateDescription, OBJECT_BOILERPLATE_DESCRIPTION) \
44 APPLY(V, RegExpMatchInfo, REG_EXP_MATCH_INFO) \
45 APPLY(V, ScriptContextTable, SCRIPT_CONTEXT_TABLE) \
46 APPLY(V, WeakFixedArray, WEAK_FIXED_ARRAY)
47
48// The SIMPLE_HEAP_OBJECT_LIST1 format is:
49// V(TypeCamelCase)
50//
51#define SIMPLE_HEAP_OBJECT_LIST1_ADAPTER(V, Name, NAME) V(Name)
52#define SIMPLE_HEAP_OBJECT_LIST1(V) \
53 SIMPLE_HEAP_OBJECT_LIST_GENERATOR(SIMPLE_HEAP_OBJECT_LIST1_ADAPTER, V)
54
55// The SIMPLE_HEAP_OBJECT_LIST2 format is:
56// V(TypeCamelCase, TYPE_UPPER_CASE)
57//
58#define SIMPLE_HEAP_OBJECT_LIST2_ADAPTER(V, Name, NAME) V(Name, NAME)
59#define SIMPLE_HEAP_OBJECT_LIST2(V) \
60 SIMPLE_HEAP_OBJECT_LIST_GENERATOR(SIMPLE_HEAP_OBJECT_LIST2_ADAPTER, V)
61
62// Types in this list may be allocated in large object spaces.
63#define DYNAMICALLY_SIZED_HEAP_OBJECT_LIST(V) \
64 V(ArrayList) \
65 V(BigInt) \
66 V(ByteArray) \
67 V(BytecodeArray) \
68 V(ClosureFeedbackCellArray) \
69 V(Code) \
70 V(Context) \
71 V(ExternalString) \
72 V(FeedbackMetadata) \
73 V(FeedbackVector) \
74 V(FixedArray) \
75 V(FixedDoubleArray) \
76 V(FreeSpace) \
77 V(InstructionStream) \
78 V(ObjectBoilerplateDescription) \
79 V(PreparseData) \
80 V(PropertyArray) \
81 V(ProtectedFixedArray) \
82 V(ProtectedWeakFixedArray) \
83 V(RegExpMatchInfo) \
84 V(ScopeInfo) \
85 V(ScriptContextTable) \
86 V(SeqString) \
87 V(SloppyArgumentsElements) \
88 V(SwissNameDictionary) \
89 V(ThinString) \
90 V(TrustedByteArray) \
91 V(TrustedFixedArray) \
92 V(TrustedWeakFixedArray) \
93 V(UncompiledDataWithoutPreparseData) \
94 V(WeakArrayList) \
95 V(WeakFixedArray) \
96 IF_WASM(V, WasmArray) \
97 IF_WASM(V, WasmDispatchTable) \
98 IF_WASM(V, WasmStruct)
99
100// TODO(jgruber): Move more types to SIMPLE_HEAP_OBJECT_LIST_GENERATOR.
101#define HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
102 V(AbstractCode) \
103 V(AccessorInfo) \
104 V(AllocationSite) \
105 V(BigInt) \
106 V(BigIntBase) \
107 V(Boolean) \
108 V(Cell) \
109 V(CompilationCacheTable) \
110 V(ConsString) \
111 V(ContextSidePropertyCell) \
112 V(Context) \
113 V(CoverageInfo) \
114 V(DataHandler) \
115 V(DeoptimizationData) \
116 V(DependentCode) \
117 V(DescriptorArray) \
118 V(DictionaryTemplateInfo) \
119 V(EmbedderDataArray) \
120 V(EphemeronHashTable) \
121 V(ExternalOneByteString) \
122 V(ExternalString) \
123 V(ExternalTwoByteString) \
124 V(FeedbackCell) \
125 V(FeedbackMetadata) \
126 V(FeedbackVector) \
127 V(FunctionTemplateInfo) \
128 V(FixedArrayBase) \
129 V(FixedArrayExact) \
130 V(Foreign) \
131 V(FreeSpace) \
132 V(GcSafeCode) \
133 V(GlobalDictionary) \
134 V(HeapNumber) \
135 V(InterceptorInfo) \
136 V(InternalizedString) \
137 V(JSArgumentsObject) \
138 V(JSArray) \
139 V(JSArrayBuffer) \
140 V(JSArrayBufferView) \
141 V(JSArrayIterator) \
142 V(JSAsyncFromSyncIterator) \
143 V(JSAsyncFunctionObject) \
144 V(JSAsyncGeneratorObject) \
145 V(JSAtomicsCondition) \
146 V(JSAtomicsMutex) \
147 V(JSBoundFunction) \
148 V(JSCollection) \
149 V(JSCollectionIterator) \
150 V(JSCustomElementsObject) \
151 V(JSDataView) \
152 V(JSDataViewOrRabGsabDataView) \
153 V(JSDate) \
154 V(JSDisposableStackBase) \
155 V(JSSyncDisposableStack) \
156 V(JSAsyncDisposableStack) \
157 V(JSExternalObject) \
158 V(JSFinalizationRegistry) \
159 V(JSFunction) \
160 V(JSFunctionOrBoundFunctionOrWrappedFunction) \
161 V(JSGeneratorObject) \
162 V(JSGlobalObject) \
163 V(JSGlobalProxy) \
164 V(JSIteratorHelper) \
165 V(JSIteratorFilterHelper) \
166 V(JSIteratorMapHelper) \
167 V(JSIteratorTakeHelper) \
168 V(JSIteratorDropHelper) \
169 V(JSIteratorFlatMapHelper) \
170 V(JSMap) \
171 V(JSMapIterator) \
172 V(JSMessageObject) \
173 V(JSModuleNamespace) \
174 V(JSObject) \
175 V(JSAPIObjectWithEmbedderSlots) \
176 V(JSObjectWithEmbedderSlots) \
177 V(JSPrimitiveWrapper) \
178 V(JSPromise) \
179 V(JSProxy) \
180 V(JSRabGsabDataView) \
181 V(JSRawJson) \
182 V(JSReceiver) \
183 V(JSRegExp) \
184 V(JSRegExpStringIterator) \
185 V(JSSet) \
186 V(JSSetIterator) \
187 V(JSShadowRealm) \
188 V(JSSharedArray) \
189 V(JSSharedStruct) \
190 V(JSSpecialObject) \
191 V(JSStringIterator) \
192 V(JSSynchronizationPrimitive) \
193 V(JSTemporalCalendar) \
194 V(JSTemporalDuration) \
195 V(JSTemporalInstant) \
196 V(JSTemporalPlainDate) \
197 V(JSTemporalPlainTime) \
198 V(JSTemporalPlainDateTime) \
199 V(JSTemporalPlainMonthDay) \
200 V(JSTemporalPlainYearMonth) \
201 V(JSTemporalTimeZone) \
202 V(JSTemporalZonedDateTime) \
203 V(JSTypedArray) \
204 V(JSValidIteratorWrapper) \
205 V(JSWeakCollection) \
206 V(JSWeakRef) \
207 V(JSWeakMap) \
208 V(JSWeakSet) \
209 V(JSWrappedFunction) \
210 V(LoadHandler) \
211 V(Map) \
212 V(MegaDomHandler) \
213 V(Module) \
214 V(Microtask) \
215 V(Name) \
216 V(NameDictionary) \
217 V(NameToIndexHashTable) \
218 V(NativeContext) \
219 V(NormalizedMapCache) \
220 V(NumberDictionary) \
221 V(ObjectHashSet) \
222 V(ObjectHashTable) \
223 V(ObjectTemplateInfo) \
224 V(ObjectTwoHashTable) \
225 V(Oddball) \
226 V(Hole) \
227 V(OrderedHashMap) \
228 V(OrderedHashSet) \
229 V(OrderedNameDictionary) \
230 V(PreparseData) \
231 V(PrimitiveHeapObject) \
232 V(PromiseReactionJobTask) \
233 V(PropertyArray) \
234 V(PropertyCell) \
235 V(ScopeInfo) \
236 V(SeqOneByteString) \
237 V(SeqString) \
238 V(SeqTwoByteString) \
239 V(SharedFunctionInfo) \
240 V(SimpleNumberDictionary) \
241 V(SlicedString) \
242 V(SmallOrderedHashMap) \
243 V(SmallOrderedHashSet) \
244 V(SmallOrderedNameDictionary) \
245 V(SourceTextModule) \
246 V(SourceTextModuleInfo) \
247 V(StoreHandler) \
248 V(String) \
249 V(StringSet) \
250 V(RegisteredSymbolTable) \
251 V(Struct) \
252 V(SwissNameDictionary) \
253 V(Symbol) \
254 V(SyntheticModule) \
255 V(TemplateInfo) \
256 V(TemplateInfoWithProperties) \
257 V(TemplateLiteralObject) \
258 V(ThinString) \
259 V(TransitionArray) \
260 V(TurboshaftFloat64RangeType) \
261 V(TurboshaftFloat64SetType) \
262 V(TurboshaftFloat64Type) \
263 V(TurboshaftType) \
264 V(TurboshaftWord32RangeType) \
265 V(TurboshaftWord32SetType) \
266 V(TurboshaftWord32Type) \
267 V(TurboshaftWord64RangeType) \
268 V(TurboshaftWord64SetType) \
269 V(TurboshaftWord64Type) \
270 IF_WASM(V, WasmArray) \
271 IF_WASM(V, WasmExceptionPackage) \
272 IF_WASM(V, WasmFuncRef) \
273 IF_WASM(V, WasmGlobalObject) \
274 IF_WASM(V, WasmInstanceObject) \
275 IF_WASM(V, WasmMemoryObject) \
276 IF_WASM(V, WasmMemoryMapDescriptor) \
277 IF_WASM(V, WasmModuleObject) \
278 IF_WASM(V, WasmNull) \
279 IF_WASM(V, WasmObject) \
280 IF_WASM(V, WasmResumeData) \
281 IF_WASM(V, WasmStruct) \
282 IF_WASM(V, WasmSuspenderObject) \
283 IF_WASM(V, WasmSuspendingObject) \
284 IF_WASM(V, WasmTableObject) \
285 IF_WASM(V, WasmTagObject) \
286 IF_WASM(V, WasmTypeInfo) \
287 IF_WASM(V, WasmValueObject) \
288 V(WeakArrayList) \
289 V(WeakCell) \
290 TORQUE_DEFINED_CLASS_LIST(V) \
291 SIMPLE_HEAP_OBJECT_LIST1(V)
292
293// These are artificial object types which don't have properly defined classes
294// but exist for the sake of type checking, for example IsCallable().
295#define VIRTUAL_OBJECT_TYPE_LIST(V) \
296 V(AccessCheckNeeded) \
297 V(AlwaysSharedSpaceJSObject) \
298 V(BigIntWrapper) \
299 V(BooleanWrapper) \
300 V(Callable) \
301 V(Constructor) \
302 V(Filler) \
303 V(HandlerTable) \
304 V(JSContextExtensionObject) \
305 V(JSError) \
306 V(MapCache) \
307 V(NumberWrapper) \
308 V(OSROptimizedCodeCache) \
309 V(ScriptWrapper) \
310 V(StringWrapper) \
311 V(SymbolWrapper) \
312 V(UniqueName) \
313 V(Undetectable)
314
315#ifdef V8_INTL_SUPPORT
316#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
317 HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
318 V(JSV8BreakIterator) \
319 V(JSCollator) \
320 V(JSDateTimeFormat) \
321 V(JSDisplayNames) \
322 V(JSDurationFormat) \
323 V(JSListFormat) \
324 V(JSLocale) \
325 V(JSNumberFormat) \
326 V(JSPluralRules) \
327 V(JSRelativeTimeFormat) \
328 V(JSSegmentDataObject) \
329 V(JSSegmentDataObjectWithIsWordLike) \
330 V(JSSegmentIterator) \
331 V(JSSegmenter) \
332 V(JSSegments)
333#else
334#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V)
335#endif // V8_INTL_SUPPORT
336
337//
338// Trusted Objects.
339//
340// Objects that are considered trusted. They must inherit from TrustedObject
341// and live in trusted space, outside of the sandbox.
342//
343
344#define ABSTRACT_TRUSTED_OBJECT_LIST_GENERATOR(APPLY, V) \
345 APPLY(V, TrustedObject, TRUSTED_OBJECT) \
346 APPLY(V, ExposedTrustedObject, EXPOSED_TRUSTED_OBJECT) \
347 APPLY(V, UncompiledData, UNCOMPILED_DATA) \
348 IF_WASM(APPLY, V, WasmFunctionData, WASM_FUNCTION_DATA)
349
350// Concrete trusted objects. These must:
351// - (Transitively) inherit from TrustedObject
352// - Have a unique instance type
353// - Define a custom body descriptor
354#define CONCRETE_TRUSTED_OBJECT_LIST_GENERATOR(APPLY, V) \
355 APPLY(V, BytecodeArray, BYTECODE_ARRAY) \
356 APPLY(V, Code, CODE) \
357 APPLY(V, InstructionStream, INSTRUCTION_STREAM) \
358 APPLY(V, InterpreterData, INTERPRETER_DATA) \
359 APPLY(V, UncompiledDataWithPreparseData, UNCOMPILED_DATA_WITH_PREPARSE_DATA) \
360 APPLY(V, UncompiledDataWithoutPreparseData, \
361 UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA) \
362 APPLY(V, UncompiledDataWithPreparseDataAndJob, \
363 UNCOMPILED_DATA_WITH_PREPARSE_DATA_AND_JOB) \
364 APPLY(V, UncompiledDataWithoutPreparseDataWithJob, \
365 UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_WITH_JOB) \
366 APPLY(V, SharedFunctionInfoWrapper, SHARED_FUNCTION_INFO_WRAPPER) \
367 APPLY(V, ProtectedFixedArray, PROTECTED_FIXED_ARRAY) \
368 APPLY(V, ProtectedWeakFixedArray, PROTECTED_WEAK_FIXED_ARRAY) \
369 APPLY(V, TrustedByteArray, TRUSTED_BYTE_ARRAY) \
370 APPLY(V, TrustedFixedArray, TRUSTED_FIXED_ARRAY) \
371 APPLY(V, TrustedForeign, TRUSTED_FOREIGN) \
372 APPLY(V, TrustedWeakFixedArray, TRUSTED_WEAK_FIXED_ARRAY) \
373 APPLY(V, AtomRegExpData, ATOM_REG_EXP_DATA) \
374 APPLY(V, IrRegExpData, IR_REG_EXP_DATA) \
375 APPLY(V, RegExpData, REG_EXP_DATA) \
376 IF_WASM(APPLY, V, WasmImportData, WASM_IMPORT_DATA) \
377 IF_WASM(APPLY, V, WasmCapiFunctionData, WASM_CAPI_FUNCTION_DATA) \
378 IF_WASM(APPLY, V, WasmDispatchTable, WASM_DISPATCH_TABLE) \
379 IF_WASM(APPLY, V, WasmExportedFunctionData, WASM_EXPORTED_FUNCTION_DATA) \
380 IF_WASM(APPLY, V, WasmJSFunctionData, WASM_JS_FUNCTION_DATA) \
381 IF_WASM(APPLY, V, WasmInternalFunction, WASM_INTERNAL_FUNCTION) \
382 IF_WASM(APPLY, V, WasmTrustedInstanceData, WASM_TRUSTED_INSTANCE_DATA)
383
384#define TRUSTED_OBJECT_LIST1_ADAPTER(V, Name, NAME) V(Name)
385#define TRUSTED_OBJECT_LIST2_ADAPTER(V, Name, NAME) V(Name, NAME)
386
387// The format is:
388// V(TypeCamelCase)
389#define CONCRETE_TRUSTED_OBJECT_TYPE_LIST1(V) \
390 CONCRETE_TRUSTED_OBJECT_LIST_GENERATOR(TRUSTED_OBJECT_LIST1_ADAPTER, V)
391// The format is:
392// V(TypeCamelCase, TYPE_UPPER_CASE)
393#define CONCRETE_TRUSTED_OBJECT_TYPE_LIST2(V) \
394 CONCRETE_TRUSTED_OBJECT_LIST_GENERATOR(TRUSTED_OBJECT_LIST2_ADAPTER, V)
395
396// The format is:
397// V(TypeCamelCase)
398#define HEAP_OBJECT_TRUSTED_TYPE_LIST(V) \
399 ABSTRACT_TRUSTED_OBJECT_LIST_GENERATOR(TRUSTED_OBJECT_LIST1_ADAPTER, V) \
400 CONCRETE_TRUSTED_OBJECT_LIST_GENERATOR(TRUSTED_OBJECT_LIST1_ADAPTER, V)
401
402#define HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) V(HashTable)
403
404// Logical sub-types of heap objects that don't correspond to a C++ class but
405// represent some specialization in terms of additional constraints.
406#define HEAP_OBJECT_SPECIALIZED_TYPE_LIST(V) \
407 V(AwaitContext) \
408 V(BlockContext) \
409 V(CallableApiObject) \
410 V(CallableJSFunction) \
411 V(CallableJSProxy) \
412 V(CatchContext) \
413 V(DebugEvaluateContext) \
414 V(EvalContext) \
415 V(FreeSpaceOrFiller) \
416 V(FunctionContext) \
417 V(JSApiObject) \
418 V(JSClassConstructor) \
419 V(JSLastDummyApiObject) \
420 V(JSPromiseConstructor) \
421 V(JSArrayConstructor) \
422 V(JSRegExpConstructor) \
423 V(JSMapKeyIterator) \
424 V(JSMapKeyValueIterator) \
425 V(JSMapValueIterator) \
426 V(JSSetKeyValueIterator) \
427 V(JSSetValueIterator) \
428 V(JSSpecialApiObject) \
429 V(MaybeReadOnlyJSObject) \
430 V(ModuleContext) \
431 V(NonNullForeign) \
432 V(ScriptContext) \
433 V(WithContext) \
434 V(JSInternalPrototypeBase) \
435 V(JSObjectPrototype) \
436 V(JSRegExpPrototype) \
437 V(JSPromisePrototype) \
438 V(JSSetPrototype) \
439 V(JSIteratorPrototype) \
440 V(JSArrayIteratorPrototype) \
441 V(JSMapIteratorPrototype) \
442 V(JSTypedArrayPrototype) \
443 V(JSSetIteratorPrototype) \
444 V(JSStringIteratorPrototype) \
445 V(TypedArrayConstructor) \
446 V(Uint8TypedArrayConstructor) \
447 V(Int8TypedArrayConstructor) \
448 V(Uint16TypedArrayConstructor) \
449 V(Int16TypedArrayConstructor) \
450 V(Uint32TypedArrayConstructor) \
451 V(Int32TypedArrayConstructor) \
452 V(Float16TypedArrayConstructor) \
453 V(Float32TypedArrayConstructor) \
454 V(Float64TypedArrayConstructor) \
455 V(Uint8ClampedTypedArrayConstructor) \
456 V(Biguint64TypedArrayConstructor) \
457 V(Bigint64TypedArrayConstructor)
458
459#define HEAP_OBJECT_TYPE_LIST(V) \
460 HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
461 VIRTUAL_OBJECT_TYPE_LIST(V) \
462 HEAP_OBJECT_TRUSTED_TYPE_LIST(V) \
463 HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) \
464 HEAP_OBJECT_SPECIALIZED_TYPE_LIST(V)
465
466#define ODDBALL_LIST(V) \
467 V(Undefined, undefined_value, UndefinedValue) \
468 V(Null, null_value, NullValue) \
469 V(True, true_value, TrueValue) \
470 V(False, false_value, FalseValue)
471
472#define HOLE_LIST(V) \
473 V(TheHole, the_hole_value, TheHoleValue) \
474 V(PropertyCellHole, property_cell_hole_value, PropertyCellHoleValue) \
475 V(HashTableHole, hash_table_hole_value, HashTableHoleValue) \
476 V(PromiseHole, promise_hole_value, PromiseHoleValue) \
477 V(Exception, exception, Exception) \
478 V(TerminationException, termination_exception, TerminationException) \
479 V(Uninitialized, uninitialized_value, UninitializedValue) \
480 V(ArgumentsMarker, arguments_marker, ArgumentsMarker) \
481 V(OptimizedOut, optimized_out, OptimizedOut) \
482 V(StaleRegister, stale_register, StaleRegister) \
483 V(SelfReferenceMarker, self_reference_marker, SelfReferenceMarker) \
484 V(BasicBlockCountersMarker, basic_block_counters_marker, \
485 BasicBlockCountersMarker)
486
487#define OBJECT_TYPE_LIST(V) \
488 V(Primitive) \
489 V(Number) \
490 V(Numeric)
491
492// These forward-declarations expose heap object types to most of our codebase.
493#define DEF_FWD_DECLARATION(Type) class Type;
498#undef DEF_FWD_DECLARATION
499
500} // namespace internal
501} // namespace v8
502
503#endif // V8_OBJECTS_OBJECT_LIST_MACROS_H_
#define DEF_FWD_DECLARATION(Type)
#define HEAP_OBJECT_TRUSTED_TYPE_LIST(V)
#define VIRTUAL_OBJECT_TYPE_LIST(V)
#define HEAP_OBJECT_SPECIALIZED_TYPE_LIST(V)
#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V)