Do not rewrite the VM isolate's symbol table during AOT snapshots.

This has the effect of making every program generate the same VM isolate, allowing an embedder to load different programs into different isolates.

Verify the number of base objects in clustered snapshots.

Remove dead code leftover from core snapshots switching from saving scripts to saving token streams in the VM isolate.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2790243003 .
This commit is contained in:
Ryan Macnak
2017-04-06 13:22:22 -07:00
parent 5f5a698100
commit 22eee804cd
3 changed files with 16 additions and 35 deletions
+15 -2
View File
@@ -4719,6 +4719,7 @@ void Serializer::Serialize() {
}
#endif
Write<int32_t>(num_base_objects_);
Write<int32_t>(num_objects);
Write<int32_t>(num_clusters);
@@ -5093,6 +5094,7 @@ RawApiError* Deserializer::VerifyVersionAndFeatures(Isolate* isolate) {
void Deserializer::Prepare() {
num_base_objects_ = Read<int32_t>();
num_objects_ = Read<int32_t>();
num_clusters_ = Read<int32_t>();
@@ -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();
}
}
+1
View File
@@ -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_;
-33
View File
@@ -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),