Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::ProgramSerializationRoots Class Reference
Inheritance diagram for dart::ProgramSerializationRoots:
dart::SerializationRoots

Public Member Functions

 ProgramSerializationRoots (ZoneGrowableArray< Object * > *base_objects, ObjectStore *object_store, Snapshot::Kind snapshot_kind)
 
 ~ProgramSerializationRoots ()
 
void AddBaseObjects (Serializer *s)
 
void PushRoots (Serializer *s)
 
void WriteRoots (Serializer *s)
 
virtual const CompressedStackMapscanonicalized_stack_map_entries () const
 
- Public Member Functions inherited from dart::SerializationRoots
virtual ~SerializationRoots ()
 
virtual void AddBaseObjects (Serializer *serializer)=0
 
virtual void PushRoots (Serializer *serializer)=0
 
virtual void WriteRoots (Serializer *serializer)=0
 
virtual const CompressedStackMapscanonicalized_stack_map_entries () const
 

Detailed Description

Definition at line 7037 of file app_snapshot.cc.

Constructor & Destructor Documentation

◆ ProgramSerializationRoots()

dart::ProgramSerializationRoots::ProgramSerializationRoots ( ZoneGrowableArray< Object * > *  base_objects,
ObjectStore object_store,
Snapshot::Kind  snapshot_kind 
)
inline

Definition at line 7055 of file app_snapshot.cc.

7058 : base_objects_(base_objects),
7059 object_store_(object_store),
7060 snapshot_kind_(snapshot_kind) {
7061#define ONLY_IN_AOT(code) \
7062 if (snapshot_kind_ == Snapshot::kFullAOT) { \
7063 code \
7064 }
7065#define SAVE_AND_RESET_ROOT(name, Type, init) \
7066 do { \
7067 saved_##name##_ = object_store->name(); \
7068 object_store->set_##name(Type::Handle(init)); \
7069 } while (0);
7070
7072#undef SAVE_AND_RESET_ROOT
7073#undef ONLY_IN_AOT
7074 }
#define SAVE_AND_RESET_ROOT(name, Type, init)
#define RESET_ROOT_LIST(V)
static SnapshotKind snapshot_kind
Definition: gen_snapshot.cc:83

◆ ~ProgramSerializationRoots()

dart::ProgramSerializationRoots::~ProgramSerializationRoots ( )
inline

Definition at line 7075 of file app_snapshot.cc.

7075 {
7076#define ONLY_IN_AOT(code) \
7077 if (snapshot_kind_ == Snapshot::kFullAOT) { \
7078 code \
7079 }
7080#define RESTORE_ROOT(name, Type, init) \
7081 object_store_->set_##name(saved_##name##_);
7083#undef RESTORE_ROOT
7084#undef ONLY_IN_AOT
7085 }
#define RESTORE_ROOT(name, Type, init)

Member Function Documentation

◆ AddBaseObjects()

void dart::ProgramSerializationRoots::AddBaseObjects ( Serializer s)
inlinevirtual

Implements dart::SerializationRoots.

Definition at line 7087 of file app_snapshot.cc.

7087 {
7088 if (base_objects_ == nullptr) {
7089 // Not writing a new vm isolate: use the one this VM was loaded from.
7090 const Array& base_objects = Object::vm_isolate_snapshot_object_table();
7091 for (intptr_t i = kFirstReference; i < base_objects.Length(); i++) {
7092 s->AddBaseObject(base_objects.At(i));
7093 }
7094 } else {
7095 // Base objects carried over from WriteVMSnapshot.
7096 for (intptr_t i = 0; i < base_objects_->length(); i++) {
7097 s->AddBaseObject((*base_objects_)[i]->ptr());
7098 }
7099 }
7100 }
struct MyStruct s
static constexpr intptr_t kFirstReference

◆ canonicalized_stack_map_entries()

virtual const CompressedStackMaps & dart::ProgramSerializationRoots::canonicalized_stack_map_entries ( ) const
inlinevirtual

Reimplemented from dart::SerializationRoots.

Definition at line 7167 of file app_snapshot.cc.

7167 {
7168 return saved_canonicalized_stack_map_entries_;
7169 }

◆ PushRoots()

void dart::ProgramSerializationRoots::PushRoots ( Serializer s)
inlinevirtual

Implements dart::SerializationRoots.

Definition at line 7102 of file app_snapshot.cc.

7102 {
7103 ObjectPtr* from = object_store_->from();
7104 ObjectPtr* to = object_store_->to_snapshot(s->kind());
7105 for (ObjectPtr* p = from; p <= to; p++) {
7106 s->Push(*p);
7107 }
7108
7109 FieldTable* initial_field_table =
7110 s->thread()->isolate_group()->initial_field_table();
7111 for (intptr_t i = 0, n = initial_field_table->NumFieldIds(); i < n; i++) {
7112 s->Push(initial_field_table->At(i));
7113 }
7114
7115 FieldTable* shared_initial_field_table =
7116 s->thread()->isolate_group()->shared_initial_field_table();
7117 for (intptr_t i = 0, n = shared_initial_field_table->NumFieldIds(); i < n;
7118 i++) {
7119 s->Push(shared_initial_field_table->At(i));
7120 }
7121
7122 dispatch_table_entries_ = object_store_->dispatch_table_code_entries();
7123 // We should only have a dispatch table in precompiled mode.
7124 ASSERT(dispatch_table_entries_.IsNull() || s->kind() == Snapshot::kFullAOT);
7125
7126#if defined(DART_PRECOMPILER)
7127 // We treat the dispatch table as a root object and trace the Code objects
7128 // it references. Otherwise, a non-empty entry could be invalid on
7129 // deserialization if the corresponding Code object was not reachable from
7130 // the existing snapshot roots.
7131 if (!dispatch_table_entries_.IsNull()) {
7132 for (intptr_t i = 0; i < dispatch_table_entries_.Length(); i++) {
7133 s->Push(dispatch_table_entries_.At(i));
7134 }
7135 }
7136#endif
7137 }
ObjectPtr At(intptr_t index) const
Definition: object.h:10875
intptr_t Length() const
Definition: object.h:10829
bool IsNull() const
Definition: object.h:363
#define ASSERT(E)

◆ WriteRoots()

void dart::ProgramSerializationRoots::WriteRoots ( Serializer s)
inlinevirtual

Implements dart::SerializationRoots.

Definition at line 7139 of file app_snapshot.cc.

7139 {
7140 ObjectPtr* from = object_store_->from();
7141 ObjectPtr* to = object_store_->to_snapshot(s->kind());
7142 for (ObjectPtr* p = from; p <= to; p++) {
7143 s->WriteRootRef(*p, kObjectStoreFieldNames[p - from]);
7144 }
7145
7146 FieldTable* initial_field_table =
7147 s->thread()->isolate_group()->initial_field_table();
7148 intptr_t n = initial_field_table->NumFieldIds();
7149 s->WriteUnsigned(n);
7150 for (intptr_t i = 0; i < n; i++) {
7151 s->WriteRootRef(initial_field_table->At(i), "some-static-field");
7152 }
7153
7154 FieldTable* shared_initial_field_table =
7155 s->thread()->isolate_group()->shared_initial_field_table();
7156 intptr_t n_shared = shared_initial_field_table->NumFieldIds();
7157 s->WriteUnsigned(n_shared);
7158 for (intptr_t i = 0; i < n_shared; i++) {
7159 s->WriteRootRef(shared_initial_field_table->At(i),
7160 "some-shared-static-field");
7161 }
7162
7163 // The dispatch table is serialized only for precompiled snapshots.
7164 s->WriteDispatchTable(dispatch_table_entries_);
7165 }
static const char *const kObjectStoreFieldNames[]

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