Chromium Code Reviews| Index: runtime/vm/snapshot.cc |
| diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc |
| index 4b92acda84b71f86da0891b60c6008beba3d49a4..9035b86f03e82e24e97f5551bae9f4411ba4bf2a 100644 |
| --- a/runtime/vm/snapshot.cc |
| +++ b/runtime/vm/snapshot.cc |
| @@ -177,6 +177,7 @@ SnapshotReader::SnapshotReader( |
| Zone* zone) |
| : BaseReader(buffer, size), |
| kind_(kind), |
| + snapshot_code_(false), |
| isolate_(isolate), |
| zone_(zone), |
| heap_(isolate->heap()), |
| @@ -925,6 +926,32 @@ RawFunction* SnapshotReader::NewFunction() { |
| } |
| +RawCode* SnapshotReader::NewCode(intptr_t pointer_offsets_length) { |
| + ASSERT(pointer_offsets_length == 0); |
| + ALLOC_NEW_OBJECT(Code); |
| +} |
| + |
| + |
| +RawObjectPool* SnapshotReader::NewObjectPool(intptr_t length) { |
| + ALLOC_NEW_OBJECT(ObjectPool); |
| +} |
| + |
| + |
| +RawICData* SnapshotReader::NewICData() { |
| + ALLOC_NEW_OBJECT(ICData); |
| +} |
| + |
| + |
| +RawMegamorphicCache* SnapshotReader::NewMegamorphicCache() { |
| + ALLOC_NEW_OBJECT(MegamorphicCache); |
| +} |
| + |
| + |
| +RawSubtypeTestCache* SnapshotReader::NewSubtypeTestCache() { |
| + ALLOC_NEW_OBJECT(SubtypeTestCache); |
| +} |
| + |
| + |
| RawField* SnapshotReader::NewField() { |
| ALLOC_NEW_OBJECT(Field); |
| } |
| @@ -1032,6 +1059,12 @@ RawStacktrace* SnapshotReader::NewStacktrace() { |
| } |
| +RawInstructions* SnapshotReader::GetInstructionsById(int32_t id) { |
| + // TODO(rmacnak): Read from shared library. |
| + return Instructions::null(); |
| +} |
| + |
| + |
| intptr_t SnapshotReader::LookupInternalClass(intptr_t class_header) { |
| // If the header is an object Id, lookup singleton VM classes or classes |
| // stored in the object store. |
| @@ -1089,6 +1122,9 @@ RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) { |
| if (object_id == kSentinelObject) { |
| return Object::sentinel().raw(); |
| } |
| + if (object_id == kTransitionSentinelObject) { |
| + return Object::transition_sentinel().raw(); |
| + } |
| if (object_id == kEmptyArrayObject) { |
| return Object::empty_array().raw(); |
| } |
| @@ -1353,7 +1389,8 @@ SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, |
| ReAlloc alloc, |
| intptr_t initial_size, |
| ForwardList* forward_list, |
| - bool can_send_any_object) |
| + bool can_send_any_object, |
| + bool snapshot_code) |
| : BaseWriter(buffer, alloc, initial_size), |
| kind_(kind), |
| isolate_(Isolate::Current()), |
| @@ -1363,7 +1400,8 @@ SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, |
| exception_type_(Exceptions::kNone), |
| exception_msg_(NULL), |
| unmarked_objects_(false), |
| - can_send_any_object_(can_send_any_object) { |
| + can_send_any_object_(can_send_any_object), |
| + snapshot_code_(snapshot_code) { |
| ASSERT(forward_list_ != NULL); |
| } |
| @@ -1400,6 +1438,12 @@ void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { |
| return; |
| } |
| + // Check if it is a singleton sentinel object. |
| + if (rawobj == Object::transition_sentinel().raw()) { |
| + WriteVMIsolateObject(kTransitionSentinelObject); |
| + return; |
| + } |
| + |
| // Check if it is a singleton empty array object. |
| if (rawobj == Object::empty_array().raw()) { |
| WriteVMIsolateObject(kEmptyArrayObject); |
| @@ -1486,7 +1530,9 @@ void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { |
| } |
| } |
| } |
| - UNREACHABLE(); |
| + |
| + const Object& obj = Object::Handle(rawobj); |
| + FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString()); |
| } |
| #undef VM_OBJECT_WRITE |
| @@ -1531,7 +1577,8 @@ class ScriptVisitor : public ObjectVisitor { |
| FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
| uint8_t** isolate_snapshot_buffer, |
| - ReAlloc alloc) |
| + ReAlloc alloc, |
| + bool snapshot_code) |
| : isolate_(Isolate::Current()), |
| vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer), |
| isolate_snapshot_buffer_(isolate_snapshot_buffer), |
| @@ -1540,7 +1587,8 @@ FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
| isolate_snapshot_size_(0), |
| forward_list_(NULL), |
| scripts_(Array::Handle(isolate_)), |
| - symbol_table_(Array::Handle(isolate_)) { |
| + symbol_table_(Array::Handle(isolate_)), |
| + snapshot_code_(snapshot_code) { |
| ASSERT(isolate_snapshot_buffer_ != NULL); |
| ASSERT(alloc_ != NULL); |
| ASSERT(isolate_ != NULL); |
| @@ -1591,7 +1639,8 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() { |
| alloc_, |
| kInitialSize, |
| forward_list_, |
| - true); // Can send any kind of object. |
| + true, /* can_send_any_object */ |
| + snapshot_code_); |
| // Write full snapshot for the VM isolate. |
| // Setup for long jump in case there is an exception while writing |
| // the snapshot. |
| @@ -1635,7 +1684,8 @@ void FullSnapshotWriter::WriteIsolateFullSnapshot() { |
| alloc_, |
| kInitialSize, |
| forward_list_, |
| - true); |
| + true, /* can_send_any_object */ |
| + snapshot_code_); |
| ObjectStore* object_store = isolate_->object_store(); |
| ASSERT(object_store != NULL); |
| @@ -1678,6 +1728,20 @@ void FullSnapshotWriter::WriteFullSnapshot() { |
| } |
| +PrecompiledSnapshotWriter::PrecompiledSnapshotWriter( |
| + uint8_t** vm_isolate_snapshot_buffer, |
| + uint8_t** isolate_snapshot_buffer, |
| + ReAlloc alloc) |
| + : FullSnapshotWriter(vm_isolate_snapshot_buffer, |
| + isolate_snapshot_buffer, |
| + alloc, |
| + true /* snapshot_code */) { |
| +} |
| + |
| + |
| +PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {} |
| + |
| + |
| uword SnapshotWriter::GetObjectTags(RawObject* raw) { |
| uword tags = raw->ptr()->tags_; |
| if (SerializedHeaderTag::decode(tags) == kObjectId) { |
| @@ -1808,7 +1872,7 @@ bool SnapshotWriter::CheckAndWritePredefinedObject(RawObject* rawobj) { |
| // Check if it is a code object in that case just write a Null object |
| // as we do not want code objects in the snapshot. |
| - if (cid == kCodeCid) { |
| + if (!snapshot_code() && cid == kCodeCid) { |
|
siva
2015/08/19 19:40:03
maybe
if ((cid == kCodeCid) && !snapshot_code()) {
rmacnak
2015/08/19 22:33:54
Done.
|
| WriteVMIsolateObject(kNullObject); |
| return true; |
| } |
| @@ -2318,6 +2382,12 @@ intptr_t SnapshotWriter::FirstObjectId() { |
| } |
| +int32_t GetInstructionsId(RawInstructions* instructions) { |
|
Florian Schneider
2015/08/18 11:54:14
Where is this function used?
There is already Sna
rmacnak
2015/08/19 22:33:54
Refactoring leftover - deleted.
|
| + // TODO(rmacnak): Keep list and write them to another buffer. |
| + return 0; |
| +} |
| + |
| + |
| ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, |
| ReAlloc alloc) |
| : SnapshotWriter(Snapshot::kScript, |
| @@ -2325,7 +2395,8 @@ ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, |
| alloc, |
| kInitialSize, |
| &forward_list_, |
| - true), |
| + true, /* can_send_any_object */ |
| + false /* snapshot_code */), |
| forward_list_(kMaxPredefinedObjectIds) { |
| ASSERT(buffer != NULL); |
| ASSERT(alloc != NULL); |
| @@ -2379,7 +2450,8 @@ MessageWriter::MessageWriter(uint8_t** buffer, |
| alloc, |
| kInitialSize, |
| &forward_list_, |
| - can_send_any_object), |
| + can_send_any_object, |
| + false /* snapshot_code */), |
| forward_list_(kMaxPredefinedObjectIds) { |
| ASSERT(buffer != NULL); |
| ASSERT(alloc != NULL); |