Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: runtime/vm/snapshot.cc

Issue 1944213002: Support for taking full snapshots from 'dart', not just 'dart_bootstrap'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/snapshot.cc
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 2f2ca6a533b9cde0fe76207cfeb337ca676946b6..fcb79dce164db102289f38fd2d45ea6c799dc237 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -1818,7 +1818,7 @@ SnapshotWriter::SnapshotWriter(Thread* thread,
ForwardList* forward_list,
InstructionsWriter* instructions_writer,
bool can_send_any_object,
- bool vm_isolate_is_symbolic)
+ bool writing_vm_isolate)
: BaseWriter(buffer, alloc, initial_size),
thread_(thread),
kind_(kind),
@@ -1830,7 +1830,7 @@ SnapshotWriter::SnapshotWriter(Thread* thread,
exception_msg_(NULL),
unmarked_objects_(false),
can_send_any_object_(can_send_any_object),
- vm_isolate_is_symbolic_(vm_isolate_is_symbolic) {
+ writing_vm_isolate_(writing_vm_isolate) {
ASSERT(forward_list_ != NULL);
}
@@ -1922,6 +1922,14 @@ bool SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) {
}
}
+ if (writing_vm_isolate_) {
+ if (id == kCodeCid) {
+ ASSERT(Snapshot::IncludesCode(kind()));
+ }
+ // Write the object instead of a reference.
+ return false;
+ }
siva 2016/05/05 00:50:04 Instead of this code which is heard to read and un
+
if (Snapshot::IsFull(kind())) {
// Check it is a predefined symbol in the VM isolate.
id = Symbols::LookupVMSymbol(rawobj);
@@ -1960,10 +1968,6 @@ bool SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) {
}
}
- if (!vm_isolate_is_symbolic()) {
- return false;
- }
-
const Object& obj = Object::Handle(rawobj);
FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString());
return false;
@@ -2011,8 +2015,7 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
uint8_t** vm_isolate_snapshot_buffer,
uint8_t** isolate_snapshot_buffer,
ReAlloc alloc,
- InstructionsWriter* instructions_writer,
- bool vm_isolate_is_symbolic)
+ InstructionsWriter* instructions_writer)
: thread_(Thread::Current()),
kind_(kind),
vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer),
@@ -2023,8 +2026,8 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
forward_list_(NULL),
instructions_writer_(instructions_writer),
scripts_(Array::Handle(zone())),
- symbol_table_(Array::Handle(zone())),
- vm_isolate_is_symbolic_(vm_isolate_is_symbolic) {
+ saved_symbol_table_(Array::Handle(zone())),
+ new_vm_symbol_table_(Array::Handle(zone())) {
ASSERT(isolate_snapshot_buffer_ != NULL);
ASSERT(alloc_ != NULL);
ASSERT(isolate() != NULL);
@@ -2050,10 +2053,15 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
heap()->IterateOldObjects(&script_visitor);
if (vm_isolate_snapshot_buffer != NULL) {
- // Stash the symbol table away for writing and reading into the vm isolate,
- // and reset the symbol table for the regular isolate so that we do not
- // write these symbols into the snapshot of a regular dart isolate.
- symbol_table_ = object_store->symbol_table();
+ // Tuck away the current symbol table.
+ saved_symbol_table_ = object_store->symbol_table();
+
+ // Create a unified symbol table that will be written as the vm isolate's
+ // symbol table.
+ new_vm_symbol_table_ = Symbols::UnifiedSymbolTable();
+
+ // Create an empty symbol table that will be written as the isolate's symbol
+ // table.
Symbols::SetupSymbolTable(isolate());
}
@@ -2065,10 +2073,11 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
FullSnapshotWriter::~FullSnapshotWriter() {
delete forward_list_;
// We may run Dart code afterwards, restore the symbol table if needed.
- if (!symbol_table_.IsNull()) {
- isolate()->object_store()->set_symbol_table(symbol_table_);
- symbol_table_ = Array::null();
+ if (!saved_symbol_table_.IsNull()) {
+ isolate()->object_store()->set_symbol_table(saved_symbol_table_);
+ saved_symbol_table_ = Array::null();
}
+ new_vm_symbol_table_ = Array::null();
scripts_ = Array::null();
}
@@ -2083,7 +2092,7 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() {
forward_list_,
instructions_writer_,
true, /* can_send_any_object */
- vm_isolate_is_symbolic_);
+ true /* writing_vm_isolate */);
// Write full snapshot for the VM isolate.
// Setup for long jump in case there is an exception while writing
// the snapshot.
@@ -2099,10 +2108,10 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() {
* Now Write out the following
* - the symbol table
* - all the scripts and token streams for these scripts
- *
+ * - the stub code (precompiled snapshots only)
**/
// Write out the symbol table.
- writer.WriteObject(symbol_table_.raw());
+ writer.WriteObject(new_vm_symbol_table_.raw());
// Write out all the script objects and the accompanying token streams
// for the bootstrap libraries so that they are in the VM isolate
@@ -2110,11 +2119,9 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() {
writer.WriteObject(scripts_.raw());
if (Snapshot::IncludesCode(kind_)) {
- ASSERT(!vm_isolate_is_symbolic_);
StubCode::WriteTo(&writer);
}
-
writer.FillHeader(writer.kind());
vm_isolate_snapshot_size_ = writer.BytesWritten();
@@ -2133,7 +2140,7 @@ void FullSnapshotWriter::WriteIsolateFullSnapshot() {
forward_list_,
instructions_writer_,
true, /* can_send_any_object */
- true /* vm_isolate_is_symbolic */);
+ false /* writing_vm_isolate */);
ObjectStore* object_store = isolate()->object_store();
ASSERT(object_store != NULL);
@@ -2197,8 +2204,7 @@ PrecompiledSnapshotWriter::PrecompiledSnapshotWriter(
vm_isolate_snapshot_buffer,
isolate_snapshot_buffer,
alloc,
- instructions_writer,
- false /* vm_isolate_is_symbolic */) {
+ instructions_writer) {
}
@@ -2713,7 +2719,7 @@ ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer,
&forward_list_,
NULL, /* instructions_writer */
true, /* can_send_any_object */
- true /* vm_isolate_is_symbolic */),
+ false /* writing_vm_isolate */),
forward_list_(thread(), kMaxPredefinedObjectIds) {
ASSERT(buffer != NULL);
ASSERT(alloc != NULL);
@@ -2769,7 +2775,7 @@ MessageWriter::MessageWriter(uint8_t** buffer,
&forward_list_,
NULL, /* instructions_writer */
can_send_any_object,
- true /* vm_isolate_is_symbolic */),
+ false /* writing_vm_isolate */),
forward_list_(thread(), kMaxPredefinedObjectIds) {
ASSERT(buffer != NULL);
ASSERT(alloc != NULL);
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | runtime/vm/symbols.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698