Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
object_store.h
Go to the documentation of this file.
1// Copyright (c) 2012, 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_OBJECT_STORE_H_
6#define RUNTIME_VM_OBJECT_STORE_H_
7
8#include "vm/object.h"
9
10namespace dart {
11
12// Forward declarations.
13class Isolate;
14class ObjectPointerVisitor;
15
16// A list of the bootstrap libraries including CamelName and name.
17//
18// These are listed in the order that they are compiled (see vm/bootstrap.cc).
19#define FOR_EACH_BOOTSTRAP_LIBRARY(M) \
20 M(Core, core) \
21 M(Async, async) \
22 M(Collection, collection) \
23 M(Convert, convert) \
24 M(Developer, developer) \
25 M(Ffi, ffi) \
26 M(Internal, _internal) \
27 M(Isolate, isolate) \
28 M(Math, math) \
29 M(Mirrors, mirrors) \
30 M(TypedData, typed_data) \
31 M(VMService, _vmservice)
32
33// TODO(liama): Once NNBD is enabled, *_type will be deleted and all uses will
34// be replaced with *_type_non_nullable. Later, once we drop support for opted
35// out code, *_type_legacy will be deleted.
36//
37// R_ - needs getter only
38// RW - needs getter and setter
39// ARW_RELAXED - needs getter and setter with relaxed atomic access
40// ARW_AR - needs getter and setter with acq/rel atomic access
41// LAZY_CORE - needs lazy init getter for a "dart:core" member
42// LAZY_ASYNC - needs lazy init getter for a "dart:async" member
43// LAZY_ISOLATE - needs lazy init getter for a "dart:isolate" member
44// LAZY_INTERNAL - needs lazy init getter for a "dart:_internal" member
45#define OBJECT_STORE_FIELD_LIST(R_, RW, ARW_RELAXED, ARW_AR, LAZY_CORE, \
46 LAZY_ASYNC, LAZY_ISOLATE, LAZY_INTERNAL, \
47 LAZY_FFI) \
48 LAZY_CORE(Class, list_class) \
49 LAZY_CORE(Class, map_class) \
50 LAZY_CORE(Class, set_class) \
51 LAZY_CORE(Type, non_nullable_list_rare_type) \
52 LAZY_CORE(Type, non_nullable_map_rare_type) \
53 LAZY_CORE(Field, enum_index_field) \
54 LAZY_CORE(Field, enum_name_field) \
55 LAZY_CORE(Function, _object_equals_function) \
56 LAZY_CORE(Function, _object_hash_code_function) \
57 LAZY_CORE(Function, _object_to_string_function) \
58 LAZY_INTERNAL(Class, symbol_class) \
59 LAZY_INTERNAL(Field, symbol_name_field) \
60 LAZY_FFI(Class, varargs_class) \
61 LAZY_FFI(Function, ffi_resolver_function) \
62 LAZY_FFI(Function, handle_finalizer_message_function) \
63 LAZY_FFI(Function, handle_native_finalizer_message_function) \
64 LAZY_ASYNC(Type, non_nullable_future_never_type) \
65 LAZY_ASYNC(Type, nullable_future_null_type) \
66 LAZY_ISOLATE(Class, send_port_class) \
67 LAZY_ISOLATE(Class, capability_class) \
68 LAZY_ISOLATE(Class, transferable_class) \
69 LAZY_ISOLATE(Function, lookup_port_handler) \
70 LAZY_ISOLATE(Function, lookup_open_ports) \
71 LAZY_ISOLATE(Function, handle_message_function) \
72 RW(Class, object_class) \
73 RW(Type, object_type) \
74 RW(Type, legacy_object_type) \
75 RW(Type, non_nullable_object_type) \
76 RW(Type, nullable_object_type) \
77 RW(Class, null_class) \
78 RW(Type, null_type) \
79 RW(Class, never_class) \
80 RW(Type, never_type) \
81 RW(Type, function_type) \
82 RW(Type, type_type) \
83 RW(Class, closure_class) \
84 RW(Class, record_class) \
85 RW(Type, number_type) \
86 RW(Type, nullable_number_type) \
87 RW(Type, int_type) \
88 RW(Type, legacy_int_type) \
89 RW(Type, non_nullable_int_type) \
90 RW(Type, nullable_int_type) \
91 RW(Class, integer_implementation_class) \
92 RW(Type, int64_type) \
93 RW(Class, smi_class) \
94 RW(Type, smi_type) \
95 RW(Class, mint_class) \
96 RW(Type, mint_type) \
97 RW(Class, double_class) \
98 RW(Type, double_type) \
99 RW(Type, nullable_double_type) \
100 RW(Type, float32x4_type) \
101 RW(Type, int32x4_type) \
102 RW(Type, float64x2_type) \
103 RW(Type, string_type) \
104 RW(Type, legacy_string_type) \
105 RW(TypeArguments, type_argument_int) \
106 RW(TypeArguments, type_argument_legacy_int) \
107 RW(TypeArguments, type_argument_double) \
108 RW(TypeArguments, type_argument_never) \
109 RW(TypeArguments, type_argument_string) \
110 RW(TypeArguments, type_argument_legacy_string) \
111 RW(TypeArguments, type_argument_string_dynamic) \
112 RW(TypeArguments, type_argument_string_string) \
113 RW(Class, compiletime_error_class) \
114 RW(Class, pragma_class) \
115 RW(Field, pragma_name) \
116 RW(Field, pragma_options) \
117 RW(Class, future_class) \
118 RW(Class, future_or_class) \
119 RW(Class, one_byte_string_class) \
120 RW(Class, two_byte_string_class) \
121 RW(Type, bool_type) \
122 RW(Class, bool_class) \
123 RW(Class, array_class) \
124 RW(Type, array_type) \
125 RW(Class, immutable_array_class) \
126 RW(Class, growable_object_array_class) \
127 RW(Class, map_impl_class) \
128 RW(Class, const_map_impl_class) \
129 RW(Class, set_impl_class) \
130 RW(Class, const_set_impl_class) \
131 RW(Class, float32x4_class) \
132 RW(Class, int32x4_class) \
133 RW(Class, float64x2_class) \
134 RW(Class, error_class) \
135 RW(Class, expando_class) \
136 RW(Class, iterable_class) \
137 RW(Class, weak_property_class) \
138 RW(Class, weak_reference_class) \
139 RW(Class, finalizer_class) \
140 RW(Class, finalizer_entry_class) \
141 RW(Class, native_finalizer_class) \
142 ARW_AR(WeakArray, symbol_table) \
143 ARW_AR(WeakArray, regexp_table) \
144 RW(Array, canonical_types) \
145 RW(Array, canonical_function_types) \
146 RW(Array, canonical_record_types) \
147 RW(Array, canonical_type_parameters) \
148 RW(Array, canonical_type_arguments) \
149 RW(Library, async_library) \
150 RW(Library, core_library) \
151 RW(Library, collection_library) \
152 RW(Library, convert_library) \
153 RW(Library, developer_library) \
154 RW(Library, ffi_library) \
155 RW(Library, _internal_library) \
156 RW(Library, isolate_library) \
157 RW(Library, math_library) \
158 RW(Library, mirrors_library) \
159 RW(Library, native_wrappers_library) \
160 RW(Library, root_library) \
161 RW(Library, typed_data_library) \
162 RW(Library, _vmservice_library) \
163 RW(Library, native_assets_library) \
164 RW(Array, native_assets_map) \
165 RW(GrowableObjectArray, libraries) \
166 RW(Array, libraries_map) \
167 RW(Array, uri_to_resolved_uri_map) \
168 RW(Array, resolved_uri_to_uri_map) \
169 RW(Smi, last_libraries_count) \
170 RW(Array, loading_units) \
171 RW(GrowableObjectArray, closure_functions) \
172 RW(Array, closure_functions_table) \
173 RW(GrowableObjectArray, pending_classes) \
174 RW(Array, record_field_names_map) \
175 ARW_RELAXED(Array, record_field_names) \
176 RW(Instance, stack_overflow) \
177 RW(Instance, out_of_memory) \
178 RW(Function, growable_list_factory) \
179 RW(Function, simple_instance_of_function) \
180 RW(Function, simple_instance_of_true_function) \
181 RW(Function, simple_instance_of_false_function) \
182 RW(Function, async_star_stream_controller_add) \
183 RW(Function, async_star_stream_controller_add_stream) \
184 RW(Function, suspend_state_init_async) \
185 RW(Function, suspend_state_await) \
186 RW(Function, suspend_state_await_with_type_check) \
187 RW(Function, suspend_state_return_async) \
188 RW(Function, suspend_state_return_async_not_future) \
189 RW(Function, suspend_state_init_async_star) \
190 RW(Function, suspend_state_yield_async_star) \
191 RW(Function, suspend_state_return_async_star) \
192 RW(Function, suspend_state_init_sync_star) \
193 RW(Function, suspend_state_suspend_sync_star_at_start) \
194 RW(Function, suspend_state_handle_exception) \
195 RW(Class, async_star_stream_controller) \
196 RW(Class, stream_class) \
197 RW(Class, sync_star_iterator_class) \
198 RW(Field, async_star_stream_controller_async_star_body) \
199 RW(Field, sync_star_iterator_current) \
200 RW(Field, sync_star_iterator_state) \
201 RW(Field, sync_star_iterator_yield_star_iterable) \
202 RW(CompressedStackMaps, canonicalized_stack_map_entries) \
203 RW(ObjectPool, global_object_pool) \
204 RW(Array, unique_dynamic_targets) \
205 RW(GrowableObjectArray, megamorphic_cache_table) \
206 RW(GrowableObjectArray, ffi_callback_code) \
207 RW(Code, dispatch_table_null_error_stub) \
208 RW(Code, late_initialization_error_stub_with_fpu_regs_stub) \
209 RW(Code, late_initialization_error_stub_without_fpu_regs_stub) \
210 RW(Code, null_error_stub_with_fpu_regs_stub) \
211 RW(Code, null_error_stub_without_fpu_regs_stub) \
212 RW(Code, null_arg_error_stub_with_fpu_regs_stub) \
213 RW(Code, null_arg_error_stub_without_fpu_regs_stub) \
214 RW(Code, null_cast_error_stub_with_fpu_regs_stub) \
215 RW(Code, null_cast_error_stub_without_fpu_regs_stub) \
216 RW(Code, range_error_stub_with_fpu_regs_stub) \
217 RW(Code, range_error_stub_without_fpu_regs_stub) \
218 RW(Code, write_error_stub_with_fpu_regs_stub) \
219 RW(Code, write_error_stub_without_fpu_regs_stub) \
220 RW(Code, allocate_mint_with_fpu_regs_stub) \
221 RW(Code, allocate_mint_without_fpu_regs_stub) \
222 RW(Code, stack_overflow_stub_with_fpu_regs_stub) \
223 RW(Code, stack_overflow_stub_without_fpu_regs_stub) \
224 RW(Code, allocate_array_stub) \
225 RW(Code, allocate_mint_stub) \
226 RW(Code, allocate_double_stub) \
227 RW(Code, allocate_float32x4_stub) \
228 RW(Code, allocate_float64x2_stub) \
229 RW(Code, allocate_int32x4_stub) \
230 RW(Code, allocate_int8_array_stub) \
231 RW(Code, allocate_uint8_array_stub) \
232 RW(Code, allocate_uint8_clamped_array_stub) \
233 RW(Code, allocate_int16_array_stub) \
234 RW(Code, allocate_uint16_array_stub) \
235 RW(Code, allocate_int32_array_stub) \
236 RW(Code, allocate_uint32_array_stub) \
237 RW(Code, allocate_int64_array_stub) \
238 RW(Code, allocate_uint64_array_stub) \
239 RW(Code, allocate_float32_array_stub) \
240 RW(Code, allocate_float64_array_stub) \
241 RW(Code, allocate_float32x4_array_stub) \
242 RW(Code, allocate_int32x4_array_stub) \
243 RW(Code, allocate_float64x2_array_stub) \
244 RW(Code, allocate_closure_stub) \
245 RW(Code, allocate_closure_generic_stub) \
246 RW(Code, allocate_closure_ta_stub) \
247 RW(Code, allocate_closure_ta_generic_stub) \
248 RW(Code, allocate_context_stub) \
249 RW(Code, allocate_growable_array_stub) \
250 RW(Code, allocate_object_stub) \
251 RW(Code, allocate_object_parametrized_stub) \
252 RW(Code, allocate_record_stub) \
253 RW(Code, allocate_record2_stub) \
254 RW(Code, allocate_record2_named_stub) \
255 RW(Code, allocate_record3_stub) \
256 RW(Code, allocate_record3_named_stub) \
257 RW(Code, allocate_unhandled_exception_stub) \
258 RW(Code, clone_context_stub) \
259 RW(Code, write_barrier_wrappers_stub) \
260 RW(Code, array_write_barrier_stub) \
261 RW(Code, throw_stub) \
262 RW(Code, re_throw_stub) \
263 RW(Code, assert_boolean_stub) \
264 RW(Code, instance_of_stub) \
265 RW(Code, init_static_field_stub) \
266 RW(Code, init_late_static_field_stub) \
267 RW(Code, init_late_final_static_field_stub) \
268 RW(Code, init_instance_field_stub) \
269 RW(Code, init_late_instance_field_stub) \
270 RW(Code, init_late_final_instance_field_stub) \
271 RW(Code, call_closure_no_such_method_stub) \
272 RW(Code, default_tts_stub) \
273 RW(Code, default_nullable_tts_stub) \
274 RW(Code, top_type_tts_stub) \
275 RW(Code, nullable_type_parameter_tts_stub) \
276 RW(Code, type_parameter_tts_stub) \
277 RW(Code, unreachable_tts_stub) \
278 RW(Array, ffi_callback_functions) \
279 RW(Code, slow_tts_stub) \
280 /* Roots for JIT/AOT snapshots are up until here (see to_snapshot() below)*/ \
281 RW(Code, await_stub) \
282 RW(Code, await_with_type_check_stub) \
283 RW(Code, clone_suspend_state_stub) \
284 RW(Code, ffi_async_callback_send_stub) \
285 RW(Code, init_async_stub) \
286 RW(Code, resume_stub) \
287 RW(Code, return_async_stub) \
288 RW(Code, return_async_not_future_stub) \
289 RW(Code, init_async_star_stub) \
290 RW(Code, yield_async_star_stub) \
291 RW(Code, return_async_star_stub) \
292 RW(Code, init_sync_star_stub) \
293 RW(Code, suspend_sync_star_at_start_stub) \
294 RW(Code, suspend_sync_star_at_yield_stub) \
295 RW(Array, dispatch_table_code_entries) \
296 RW(GrowableObjectArray, instructions_tables) \
297 RW(Array, obfuscation_map) \
298 RW(Array, loading_unit_uris) \
299 RW(Class, ffi_pointer_class) \
300 RW(Class, ffi_native_type_class) \
301 // Please remember the last entry must be referred in the 'to' function below.
302
303#define OBJECT_STORE_STUB_CODE_LIST(DO) \
304 DO(dispatch_table_null_error_stub, DispatchTableNullError) \
305 DO(late_initialization_error_stub_with_fpu_regs_stub, \
306 LateInitializationErrorSharedWithFPURegs) \
307 DO(late_initialization_error_stub_without_fpu_regs_stub, \
308 LateInitializationErrorSharedWithoutFPURegs) \
309 DO(null_error_stub_with_fpu_regs_stub, NullErrorSharedWithFPURegs) \
310 DO(null_error_stub_without_fpu_regs_stub, NullErrorSharedWithoutFPURegs) \
311 DO(null_arg_error_stub_with_fpu_regs_stub, NullArgErrorSharedWithFPURegs) \
312 DO(null_arg_error_stub_without_fpu_regs_stub, \
313 NullArgErrorSharedWithoutFPURegs) \
314 DO(null_cast_error_stub_with_fpu_regs_stub, NullCastErrorSharedWithFPURegs) \
315 DO(null_cast_error_stub_without_fpu_regs_stub, \
316 NullCastErrorSharedWithoutFPURegs) \
317 DO(range_error_stub_with_fpu_regs_stub, RangeErrorSharedWithFPURegs) \
318 DO(range_error_stub_without_fpu_regs_stub, RangeErrorSharedWithoutFPURegs) \
319 DO(write_error_stub_with_fpu_regs_stub, WriteErrorSharedWithFPURegs) \
320 DO(write_error_stub_without_fpu_regs_stub, WriteErrorSharedWithoutFPURegs) \
321 DO(allocate_mint_with_fpu_regs_stub, AllocateMintSharedWithFPURegs) \
322 DO(allocate_mint_without_fpu_regs_stub, AllocateMintSharedWithoutFPURegs) \
323 DO(stack_overflow_stub_with_fpu_regs_stub, StackOverflowSharedWithFPURegs) \
324 DO(stack_overflow_stub_without_fpu_regs_stub, \
325 StackOverflowSharedWithoutFPURegs) \
326 DO(allocate_array_stub, AllocateArray) \
327 DO(allocate_mint_stub, AllocateMint) \
328 DO(allocate_double_stub, AllocateDouble) \
329 DO(allocate_float32x4_stub, AllocateFloat32x4) \
330 DO(allocate_float64x2_stub, AllocateFloat64x2) \
331 DO(allocate_int32x4_stub, AllocateInt32x4) \
332 DO(allocate_int8_array_stub, AllocateInt8Array) \
333 DO(allocate_uint8_array_stub, AllocateUint8Array) \
334 DO(allocate_uint8_clamped_array_stub, AllocateUint8ClampedArray) \
335 DO(allocate_int16_array_stub, AllocateInt16Array) \
336 DO(allocate_uint16_array_stub, AllocateUint16Array) \
337 DO(allocate_int32_array_stub, AllocateInt32Array) \
338 DO(allocate_uint32_array_stub, AllocateUint32Array) \
339 DO(allocate_int64_array_stub, AllocateInt64Array) \
340 DO(allocate_uint64_array_stub, AllocateUint64Array) \
341 DO(allocate_float32_array_stub, AllocateFloat32Array) \
342 DO(allocate_float64_array_stub, AllocateFloat64Array) \
343 DO(allocate_float32x4_array_stub, AllocateFloat32x4Array) \
344 DO(allocate_int32x4_array_stub, AllocateInt32x4Array) \
345 DO(allocate_float64x2_array_stub, AllocateFloat64x2Array) \
346 DO(allocate_closure_stub, AllocateClosure) \
347 DO(allocate_closure_generic_stub, AllocateClosureGeneric) \
348 DO(allocate_closure_ta_stub, AllocateClosureTA) \
349 DO(allocate_closure_ta_generic_stub, AllocateClosureTAGeneric) \
350 DO(allocate_context_stub, AllocateContext) \
351 DO(allocate_growable_array_stub, AllocateGrowableArray) \
352 DO(allocate_object_stub, AllocateObject) \
353 DO(allocate_object_parametrized_stub, AllocateObjectParameterized) \
354 DO(allocate_record_stub, AllocateRecord) \
355 DO(allocate_record2_stub, AllocateRecord2) \
356 DO(allocate_record2_named_stub, AllocateRecord2Named) \
357 DO(allocate_record3_stub, AllocateRecord3) \
358 DO(allocate_record3_named_stub, AllocateRecord3Named) \
359 DO(allocate_unhandled_exception_stub, AllocateUnhandledException) \
360 DO(clone_context_stub, CloneContext) \
361 DO(call_closure_no_such_method_stub, CallClosureNoSuchMethod) \
362 DO(default_tts_stub, DefaultTypeTest) \
363 DO(default_nullable_tts_stub, DefaultNullableTypeTest) \
364 DO(top_type_tts_stub, TopTypeTypeTest) \
365 DO(nullable_type_parameter_tts_stub, NullableTypeParameterTypeTest) \
366 DO(type_parameter_tts_stub, TypeParameterTypeTest) \
367 DO(unreachable_tts_stub, UnreachableTypeTest) \
368 DO(slow_tts_stub, SlowTypeTest) \
369 DO(write_barrier_wrappers_stub, WriteBarrierWrappers) \
370 DO(array_write_barrier_stub, ArrayWriteBarrier) \
371 DO(throw_stub, Throw) \
372 DO(re_throw_stub, ReThrow) \
373 DO(assert_boolean_stub, AssertBoolean) \
374 DO(init_static_field_stub, InitStaticField) \
375 DO(init_late_static_field_stub, InitLateStaticField) \
376 DO(init_late_final_static_field_stub, InitLateFinalStaticField) \
377 DO(init_instance_field_stub, InitInstanceField) \
378 DO(init_late_instance_field_stub, InitLateInstanceField) \
379 DO(init_late_final_instance_field_stub, InitLateFinalInstanceField) \
380 DO(await_stub, Await) \
381 DO(await_with_type_check_stub, AwaitWithTypeCheck) \
382 DO(clone_suspend_state_stub, CloneSuspendState) \
383 DO(ffi_async_callback_send_stub, FfiAsyncCallbackSend) \
384 DO(init_async_stub, InitAsync) \
385 DO(resume_stub, Resume) \
386 DO(return_async_stub, ReturnAsync) \
387 DO(return_async_not_future_stub, ReturnAsyncNotFuture) \
388 DO(init_async_star_stub, InitAsyncStar) \
389 DO(yield_async_star_stub, YieldAsyncStar) \
390 DO(return_async_star_stub, ReturnAsyncStar) \
391 DO(init_sync_star_stub, InitSyncStar) \
392 DO(suspend_sync_star_at_start_stub, SuspendSyncStarAtStart) \
393 DO(suspend_sync_star_at_yield_stub, SuspendSyncStarAtYield) \
394 DO(instance_of_stub, InstanceOf)
395
396#define ISOLATE_OBJECT_STORE_FIELD_LIST(R_, RW) \
397 RW(UnhandledException, preallocated_unhandled_exception) \
398 RW(StackTrace, preallocated_stack_trace) \
399 RW(UnwindError, preallocated_unwind_error) \
400 R_(Array, dart_args_1) \
401 R_(Array, dart_args_2) \
402 R_(GrowableObjectArray, resume_capabilities) \
403 R_(GrowableObjectArray, exit_listeners) \
404 R_(GrowableObjectArray, error_listeners)
405// Please remember the last entry must be referred in the 'to' function below.
406
408 public:
411
412#define DECLARE_GETTER(Type, name) \
413 Type##Ptr name() const { return name##_; } \
414 static intptr_t name##_offset() { \
415 return OFFSET_OF(IsolateObjectStore, name##_); \
416 }
417
418#define DECLARE_GETTER_AND_SETTER(Type, name) \
419 DECLARE_GETTER(Type, name) \
420 void set_##name(const Type& value) { name##_ = value.ptr(); }
422#undef DECLARE_GETTER
423#undef DECLARE_GETTER_AND_SETTER
424
425 // Visit all object pointers.
426 void VisitObjectPointers(ObjectPointerVisitor* visitor);
427
428 // Called to initialize objects required by the vm but which invoke
429 // dart code. If an error occurs the error object is returned otherwise
430 // a null object is returned.
431 ErrorPtr PreallocateObjects(const Object& out_of_memory);
432
433 void Init();
434 void PostLoad();
435
436#ifndef PRODUCT
437 void PrintToJSONObject(JSONObject* jsobj);
438#endif
439
440 private:
441 // Finds a core library private method in Object.
442 FunctionPtr PrivateObjectLookup(const String& name);
443
444 ObjectPtr* from() {
445 return reinterpret_cast<ObjectPtr*>(&preallocated_unhandled_exception_);
446 }
447#define DECLARE_OBJECT_STORE_FIELD(type, name) type##Ptr name##_;
450#undef DECLARE_OBJECT_STORE_FIELD
451 ObjectPtr* to() { return reinterpret_cast<ObjectPtr*>(&error_listeners_); }
452
453 friend class Serializer;
454 friend class Deserializer;
455
457};
458
459// The object store is a per isolate group instance which stores references to
460// objects used by the VM shared by all isolates in a group.
462 public:
464#define MAKE_ID(Name, _) k##Name,
465
467#undef MAKE_ID
468 };
469
470 ObjectStore();
471 ~ObjectStore();
472
473#define DECLARE_OFFSET(name) \
474 static intptr_t name##_offset() { return OFFSET_OF(ObjectStore, name##_); }
475#define DECLARE_GETTER(Type, name) \
476 Type##Ptr name() const { return name##_; } \
477 DECLARE_OFFSET(name)
478#define DECLARE_GETTER_AND_SETTER(Type, name) \
479 DECLARE_GETTER(Type, name) \
480 void set_##name(const Type& value) { name##_ = value.ptr(); }
481#define DECLARE_RELAXED_ATOMIC_GETTER_AND_SETTER(Type, name) \
482 template <std::memory_order order = std::memory_order_relaxed> \
483 Type##Ptr name() const { \
484 return name##_.load(order); \
485 } \
486 template <std::memory_order order = std::memory_order_relaxed> \
487 void set_##name(const Type& value) { \
488 name##_.store(value.ptr(), order); \
489 } \
490 DECLARE_OFFSET(name)
491#define DECLARE_ACQREL_ATOMIC_GETTER_AND_SETTER(Type, name) \
492 Type##Ptr name() const { return name##_.load(); } \
493 void set_##name(const Type& value) { name##_.store(value.ptr()); } \
494 DECLARE_OFFSET(name)
495#define DECLARE_LAZY_INIT_GETTER(Type, name, init) \
496 Type##Ptr name() { \
497 if (name##_.load() == Type::null()) { \
498 init(); \
499 } \
500 return name##_.load(); \
501 } \
502 DECLARE_OFFSET(name)
503#define DECLARE_LAZY_INIT_CORE_GETTER(Type, name) \
504 DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitCoreMembers)
505#define DECLARE_LAZY_INIT_ASYNC_GETTER(Type, name) \
506 DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitAsyncMembers)
507#define DECLARE_LAZY_INIT_ISOLATE_GETTER(Type, name) \
508 DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitIsolateMembers)
509#define DECLARE_LAZY_INIT_INTERNAL_GETTER(Type, name) \
510 DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitInternalMembers)
511#define DECLARE_LAZY_INIT_FFI_GETTER(Type, name) \
512 DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitFfiMembers)
522#undef DECLARE_OFFSET
523#undef DECLARE_GETTER
524#undef DECLARE_GETTER_AND_SETTER
525#undef DECLARE_RELAXED_ATOMIC_GETTER_AND_SETTER
526#undef DECLARE_ACQREL_ATOMIC_GETTER_AND_SETTER
527#undef DECLARE_LAZY_INIT_GETTER
528#undef DECLARE_LAZY_INIT_CORE_GETTER
529#undef DECLARE_LAZY_INIT_ASYNC_GETTER
530#undef DECLARE_LAZY_INIT_ISOLATE_GETTER
531#undef DECLARE_LAZY_INIT_INTERNAL_GETTER
532#undef DECLARE_LAZY_INIT_TYPED_DATA_GETTER
533
534 LibraryPtr bootstrap_library(BootstrapLibraryId index) {
535 switch (index) {
536#define MAKE_CASE(CamelName, name) \
537 case k##CamelName: \
538 return name##_library_;
539
541#undef MAKE_CASE
542
543 default:
544 UNREACHABLE();
545 return Library::null();
546 }
547 }
548
550 switch (index) {
551#define MAKE_CASE(CamelName, name) \
552 case k##CamelName: \
553 name##_library_ = value.ptr(); \
554 break;
555
557#undef MAKE_CASE
558 default:
559 UNREACHABLE();
560 }
561 }
562
563 // Visit all object pointers.
565
566 // Called to initialize objects required by the vm but which invoke
567 // dart code. If an error occurs the error object is returned otherwise
568 // a null object is returned.
569 ErrorPtr PreallocateObjects();
570
571 void InitKnownObjects();
572
573 void InitStubs();
574
575#ifndef PRODUCT
576 void PrintToJSONObject(JSONObject* jsobj);
577#endif
578
579 private:
580 void LazyInitCoreMembers();
581 void LazyInitAsyncMembers();
582 void LazyInitFfiMembers();
583 void LazyInitIsolateMembers();
584 void LazyInitInternalMembers();
585
586 // Finds a core library private method in Object.
587 FunctionPtr PrivateObjectLookup(const String& name);
588
589 ObjectPtr* from() { return reinterpret_cast<ObjectPtr*>(&list_class_); }
590#define DECLARE_OBJECT_STORE_FIELD(type, name) type##Ptr name##_;
591#define DECLARE_ATOMIC_OBJECT_STORE_FIELD(type, name) \
592 std::atomic<type##Ptr> name##_;
593#define DECLARE_LAZY_OBJECT_STORE_FIELD(type, name) \
594 AcqRelAtomic<type##Ptr> name##_;
604#undef DECLARE_OBJECT_STORE_FIELD
605#undef DECLARE_ATOMIC_OBJECT_STORE_FIELD
606#undef DECLARE_LAZY_OBJECT_STORE_FIELD
607 ObjectPtr* to() {
608 return reinterpret_cast<ObjectPtr*>(&ffi_native_type_class_);
609 }
610 ObjectPtr* to_snapshot(Snapshot::Kind kind) {
611 switch (kind) {
612 case Snapshot::kFull:
614 return reinterpret_cast<ObjectPtr*>(&global_object_pool_);
617 return reinterpret_cast<ObjectPtr*>(&slow_tts_stub_);
618 case Snapshot::kNone:
620 break;
621 }
622 UNREACHABLE();
623 return nullptr;
624 }
625 uword unused_field_;
626
629 friend class ProgramVisitor;
630
632};
633
634} // namespace dart
635
636#endif // RUNTIME_VM_OBJECT_STORE_H_
#define DECLARE_OBJECT_STORE_FIELD(Type, Name)
#define UNREACHABLE()
Definition assert.h:248
void PrintToJSONObject(JSONObject *jsobj)
ErrorPtr PreallocateObjects(const Object &out_of_memory)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
ErrorPtr PreallocateObjects()
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void PrintToJSONObject(JSONObject *jsobj)
void set_bootstrap_library(BootstrapLibraryId index, const Library &value)
OBJECT_STORE_FIELD_LIST(DECLARE_GETTER, DECLARE_GETTER_AND_SETTER, DECLARE_RELAXED_ATOMIC_GETTER_AND_SETTER, DECLARE_ACQREL_ATOMIC_GETTER_AND_SETTER, DECLARE_LAZY_INIT_CORE_GETTER, DECLARE_LAZY_INIT_ASYNC_GETTER, DECLARE_LAZY_INIT_ISOLATE_GETTER, DECLARE_LAZY_INIT_INTERNAL_GETTER, DECLARE_LAZY_INIT_FFI_GETTER) LibraryPtr bootstrap_library(BootstrapLibraryId index)
static ObjectPtr null()
Definition object.h:433
#define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name)
Definition isolate.h:433
const char *const name
uintptr_t uword
Definition globals.h:501
#define MAKE_ID(Name, _)
#define DECLARE_ATOMIC_OBJECT_STORE_FIELD(type, name)
#define OBJECT_STORE_FIELD_LIST(R_, RW, ARW_RELAXED, ARW_AR, LAZY_CORE, LAZY_ASYNC, LAZY_ISOLATE, LAZY_INTERNAL, LAZY_FFI)
#define DECLARE_LAZY_INIT_CORE_GETTER(Type, name)
#define FOR_EACH_BOOTSTRAP_LIBRARY(M)
#define DECLARE_GETTER_AND_SETTER(Type, name)
#define DECLARE_LAZY_INIT_ISOLATE_GETTER(Type, name)
#define ISOLATE_OBJECT_STORE_FIELD_LIST(R_, RW)
#define DECLARE_RELAXED_ATOMIC_GETTER_AND_SETTER(Type, name)
#define DECLARE_LAZY_INIT_ASYNC_GETTER(Type, name)
#define DECLARE_ACQREL_ATOMIC_GETTER_AND_SETTER(Type, name)
#define DECLARE_LAZY_INIT_INTERNAL_GETTER(Type, name)
#define DECLARE_LAZY_INIT_FFI_GETTER(Type, name)
#define MAKE_CASE(CamelName, name)
#define DECLARE_LAZY_OBJECT_STORE_FIELD(type, name)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581