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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 1377543003: Clean up serialization of RawFunction, RawCode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: as-reference Created 5 years, 3 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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index ea0dc35128dafd441dae6e8939084a5d71532e0c..a77eb0fde5cf7d9f03083796cd137c00198978bf 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -652,25 +652,26 @@ RawFunction* Function::ReadFrom(SnapshotReader* reader,
func.set_optimized_call_site_count(reader->Read<uint16_t>());
// Set all the object fields.
- bool is_optimized = func.usage_counter() != 0;
- RawObject** toobj = reader->snapshot_code() ? func.raw()->to() :
- (is_optimized ? func.raw()->to_optimized_snapshot() :
- func.raw()->to_snapshot());
READ_OBJECT_FIELDS(func,
- func.raw()->from(), toobj,
+ func.raw()->from(), func.raw()->to_snapshot(),
kAsReference);
- if (!reader->snapshot_code()) {
- // Initialize all fields that are not part of the snapshot.
- if (!is_optimized) {
+ // Initialize all fields that are not part of the snapshot.
+ if (reader->snapshot_code()) {
+ func.ClearICDataArray();
+ func.ClearCode();
+ // Read the code object.
rmacnak 2015/09/29 18:30:03 Read the code object and fixup entry_point_.
siva 2015/09/29 20:24:25 Done.
+ (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
+ func.SetInstructions(*reader->CodeHandle());
+ } else {
+ bool is_optimized = func.usage_counter() != 0;
+ if (is_optimized) {
+ // Read the ic data array as the function is an optimized one.
+ (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
+ func.set_ic_data_array(*reader->ArrayHandle());
+ } else {
func.ClearICDataArray();
}
func.ClearCode();
- } else {
- // Fix entry point.
- (*reader->CodeHandle()) = func.CurrentCode();
- uword new_entry = (*reader->CodeHandle()).EntryPoint();
- ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
- func.StoreNonPointer(&func.raw_ptr()->entry_point_, new_entry);
}
return func.raw();
} else {
@@ -727,11 +728,19 @@ void RawFunction::WriteTo(SnapshotWriter* writer,
writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
// Write out all the object pointer fields.
- RawObject** toobj =
- writer->snapshot_code() ? to() :
- (is_optimized ? to_optimized_snapshot() : to_snapshot());
SnapshotWriterVisitor visitor(writer, kAsReference);
- visitor.VisitPointers(from(), toobj);
+ visitor.VisitPointers(from(), to_snapshot());
+ if (writer->snapshot_code()) {
+ ASSERT(ptr()->ic_data_array_ == Array::null());
+ ASSERT((ptr()->code_ == ptr()->unoptimized_code_) ||
+ (ptr()->unoptimized_code_ == Code::null()));
+ // Write out the code object as we are generating a precompiled snapshot.
+ writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject);
+ } else if (is_optimized) {
+ // Write out the ic data array as the function is optimized or
+ // we are generating a precompiled snapshot.
+ writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference);
+ }
} else {
writer->WriteFunctionId(this, owner_is_class);
}
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698