diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index c8d139ce7c9..d57951938a1 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -4719,6 +4719,7 @@ void Serializer::Serialize() { } #endif + Write(num_base_objects_); Write(num_objects); Write(num_clusters); @@ -5093,6 +5094,7 @@ RawApiError* Deserializer::VerifyVersionAndFeatures(Isolate* isolate) { void Deserializer::Prepare() { + num_base_objects_ = Read(); num_objects_ = Read(); num_clusters_ = Read(); @@ -5102,7 +5104,11 @@ void Deserializer::Prepare() { void Deserializer::Deserialize() { - // TODO(rmacnak): Verify num of base objects. + if (num_base_objects_ != (next_ref_index_ - 1)) { + FATAL2("Snapshot expects %" Pd + " base objects, but deserializer provided %" Pd, + num_base_objects_, next_ref_index_ - 1); + } { NOT_IN_PRODUCT(TimelineDurationScope tds( @@ -5360,7 +5366,12 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind, // Can't have any mutation happening while we're serializing. ASSERT(isolate()->background_compiler() == NULL); - if (vm_snapshot_data_buffer != NULL) { + // TODO(rmacnak): The special case for AOT causes us to always generate the + // same VM isolate snapshot for every app. AOT snapshots should be cleaned up + // so the VM isolate snapshot is generated separately and each app is + // generated from a VM that has loaded this snapshots, much like app-jit + // snapshots. + if ((vm_snapshot_data_buffer != NULL) && (kind != Snapshot::kAppAOT)) { NOT_IN_PRODUCT(TimelineDurationScope tds( thread(), Timeline::GetIsolateStream(), "PrepareNewVMIsolate")); @@ -5390,6 +5401,8 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind, Symbols::SetupSymbolTable(isolate()); } else { // Reuse the current vm isolate. + saved_symbol_table_ = object_store->symbol_table(); + new_vm_symbol_table_ = Dart::vm_isolate()->object_store()->symbol_table(); } } diff --git a/runtime/vm/clustered_snapshot.h b/runtime/vm/clustered_snapshot.h index 8e76043cea4..a91497f170b 100644 --- a/runtime/vm/clustered_snapshot.h +++ b/runtime/vm/clustered_snapshot.h @@ -377,6 +377,7 @@ class Deserializer : public StackResource { Snapshot::Kind kind_; ReadStream stream_; InstructionsReader* instructions_reader_; + intptr_t num_base_objects_; intptr_t num_objects_; intptr_t num_clusters_; RawArray* refs_; diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index 82a12448e99..d720d0ef67e 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -1439,39 +1439,6 @@ bool SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { #undef VM_OBJECT_WRITE -// An object visitor which will iterate over all the script objects in the heap -// and either count them or collect them into an array. This is used during -// full snapshot generation of the VM isolate to write out all script -// objects and their accompanying token streams. -class ScriptVisitor : public ObjectVisitor { - public: - explicit ScriptVisitor(Thread* thread) - : objHandle_(Object::Handle(thread->zone())), count_(0), scripts_(NULL) {} - - ScriptVisitor(Thread* thread, const Array* scripts) - : objHandle_(Object::Handle(thread->zone())), - count_(0), - scripts_(scripts) {} - - void VisitObject(RawObject* obj) { - if (obj->IsScript()) { - if (scripts_ != NULL) { - objHandle_ = obj; - scripts_->SetAt(count_, objHandle_); - } - count_ += 1; - } - } - - intptr_t count() const { return count_; } - - private: - Object& objHandle_; - intptr_t count_; - const Array* scripts_; -}; - - ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) : thread_(thread), first_object_id_(first_object_id),