Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Friends | List of all members
dart::ObjectStore Class Reference

#include <object_store.h>

Public Types

enum  BootstrapLibraryId
 

Public Member Functions

 ObjectStore ()
 
 ~ObjectStore ()
 
 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)
 
void set_bootstrap_library (BootstrapLibraryId index, const Library &value)
 
void VisitObjectPointers (ObjectPointerVisitor *visitor)
 
ErrorPtr PreallocateObjects ()
 
void InitKnownObjects ()
 
void InitStubs ()
 
void PrintToJSONObject (JSONObject *jsobj)
 

Friends

class ProgramSerializationRoots
 
class ProgramDeserializationRoots
 
class ProgramVisitor
 

Detailed Description

Definition at line 456 of file object_store.h.

Member Enumeration Documentation

◆ BootstrapLibraryId

Definition at line 458 of file object_store.h.

458 {
459#define MAKE_ID(Name, _) k##Name,
460
462#undef MAKE_ID
463 };
#define MAKE_ID(Name, _)
Definition: object_store.h:459
#define FOR_EACH_BOOTSTRAP_LIBRARY(M)
Definition: object_store.h:19

Constructor & Destructor Documentation

◆ ObjectStore()

dart::ObjectStore::ObjectStore ( )

Definition at line 100 of file object_store.cc.

101 :
102#define EMIT_FIELD_INIT(type, name) name##_(nullptr),
112#undef EMIT_FIELD_INIT
113 // Just to prevent a trailing comma.
114 unused_field_(0) {
115 for (ObjectPtr* current = from(); current <= to(); current++) {
116 *current = Object::null();
117 }
118}
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)
Definition: object_store.h:508
static ObjectPtr null()
Definition: object.h:433
#define EMIT_FIELD_INIT(type, name)

◆ ~ObjectStore()

dart::ObjectStore::~ObjectStore ( )

Definition at line 120 of file object_store.cc.

120{}

Member Function Documentation

◆ InitKnownObjects()

void dart::ObjectStore::InitKnownObjects ( )

Definition at line 215 of file object_store.cc.

215 {
216 Thread* thread = Thread::Current();
217 Zone* zone = thread->zone();
218 Class& cls = Class::Handle(zone);
219 const Library& collection_lib = Library::Handle(zone, collection_library());
220 cls = collection_lib.LookupClassAllowPrivate(Symbols::_Set());
221 ASSERT(!cls.IsNull());
222 set_set_impl_class(cls);
223
224#if defined(DART_PRECOMPILED_RUNTIME)
225 // The rest of these objects are only needed for code generation.
226 return;
227#else
228 auto isolate_group = thread->isolate_group();
229 ASSERT(isolate_group != nullptr && isolate_group->object_store() == this);
230
231 const Library& async_lib = Library::Handle(zone, async_library());
232 ASSERT(!async_lib.IsNull());
233 cls = async_lib.LookupClass(Symbols::Future());
234 ASSERT(!cls.IsNull());
235 set_future_class(cls);
236
237 String& function_name = String::Handle(zone);
238 Function& function = Function::Handle(zone);
239 Field& field = Field::Handle(zone);
240
241 cls =
242 async_lib.LookupClassAllowPrivate(Symbols::_AsyncStarStreamController());
243 ASSERT(!cls.IsNull());
244 RELEASE_ASSERT(cls.EnsureIsFinalized(thread) == Error::null());
245 set_async_star_stream_controller(cls);
246
247 function = cls.LookupFunctionAllowPrivate(Symbols::add());
248 ASSERT(!function.IsNull());
249 set_async_star_stream_controller_add(function);
250
251 function = cls.LookupFunctionAllowPrivate(Symbols::addStream());
252 ASSERT(!function.IsNull());
253 set_async_star_stream_controller_add_stream(function);
254
255 field = cls.LookupFieldAllowPrivate(Symbols::asyncStarBody());
256 ASSERT(!field.IsNull());
257 set_async_star_stream_controller_async_star_body(field);
258
259#if !defined(PRODUCT)
260 // Disable debugging and inlining of all functions on the
261 // _AsyncStarStreamController class.
262 const Array& functions = Array::Handle(zone, cls.current_functions());
263 for (intptr_t i = 0; i < functions.Length(); i++) {
264 function ^= functions.At(i);
265 if (function.IsNull()) {
266 break;
267 }
268 function.set_is_debuggable(false);
269 function.set_is_inlinable(false);
270 }
271#endif
272
273 cls = async_lib.LookupClassAllowPrivate(Symbols::Stream());
274 ASSERT(!cls.IsNull());
275 set_stream_class(cls);
276
277 cls = async_lib.LookupClassAllowPrivate(Symbols::_SuspendState());
278 ASSERT(!cls.IsNull());
279 const auto& error = cls.EnsureIsFinalized(thread);
281
282 function = cls.LookupFunctionAllowPrivate(Symbols::_initAsync());
283 ASSERT(!function.IsNull());
284 set_suspend_state_init_async(function);
285
286 function = cls.LookupFunctionAllowPrivate(Symbols::_await());
287 ASSERT(!function.IsNull());
288 set_suspend_state_await(function);
289
290 function = cls.LookupFunctionAllowPrivate(Symbols::_awaitWithTypeCheck());
291 ASSERT(!function.IsNull());
292 set_suspend_state_await_with_type_check(function);
293
294 function = cls.LookupFunctionAllowPrivate(Symbols::_returnAsync());
295 ASSERT(!function.IsNull());
296 set_suspend_state_return_async(function);
297
298 function = cls.LookupFunctionAllowPrivate(Symbols::_returnAsyncNotFuture());
299 ASSERT(!function.IsNull());
300 set_suspend_state_return_async_not_future(function);
301
302 function = cls.LookupFunctionAllowPrivate(Symbols::_initAsyncStar());
303 ASSERT(!function.IsNull());
304 set_suspend_state_init_async_star(function);
305
306 function = cls.LookupFunctionAllowPrivate(Symbols::_yieldAsyncStar());
307 ASSERT(!function.IsNull());
308 set_suspend_state_yield_async_star(function);
309
310 function = cls.LookupFunctionAllowPrivate(Symbols::_returnAsyncStar());
311 ASSERT(!function.IsNull());
312 set_suspend_state_return_async_star(function);
313
314 function = cls.LookupFunctionAllowPrivate(Symbols::_initSyncStar());
315 ASSERT(!function.IsNull());
316 set_suspend_state_init_sync_star(function);
317
318 function = cls.LookupFunctionAllowPrivate(Symbols::_suspendSyncStarAtStart());
319 ASSERT(!function.IsNull());
320 set_suspend_state_suspend_sync_star_at_start(function);
321
322 function = cls.LookupFunctionAllowPrivate(Symbols::_handleException());
323 ASSERT(!function.IsNull());
324 set_suspend_state_handle_exception(function);
325
326 cls = async_lib.LookupClassAllowPrivate(Symbols::_SyncStarIterator());
327 ASSERT(!cls.IsNull());
328 RELEASE_ASSERT(cls.EnsureIsFinalized(thread) == Error::null());
329 set_sync_star_iterator_class(cls);
330
331 field = cls.LookupFieldAllowPrivate(Symbols::_current());
332 ASSERT(!field.IsNull());
333 set_sync_star_iterator_current(field);
334
335 field = cls.LookupFieldAllowPrivate(Symbols::_state());
336 ASSERT(!field.IsNull());
337 set_sync_star_iterator_state(field);
338
339 field = cls.LookupFieldAllowPrivate(Symbols::_yieldStarIterable());
340 ASSERT(!field.IsNull());
341 set_sync_star_iterator_yield_star_iterable(field);
342
343 const Library& core_lib = Library::Handle(zone, core_library());
344 cls = core_lib.LookupClassAllowPrivate(Symbols::_CompileTimeError());
345 ASSERT(!cls.IsNull());
346 set_compiletime_error_class(cls);
347
348 cls = core_lib.LookupClassAllowPrivate(Symbols::Pragma());
349 ASSERT(!cls.IsNull());
350 set_pragma_class(cls);
351 RELEASE_ASSERT(cls.EnsureIsFinalized(thread) == Error::null());
352 set_pragma_name(Field::Handle(zone, cls.LookupField(Symbols::name())));
353 set_pragma_options(Field::Handle(zone, cls.LookupField(Symbols::options())));
354
355 cls = core_lib.LookupClassAllowPrivate(Symbols::_GrowableList());
356 ASSERT(!cls.IsNull());
357 RELEASE_ASSERT(cls.EnsureIsFinalized(thread) == Error::null());
358 growable_list_factory_ =
359 cls.LookupFactoryAllowPrivate(Symbols::_GrowableListFactory());
360 ASSERT(growable_list_factory_ != Function::null());
361
362 cls = core_lib.LookupClassAllowPrivate(Symbols::Error());
363 ASSERT(!cls.IsNull());
364 set_error_class(cls);
365
366 cls = core_lib.LookupClassAllowPrivate(Symbols::Expando());
367 ASSERT(!cls.IsNull());
368 set_expando_class(cls);
369
370 cls = core_lib.LookupClassAllowPrivate(Symbols::Iterable());
371 ASSERT(!cls.IsNull());
372 set_iterable_class(cls);
373
374 // Cache the core private functions used for fast instance of checks.
375 simple_instance_of_function_ =
376 PrivateObjectLookup(Symbols::_simpleInstanceOf());
377 simple_instance_of_true_function_ =
378 PrivateObjectLookup(Symbols::_simpleInstanceOfTrue());
379 simple_instance_of_false_function_ =
380 PrivateObjectLookup(Symbols::_simpleInstanceOfFalse());
381
382 // Ensure AddSmiSmiCheckForFastSmiStubs run by the background compiler
383 // will not create new functions.
384 const Class& smi_class = Class::Handle(zone, this->smi_class());
385 RELEASE_ASSERT(smi_class.EnsureIsFinalized(thread) == Error::null());
389 /*allow_add=*/true);
393 /*allow_add=*/true);
397 /*allow_add=*/true);
401 /*allow_add=*/true);
405 /*allow_add=*/true);
409 /*allow_add=*/true);
413 /*allow_add=*/true);
417 /*allow_add=*/true);
418#endif // defined(DART_PRECOMPILED_RUNTIME)
419}
const char * options
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
static StringPtr CreateDynamicInvocationForwarderName(const String &name)
Definition: object.cc:4205
static Object & Handle()
Definition: object.h:407
static FunctionPtr ResolveDynamicAnyArgs(Zone *zone, const Class &receiver_class, const String &function_name, bool allow_add)
Definition: resolver.cc:185
static const String & Plus()
Definition: symbols.h:617
static const String & LAngleBracket()
Definition: symbols.h:623
static const String & BitOr()
Definition: symbols.h:619
static const String & RAngleBracket()
Definition: symbols.h:626
static const String & Star()
Definition: symbols.h:678
static const String & BitAnd()
Definition: symbols.h:620
static const String & Minus()
Definition: symbols.h:618
static const String & Equals()
Definition: symbols.h:614
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
Definition: fuchsia.cc:51
const char *const function_name
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ InitStubs()

void dart::ObjectStore::InitStubs ( )

Definition at line 129 of file object_store.cc.

129 {
130#define DO(member, name) set_##member(StubCode::name());
132#undef DO
133}
#define DO(member, name)
#define OBJECT_STORE_STUB_CODE_LIST(DO)
Definition: object_store.h:296

◆ OBJECT_STORE_FIELD_LIST()

Definition at line 508 of file object_store.h.

529 {
530 switch (index) {
531#define MAKE_CASE(CamelName, name) \
532 case k##CamelName: \
533 return name##_library_;
534
536#undef MAKE_CASE
537
538 default:
539 UNREACHABLE();
540 return Library::null();
541 }
542 }
#define UNREACHABLE()
Definition: assert.h:248
#define MAKE_CASE(CamelName, name)

◆ PreallocateObjects()

ErrorPtr dart::ObjectStore::PreallocateObjects ( )

Definition at line 170 of file object_store.cc.

170 {
171 Thread* thread = Thread::Current();
172 IsolateGroup* isolate_group = thread->isolate_group();
173 // Either we are the object store on isolate group, or isolate group has no
174 // object store and we are the object store on the isolate.
175 ASSERT(isolate_group != nullptr && isolate_group->object_store() == this);
176
177 if (this->stack_overflow() != Instance::null()) {
178 ASSERT(this->out_of_memory() != Instance::null());
179 return Error::null();
180 }
181 ASSERT(this->stack_overflow() == Instance::null());
182 ASSERT(this->out_of_memory() == Instance::null());
183
184 Object& result = Object::Handle();
185 const Library& library = Library::Handle(Library::CoreLibrary());
186
187 result = AllocateObjectByClassName(library, Symbols::StackOverflowError());
188 if (result.IsError()) {
189 return Error::Cast(result).ptr();
190 }
191 set_stack_overflow(Instance::Cast(result));
192
193 result = AllocateObjectByClassName(library, Symbols::OutOfMemoryError());
194 if (result.IsError()) {
195 return Error::Cast(result).ptr();
196 }
197 set_out_of_memory(Instance::Cast(result));
198
199 return Error::null();
200}
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
GAsyncResult * result
static InstancePtr AllocateObjectByClassName(const Library &library, const String &class_name)

◆ PrintToJSONObject()

void dart::ObjectStore::PrintToJSONObject ( JSONObject jsobj)

Definition at line 136 of file object_store.cc.

136 {
137 jsobj->AddProperty("type", "_ObjectStore");
138
139 {
140 JSONObject fields(jsobj, "fields");
141 Object& value = Object::Handle();
142 static const char* const names[] = {
143#define EMIT_FIELD_NAME(type, name) #name "_",
148#undef EMIT_FIELD_NAME
149 };
150 ObjectPtr* current = from();
151 intptr_t i = 0;
152 while (current <= to()) {
153 value = *current;
154 fields.AddProperty(names[i], value);
155 current++;
156 i++;
157 }
159 }
160}
uint8_t value
static const char *const names[]
Definition: symbols.cc:24
#define EMIT_FIELD_NAME(type, name)
#define ARRAY_SIZE(array)
Definition: globals.h:72

◆ set_bootstrap_library()

void dart::ObjectStore::set_bootstrap_library ( BootstrapLibraryId  index,
const Library value 
)
inline

Definition at line 544 of file object_store.h.

544 {
545 switch (index) {
546#define MAKE_CASE(CamelName, name) \
547 case k##CamelName: \
548 name##_library_ = value.ptr(); \
549 break;
550
552#undef MAKE_CASE
553 default:
554 UNREACHABLE();
555 }
556 }

◆ VisitObjectPointers()

void dart::ObjectStore::VisitObjectPointers ( ObjectPointerVisitor visitor)

Definition at line 122 of file object_store.cc.

122 {
123 ASSERT(visitor != nullptr);
124 visitor->set_gc_root_type("object store");
125 visitor->VisitPointers(from(), to());
126 visitor->clear_gc_root_type();
127}

Friends And Related Function Documentation

◆ ProgramDeserializationRoots

friend class ProgramDeserializationRoots
friend

Definition at line 623 of file object_store.h.

◆ ProgramSerializationRoots

friend class ProgramSerializationRoots
friend

Definition at line 622 of file object_store.h.

◆ ProgramVisitor

friend class ProgramVisitor
friend

Definition at line 624 of file object_store.h.


The documentation for this class was generated from the following files: