1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_COMPILER_RUNTIME_OFFSETS_LIST_H_
6#define RUNTIME_VM_COMPILER_RUNTIME_OFFSETS_LIST_H_
7
8// Macro list of all constants that differ based on whether the architecture is
9// 32-bit or 64-bit. They are used to allow the target architecture to differ
10// from the host, like this:
11// 1) The macros correspond to constants defined throughout the VM that are
12// sized based on the *host* architecture.
13// 2) offsets_extractor.cc prints these values to runtime_offsets_extracted.h,
14// for both 32 and 64 bit architectures.
15// 3) runtime_api.h presents the runtime_offsets_extracted.h constants in a way
16// designed to look like the original constants from 1), but now namespaced
17// to dart::compiler::target, and sized based on the *target* architecture.
18// 4) Users of the constants from 1) can now just add the namespace from 3) to
19// get all their constants sized based on the target rather than the host.
20
21// FIELD(Class, Name) Offset of a field within a class.
22// ARRAY(Class, Name) Offset of the first element and the size of the elements
23// in an array of this class.
24// SIZEOF(Class, Name, What) Size of an object.
25// RANGE(Class, Name, Type, First, Last, Filter) An array of offsets generated
26// by passing a value of the given Type in the range from First to Last to
27// Class::Name() if Filter returns true for that value.
28// CONSTANT(Class, Name) Miscellaneous constant.
29//
30// COMMON_OFFSETS_LIST is for declarations that are valid in all contexts.
31// JIT_OFFSETS_LIST is for declarations that are only valid in JIT mode.
32// A declaration that is not valid in product mode can be wrapped with
33// NOT_IN_PRODUCT().
34#define COMMON_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, RANGE, CONSTANT) \
35 ARRAY(ObjectPool, element_offset) \
36 CONSTANT(Array, kMaxElements) \
37 CONSTANT(Array, kMaxNewSpaceElements) \
38 CONSTANT(Instructions, kMonomorphicEntryOffsetJIT) \
39 CONSTANT(Instructions, kPolymorphicEntryOffsetJIT) \
40 CONSTANT(Instructions, kMonomorphicEntryOffsetAOT) \
41 CONSTANT(Instructions, kPolymorphicEntryOffsetAOT) \
42 CONSTANT(OldPage, kBytesPerCardLog2) \
43 CONSTANT(NativeEntry, kNumCallWrapperArguments) \
44 CONSTANT(String, kMaxElements) \
45 CONSTANT(SubtypeTestCache, kFunctionTypeArguments) \
46 CONSTANT(SubtypeTestCache, kInstanceClassIdOrFunction) \
47 CONSTANT(SubtypeTestCache, kInstanceDelayedFunctionTypeArguments) \
48 CONSTANT(SubtypeTestCache, kInstanceParentFunctionTypeArguments) \
49 CONSTANT(SubtypeTestCache, kInstanceTypeArguments) \
50 CONSTANT(SubtypeTestCache, kInstantiatorTypeArguments) \
51 CONSTANT(SubtypeTestCache, kTestEntryLength) \
52 CONSTANT(SubtypeTestCache, kTestResult) \
53 FIELD(AbstractType, type_test_stub_entry_point_offset) \
54 FIELD(ArgumentsDescriptor, count_offset) \
55 FIELD(ArgumentsDescriptor, size_offset) \
56 FIELD(ArgumentsDescriptor, first_named_entry_offset) \
57 FIELD(ArgumentsDescriptor, named_entry_size) \
58 FIELD(ArgumentsDescriptor, name_offset) \
59 FIELD(ArgumentsDescriptor, position_offset) \
60 FIELD(ArgumentsDescriptor, positional_count_offset) \
61 FIELD(ArgumentsDescriptor, type_args_len_offset) \
62 FIELD(Array, data_offset) \
63 FIELD(Array, length_offset) \
64 FIELD(Array, tags_offset) \
65 FIELD(Array, type_arguments_offset) \
66 FIELD(Class, declaration_type_offset) \
67 FIELD(Class, num_type_arguments_offset) \
68 FIELD(Class, super_type_offset) \
69 FIELD(Class, host_type_arguments_field_offset_in_words_offset) \
70 NOT_IN_PRODUCT(FIELD(SharedClassTable, class_heap_stats_table_offset)) \
71 FIELD(Closure, context_offset) \
72 FIELD(Closure, delayed_type_arguments_offset) \
73 FIELD(Closure, function_offset) \
74 FIELD(Closure, function_type_arguments_offset) \
75 FIELD(Closure, hash_offset) \
76 FIELD(Closure, instantiator_type_arguments_offset) \
77 FIELD(Code, object_pool_offset) \
78 FIELD(Code, saved_instructions_offset) \
79 FIELD(Code, owner_offset) \
80 FIELD(Context, num_variables_offset) \
81 FIELD(Context, parent_offset) \
82 FIELD(Double, value_offset) \
83 FIELD(ExternalOneByteString, external_data_offset) \
84 FIELD(ExternalTwoByteString, external_data_offset) \
85 FIELD(Float32x4, value_offset) \
86 FIELD(Float64x2, value_offset) \
87 FIELD(Field, initializer_function_offset) \
88 FIELD(Field, host_offset_or_field_id_offset) \
89 FIELD(Field, guarded_cid_offset) \
90 FIELD(Field, guarded_list_length_in_object_offset_offset) \
91 FIELD(Field, guarded_list_length_offset) \
92 FIELD(Field, is_nullable_offset) \
93 FIELD(Field, kind_bits_offset) \
94 FIELD(Function, code_offset) \
95 RANGE(Function, entry_point_offset, CodeEntryKind, CodeEntryKind::kNormal, \
96 CodeEntryKind::kUnchecked, [](CodeEntryKind value) { return true; }) \
97 FIELD(FutureOr, type_arguments_offset) \
98 FIELD(GrowableObjectArray, data_offset) \
99 FIELD(GrowableObjectArray, length_offset) \
100 FIELD(GrowableObjectArray, type_arguments_offset) \
101 FIELD(OldPage, card_table_offset) \
102 FIELD(CallSiteData, arguments_descriptor_offset) \
103 FIELD(ICData, NumArgsTestedMask) \
104 FIELD(ICData, NumArgsTestedShift) \
105 FIELD(ICData, entries_offset) \
106 FIELD(ICData, owner_offset) \
107 FIELD(ICData, state_bits_offset) \
108 FIELD(Isolate, shared_class_table_offset) \
109 FIELD(Isolate, cached_class_table_table_offset) \
110 FIELD(Isolate, current_tag_offset) \
111 FIELD(Isolate, default_tag_offset) \
112 FIELD(Isolate, ic_miss_code_offset) \
113 FIELD(Isolate, cached_object_store_offset) \
114 NOT_IN_PRODUCT(FIELD(Isolate, single_step_offset)) \
115 FIELD(Isolate, user_tag_offset) \
116 FIELD(LinkedHashMap, data_offset) \
117 FIELD(LinkedHashMap, deleted_keys_offset) \
118 FIELD(LinkedHashMap, hash_mask_offset) \
119 FIELD(LinkedHashMap, index_offset) \
120 FIELD(LinkedHashMap, type_arguments_offset) \
121 FIELD(LinkedHashMap, used_data_offset) \
122 FIELD(LocalHandle, raw_offset) \
123 FIELD(MarkingStackBlock, pointers_offset) \
124 FIELD(MarkingStackBlock, top_offset) \
125 FIELD(MegamorphicCache, buckets_offset) \
126 FIELD(MegamorphicCache, mask_offset) \
127 FIELD(Mint, value_offset) \
128 FIELD(NativeArguments, argc_tag_offset) \
129 FIELD(NativeArguments, argv_offset) \
130 FIELD(NativeArguments, retval_offset) \
131 FIELD(NativeArguments, thread_offset) \
132 FIELD(ObjectStore, double_type_offset) \
133 FIELD(ObjectStore, int_type_offset) \
134 FIELD(ObjectStore, string_type_offset) \
135 FIELD(OneByteString, data_offset) \
136 FIELD(PointerBase, data_field_offset) \
137 FIELD(Pointer, type_arguments_offset) \
138 FIELD(SingleTargetCache, entry_point_offset) \
139 FIELD(SingleTargetCache, lower_limit_offset) \
140 FIELD(SingleTargetCache, target_offset) \
141 FIELD(SingleTargetCache, upper_limit_offset) \
142 FIELD(StoreBufferBlock, pointers_offset) \
143 FIELD(StoreBufferBlock, top_offset) \
144 FIELD(String, hash_offset) \
145 FIELD(String, length_offset) \
146 FIELD(SubtypeTestCache, cache_offset) \
147 FIELD(Thread, AllocateArray_entry_point_offset) \
148 FIELD(Thread, active_exception_offset) \
149 FIELD(Thread, active_stacktrace_offset) \
150 FIELD(Thread, array_write_barrier_code_offset) \
151 FIELD(Thread, array_write_barrier_entry_point_offset) \
152 FIELD(Thread, allocate_mint_with_fpu_regs_entry_point_offset) \
153 FIELD(Thread, allocate_mint_with_fpu_regs_stub_offset) \
154 FIELD(Thread, allocate_mint_without_fpu_regs_entry_point_offset) \
155 FIELD(Thread, allocate_mint_without_fpu_regs_stub_offset) \
156 FIELD(Thread, allocate_object_entry_point_offset) \
157 FIELD(Thread, allocate_object_stub_offset) \
158 FIELD(Thread, allocate_object_parameterized_entry_point_offset) \
159 FIELD(Thread, allocate_object_parameterized_stub_offset) \
160 FIELD(Thread, allocate_object_slow_entry_point_offset) \
161 FIELD(Thread, allocate_object_slow_stub_offset) \
162 FIELD(Thread, api_top_scope_offset) \
163 FIELD(Thread, async_stack_trace_offset) \
164 FIELD(Thread, auto_scope_native_wrapper_entry_point_offset) \
165 FIELD(Thread, bool_false_offset) \
166 FIELD(Thread, bool_true_offset) \
167 FIELD(Thread, bootstrap_native_wrapper_entry_point_offset) \
168 FIELD(Thread, call_to_runtime_entry_point_offset) \
169 FIELD(Thread, call_to_runtime_stub_offset) \
170 FIELD(Thread, dart_stream_offset) \
171 FIELD(Thread, dispatch_table_array_offset) \
172 FIELD(Thread, optimize_entry_offset) \
173 FIELD(Thread, optimize_stub_offset) \
174 FIELD(Thread, deoptimize_entry_offset) \
175 FIELD(Thread, deoptimize_stub_offset) \
176 FIELD(Thread, double_abs_address_offset) \
177 FIELD(Thread, double_negate_address_offset) \
178 FIELD(Thread, end_offset) \
179 FIELD(Thread, enter_safepoint_stub_offset) \
180 FIELD(Thread, execution_state_offset) \
181 FIELD(Thread, exit_safepoint_stub_offset) \
182 FIELD(Thread, call_native_through_safepoint_stub_offset) \
183 FIELD(Thread, call_native_through_safepoint_entry_point_offset) \
184 FIELD(Thread, fix_allocation_stub_code_offset) \
185 FIELD(Thread, fix_callers_target_code_offset) \
186 FIELD(Thread, float_absolute_address_offset) \
187 FIELD(Thread, float_negate_address_offset) \
188 FIELD(Thread, float_not_address_offset) \
189 FIELD(Thread, float_zerow_address_offset) \
190 FIELD(Thread, global_object_pool_offset) \
191 FIELD(Thread, interpret_call_entry_point_offset) \
192 FIELD(Thread, invoke_dart_code_from_bytecode_stub_offset) \
193 FIELD(Thread, invoke_dart_code_stub_offset) \
194 FIELD(Thread, exit_through_ffi_offset) \
195 FIELD(Thread, isolate_offset) \
196 FIELD(Thread, field_table_values_offset) \
197 FIELD(Thread, lazy_deopt_from_return_stub_offset) \
198 FIELD(Thread, lazy_deopt_from_throw_stub_offset) \
199 FIELD(Thread, lazy_specialize_type_test_stub_offset) \
200 FIELD(Thread, marking_stack_block_offset) \
201 FIELD(Thread, megamorphic_call_checked_entry_offset) \
202 FIELD(Thread, switchable_call_miss_entry_offset) \
203 FIELD(Thread, switchable_call_miss_stub_offset) \
204 FIELD(Thread, no_scope_native_wrapper_entry_point_offset) \
205 FIELD(Thread, null_error_shared_with_fpu_regs_stub_offset) \
206 FIELD(Thread, null_error_shared_without_fpu_regs_stub_offset) \
207 FIELD(Thread, null_arg_error_shared_with_fpu_regs_stub_offset) \
208 FIELD(Thread, null_arg_error_shared_without_fpu_regs_stub_offset) \
209 FIELD(Thread, null_cast_error_shared_with_fpu_regs_stub_offset) \
210 FIELD(Thread, null_cast_error_shared_without_fpu_regs_stub_offset) \
211 FIELD(Thread, range_error_shared_with_fpu_regs_stub_offset) \
212 FIELD(Thread, range_error_shared_without_fpu_regs_stub_offset) \
213 \
214 FIELD(Thread, object_null_offset) \
215 FIELD(Thread, predefined_symbols_address_offset) \
216 FIELD(Thread, resume_pc_offset) \
217 FIELD(Thread, saved_shadow_call_stack_offset) \
218 FIELD(Thread, safepoint_state_offset) \
219 FIELD(Thread, slow_type_test_stub_offset) \
220 FIELD(Thread, slow_type_test_entry_point_offset) \
221 FIELD(Thread, stack_limit_offset) \
222 FIELD(Thread, saved_stack_limit_offset) \
223 FIELD(Thread, stack_overflow_flags_offset) \
224 FIELD(Thread, stack_overflow_shared_with_fpu_regs_entry_point_offset) \
225 FIELD(Thread, stack_overflow_shared_with_fpu_regs_stub_offset) \
226 FIELD(Thread, stack_overflow_shared_without_fpu_regs_entry_point_offset) \
227 \
228 FIELD(Thread, stack_overflow_shared_without_fpu_regs_stub_offset) \
229 FIELD(Thread, store_buffer_block_offset) \
230 FIELD(Thread, top_exit_frame_info_offset) \
231 FIELD(Thread, top_offset) \
232 FIELD(Thread, top_resource_offset) \
233 FIELD(Thread, unboxed_int64_runtime_arg_offset) \
234 FIELD(Thread, vm_tag_offset) \
235 FIELD(Thread, write_barrier_code_offset) \
236 FIELD(Thread, write_barrier_entry_point_offset) \
237 FIELD(Thread, write_barrier_mask_offset) \
238 FIELD(Thread, callback_code_offset) \
239 FIELD(TimelineStream, enabled_offset) \
240 FIELD(TwoByteString, data_offset) \
241 FIELD(Type, arguments_offset) \
242 FIELD(Type, hash_offset) \
243 FIELD(Type, signature_offset) \
244 FIELD(Type, type_class_id_offset) \
245 FIELD(Type, type_state_offset) \
246 FIELD(Type, nullability_offset) \
247 FIELD(TypeArguments, instantiations_offset) \
248 FIELD(TypeArguments, nullability_offset) \
249 FIELD(TypeRef, type_offset) \
250 FIELD(TypedDataBase, length_offset) \
251 FIELD(TypedDataView, data_offset) \
252 FIELD(TypedDataView, offset_in_bytes_offset) \
253 FIELD(TypedData, data_offset) \
254 FIELD(UnhandledException, exception_offset) \
255 FIELD(UnhandledException, stacktrace_offset) \
256 FIELD(UserTag, tag_offset) \
257 FIELD(MonomorphicSmiableCall, expected_cid_offset) \
258 FIELD(MonomorphicSmiableCall, entrypoint_offset) \
259 FIELD(MonomorphicSmiableCall, target_offset) \
260 ARRAY(Array, element_offset) \
261 ARRAY(TypeArguments, type_at_offset) \
262 NOT_IN_PRODUCT(ARRAY(ClassTable, ClassOffsetFor)) \
263 RANGE(Code, entry_point_offset, CodeEntryKind, CodeEntryKind::kNormal, \
264 CodeEntryKind::kMonomorphicUnchecked, \
265 [](CodeEntryKind value) { return true; }) \
266 ONLY_IN_ARM_ARM64_X64(RANGE( \
267 Thread, write_barrier_wrappers_thread_offset, Register, 0, \
268 kNumberOfCpuRegisters - 1, \
269 [](Register reg) { return (kDartAvailableCpuRegs & (1 << reg)) != 0; })) \
270 \
271 SIZEOF(ApiError, InstanceSize, ApiErrorLayout) \
272 SIZEOF(Array, InstanceSize, ArrayLayout) \
273 SIZEOF(Array, header_size, ArrayLayout) \
274 SIZEOF(Bool, InstanceSize, BoolLayout) \
275 SIZEOF(Bytecode, InstanceSize, BytecodeLayout) \
276 SIZEOF(Capability, InstanceSize, CapabilityLayout) \
277 SIZEOF(Class, InstanceSize, ClassLayout) \
278 SIZEOF(Closure, InstanceSize, ClosureLayout) \
279 SIZEOF(ClosureData, InstanceSize, ClosureDataLayout) \
280 SIZEOF(Code, InstanceSize, CodeLayout) \
281 SIZEOF(CodeSourceMap, InstanceSize, CodeSourceMapLayout) \
282 SIZEOF(CompressedStackMaps, InstanceSize, CompressedStackMapsLayout) \
283 SIZEOF(CompressedStackMaps, HeaderSize, CompressedStackMapsLayout) \
284 SIZEOF(Context, InstanceSize, ContextLayout) \
285 SIZEOF(Context, header_size, ContextLayout) \
286 SIZEOF(ContextScope, InstanceSize, ContextScopeLayout) \
287 SIZEOF(Double, InstanceSize, DoubleLayout) \
288 SIZEOF(DynamicLibrary, InstanceSize, DynamicLibraryLayout) \
289 SIZEOF(ExceptionHandlers, InstanceSize, ExceptionHandlersLayout) \
290 SIZEOF(ExternalOneByteString, InstanceSize, ExternalOneByteStringLayout) \
291 SIZEOF(ExternalTwoByteString, InstanceSize, ExternalTwoByteStringLayout) \
292 SIZEOF(ExternalTypedData, InstanceSize, ExternalTypedDataLayout) \
293 SIZEOF(FfiTrampolineData, InstanceSize, FfiTrampolineDataLayout) \
294 SIZEOF(Field, InstanceSize, FieldLayout) \
295 SIZEOF(Float32x4, InstanceSize, Float32x4Layout) \
296 SIZEOF(Float64x2, InstanceSize, Float64x2Layout) \
297 SIZEOF(Function, InstanceSize, FunctionLayout) \
298 SIZEOF(FutureOr, InstanceSize, FutureOrLayout) \
299 SIZEOF(GrowableObjectArray, InstanceSize, GrowableObjectArrayLayout) \
300 SIZEOF(ICData, InstanceSize, ICDataLayout) \
301 SIZEOF(Instance, InstanceSize, InstanceLayout) \
302 SIZEOF(Instructions, InstanceSize, InstructionsLayout) \
303 SIZEOF(Instructions, UnalignedHeaderSize, InstructionsLayout) \
304 SIZEOF(InstructionsSection, InstanceSize, InstructionsSectionLayout) \
305 SIZEOF(InstructionsSection, UnalignedHeaderSize, InstructionsSectionLayout) \
306 SIZEOF(Int32x4, InstanceSize, Int32x4Layout) \
307 SIZEOF(Integer, InstanceSize, IntegerLayout) \
308 SIZEOF(KernelProgramInfo, InstanceSize, KernelProgramInfoLayout) \
309 SIZEOF(LanguageError, InstanceSize, LanguageErrorLayout) \
310 SIZEOF(Library, InstanceSize, LibraryLayout) \
311 SIZEOF(LibraryPrefix, InstanceSize, LibraryPrefixLayout) \
312 SIZEOF(LinkedHashMap, InstanceSize, LinkedHashMapLayout) \
313 SIZEOF(LocalVarDescriptors, InstanceSize, LocalVarDescriptorsLayout) \
314 SIZEOF(MegamorphicCache, InstanceSize, MegamorphicCacheLayout) \
315 SIZEOF(Mint, InstanceSize, MintLayout) \
316 SIZEOF(MirrorReference, InstanceSize, MirrorReferenceLayout) \
317 SIZEOF(MonomorphicSmiableCall, InstanceSize, MonomorphicSmiableCallLayout) \
318 SIZEOF(Namespace, InstanceSize, NamespaceLayout) \
319 SIZEOF(NativeArguments, StructSize, NativeArguments) \
320 SIZEOF(Number, InstanceSize, NumberLayout) \
321 SIZEOF(Object, InstanceSize, ObjectLayout) \
322 SIZEOF(ObjectPool, InstanceSize, ObjectPoolLayout) \
323 SIZEOF(OneByteString, InstanceSize, OneByteStringLayout) \
324 SIZEOF(ParameterTypeCheck, InstanceSize, ParameterTypeCheckLayout) \
325 SIZEOF(PatchClass, InstanceSize, PatchClassLayout) \
326 SIZEOF(PcDescriptors, InstanceSize, PcDescriptorsLayout) \
327 SIZEOF(Pointer, InstanceSize, PointerLayout) \
328 SIZEOF(ReceivePort, InstanceSize, ReceivePortLayout) \
329 SIZEOF(RedirectionData, InstanceSize, RedirectionDataLayout) \
330 SIZEOF(RegExp, InstanceSize, RegExpLayout) \
331 SIZEOF(Script, InstanceSize, ScriptLayout) \
332 SIZEOF(SendPort, InstanceSize, SendPortLayout) \
333 SIZEOF(SignatureData, InstanceSize, SignatureDataLayout) \
334 SIZEOF(SingleTargetCache, InstanceSize, SingleTargetCacheLayout) \
335 SIZEOF(Smi, InstanceSize, SmiLayout) \
336 SIZEOF(StackTrace, InstanceSize, StackTraceLayout) \
337 SIZEOF(String, InstanceSize, StringLayout) \
338 SIZEOF(SubtypeTestCache, InstanceSize, SubtypeTestCacheLayout) \
339 SIZEOF(LoadingUnit, InstanceSize, LoadingUnitLayout) \
340 SIZEOF(TransferableTypedData, InstanceSize, TransferableTypedDataLayout) \
341 SIZEOF(TwoByteString, InstanceSize, TwoByteStringLayout) \
342 SIZEOF(Type, InstanceSize, TypeLayout) \
343 SIZEOF(TypeArguments, InstanceSize, TypeArgumentsLayout) \
344 SIZEOF(TypeParameter, InstanceSize, TypeParameterLayout) \
345 SIZEOF(TypeRef, InstanceSize, TypeRefLayout) \
346 SIZEOF(TypedData, InstanceSize, TypedDataLayout) \
347 SIZEOF(TypedDataBase, InstanceSize, TypedDataBaseLayout) \
348 SIZEOF(TypedDataView, InstanceSize, TypedDataViewLayout) \
349 SIZEOF(UnhandledException, InstanceSize, UnhandledExceptionLayout) \
350 SIZEOF(UnlinkedCall, InstanceSize, UnlinkedCallLayout) \
351 SIZEOF(UnwindError, InstanceSize, UnwindErrorLayout) \
352 SIZEOF(UserTag, InstanceSize, UserTagLayout) \
353 SIZEOF(WeakProperty, InstanceSize, WeakPropertyLayout) \
354 SIZEOF(WeakSerializationReference, InstanceSize, \
355 WeakSerializationReferenceLayout)
356
357#define JIT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, RANGE, CONSTANT) \
358 FIELD(Function, usage_counter_offset) \
359 FIELD(ICData, receivers_static_type_offset)
360
361#endif // RUNTIME_VM_COMPILER_RUNTIME_OFFSETS_LIST_H_
362