Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 field_(Field::Handle(zone_)), | 191 field_(Field::Handle(zone_)), |
| 192 str_(String::Handle(zone_)), | 192 str_(String::Handle(zone_)), |
| 193 library_(Library::Handle(zone_)), | 193 library_(Library::Handle(zone_)), |
| 194 type_(AbstractType::Handle(zone_)), | 194 type_(AbstractType::Handle(zone_)), |
| 195 type_arguments_(TypeArguments::Handle(zone_)), | 195 type_arguments_(TypeArguments::Handle(zone_)), |
| 196 tokens_(Array::Handle(zone_)), | 196 tokens_(Array::Handle(zone_)), |
| 197 stream_(TokenStream::Handle(zone_)), | 197 stream_(TokenStream::Handle(zone_)), |
| 198 data_(ExternalTypedData::Handle(zone_)), | 198 data_(ExternalTypedData::Handle(zone_)), |
| 199 typed_data_(TypedData::Handle(zone_)), | 199 typed_data_(TypedData::Handle(zone_)), |
| 200 code_(Code::Handle(zone_)), | 200 code_(Code::Handle(zone_)), |
| 201 function_(Function::Handle(zone_)), | |
| 202 megamorphic_cache_(MegamorphicCache::Handle(zone_)), | |
| 201 error_(UnhandledException::Handle(zone_)), | 203 error_(UnhandledException::Handle(zone_)), |
| 202 max_vm_isolate_object_id_( | 204 max_vm_isolate_object_id_( |
| 203 (kind == Snapshot::kFull) ? | 205 (kind == Snapshot::kFull) ? |
| 204 Object::vm_isolate_snapshot_object_table().Length() : 0), | 206 Object::vm_isolate_snapshot_object_table().Length() : 0), |
| 205 backward_references_(backward_refs), | 207 backward_references_(backward_refs), |
| 206 instructions_reader_(NULL) { | 208 instructions_reader_(NULL) { |
| 207 if (instructions_buffer != NULL) { | 209 if (instructions_buffer != NULL) { |
| 208 instructions_reader_ = new InstructionsReader(instructions_buffer); | 210 instructions_reader_ = new InstructionsReader(instructions_buffer); |
| 209 } | 211 } |
| 210 } | 212 } |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 // size for the full snapshot being read. | 659 // size for the full snapshot being read. |
| 658 { | 660 { |
| 659 NoSafepointScope no_safepoint; | 661 NoSafepointScope no_safepoint; |
| 660 HeapLocker hl(isolate, old_space()); | 662 HeapLocker hl(isolate, old_space()); |
| 661 | 663 |
| 662 // Read in all the objects stored in the object store. | 664 // Read in all the objects stored in the object store. |
| 663 intptr_t num_flds = (object_store->to() - object_store->from()); | 665 intptr_t num_flds = (object_store->to() - object_store->from()); |
| 664 for (intptr_t i = 0; i <= num_flds; i++) { | 666 for (intptr_t i = 0; i <= num_flds; i++) { |
| 665 *(object_store->from() + i) = ReadObjectImpl(kAsInlinedObject); | 667 *(object_store->from() + i) = ReadObjectImpl(kAsInlinedObject); |
| 666 } | 668 } |
| 669 if (snapshot_code_) { | |
| 670 isolate->megamorphic_cache_table()->ReadFrom(this); | |
| 671 } | |
| 667 for (intptr_t i = 0; i < backward_references_->length(); i++) { | 672 for (intptr_t i = 0; i < backward_references_->length(); i++) { |
| 668 if (!(*backward_references_)[i].is_deserialized()) { | 673 if (!(*backward_references_)[i].is_deserialized()) { |
| 669 ReadObjectImpl(kAsInlinedObject); | 674 ReadObjectImpl(kAsInlinedObject); |
| 670 (*backward_references_)[i].set_state(kIsDeserialized); | 675 (*backward_references_)[i].set_state(kIsDeserialized); |
| 671 } | 676 } |
| 672 } | 677 } |
| 673 | 678 |
| 674 // Validate the class table. | 679 // Validate the class table. |
| 675 #if defined(DEBUG) | 680 #if defined(DEBUG) |
| 676 isolate->ValidateClassTable(); | 681 isolate->ValidateClassTable(); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 // TODO(rmacnak): | 1539 // TODO(rmacnak): |
| 1535 // ArgumentsDescriptor::InitOnceFromSnapshot(i, *(ArrayHandle())); | 1540 // ArgumentsDescriptor::InitOnceFromSnapshot(i, *(ArrayHandle())); |
| 1536 } | 1541 } |
| 1537 | 1542 |
| 1538 ObjectPool::CheckedHandle(ReadObject()); // empty pool | 1543 ObjectPool::CheckedHandle(ReadObject()); // empty pool |
| 1539 PcDescriptors::CheckedHandle(ReadObject()); // empty pc desc | 1544 PcDescriptors::CheckedHandle(ReadObject()); // empty pc desc |
| 1540 LocalVarDescriptors::CheckedHandle(ReadObject()); // empty var desc | 1545 LocalVarDescriptors::CheckedHandle(ReadObject()); // empty var desc |
| 1541 ExceptionHandlers::CheckedHandle(ReadObject()); // empty exc handlers | 1546 ExceptionHandlers::CheckedHandle(ReadObject()); // empty exc handlers |
| 1542 | 1547 |
| 1543 #define READ_STUB(name) \ | 1548 #define READ_STUB(name) \ |
| 1544 *(CodeHandle()) ^= ReadObject(); | 1549 *(CodeHandle()) ^= ReadObject(); \ |
| 1545 // TODO(rmacnak): | 1550 StubCode::name##_entry_ = new StubEntry(*CodeHandle()); |
|
siva
2015/09/14 20:32:59
Instead of exposing the stub code macro order here
rmacnak
2015/09/15 17:56:42
Pushed to stub_code.cc and added TODO.
| |
| 1546 // StubCode::name##_entry()->InitOnceFromSnapshot(CodeHandle()) | |
| 1547 VM_STUB_CODE_LIST(READ_STUB); | 1551 VM_STUB_CODE_LIST(READ_STUB); |
| 1548 #undef READ_STUB | 1552 #undef READ_STUB |
| 1549 } | 1553 } |
| 1550 | 1554 |
| 1551 // Validate the class table. | 1555 // Validate the class table. |
| 1552 #if defined(DEBUG) | 1556 #if defined(DEBUG) |
| 1553 isolate->ValidateClassTable(); | 1557 isolate->ValidateClassTable(); |
| 1554 #endif | 1558 #endif |
| 1555 | 1559 |
| 1556 return ApiError::null(); | 1560 return ApiError::null(); |
| 1557 } | 1561 } |
| 1558 } | 1562 } |
| 1559 | 1563 |
| 1560 | 1564 |
| 1561 IsolateSnapshotReader::IsolateSnapshotReader(const uint8_t* buffer, | 1565 IsolateSnapshotReader::IsolateSnapshotReader(const uint8_t* buffer, |
| 1562 intptr_t size, | 1566 intptr_t size, |
| 1563 const uint8_t* instructions_buffer, | 1567 const uint8_t* instructions_buffer, |
| 1564 Thread* thread) | 1568 Thread* thread) |
| 1565 : SnapshotReader(buffer, | 1569 : SnapshotReader(buffer, |
| 1566 size, | 1570 size, |
| 1567 instructions_buffer, | 1571 instructions_buffer, |
| 1568 Snapshot::kFull, | 1572 Snapshot::kFull, |
| 1569 new ZoneGrowableArray<BackRefNode>( | 1573 new ZoneGrowableArray<BackRefNode>( |
| 1570 kNumInitialReferencesInFullSnapshot), | 1574 kNumInitialReferencesInFullSnapshot), |
| 1571 thread) { | 1575 thread) { |
| 1576 Isolate::Current()->set_compilation_allowed(instructions_buffer_ == NULL); | |
| 1572 } | 1577 } |
| 1573 | 1578 |
| 1574 | 1579 |
| 1575 IsolateSnapshotReader::~IsolateSnapshotReader() { | 1580 IsolateSnapshotReader::~IsolateSnapshotReader() { |
| 1576 ResetBackwardReferenceTable(); | 1581 ResetBackwardReferenceTable(); |
| 1577 } | 1582 } |
| 1578 | 1583 |
| 1579 | 1584 |
| 1580 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer, | 1585 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer, |
| 1581 intptr_t size, | 1586 intptr_t size, |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1989 // Write out the version string. | 1994 // Write out the version string. |
| 1990 writer.WriteVersion(); | 1995 writer.WriteVersion(); |
| 1991 | 1996 |
| 1992 // Write out the full snapshot. | 1997 // Write out the full snapshot. |
| 1993 | 1998 |
| 1994 // Write out all the objects in the object store of the isolate which | 1999 // Write out all the objects in the object store of the isolate which |
| 1995 // is the root set for all dart allocated objects at this point. | 2000 // is the root set for all dart allocated objects at this point. |
| 1996 SnapshotWriterVisitor visitor(&writer, false); | 2001 SnapshotWriterVisitor visitor(&writer, false); |
| 1997 object_store->VisitObjectPointers(&visitor); | 2002 object_store->VisitObjectPointers(&visitor); |
| 1998 | 2003 |
| 2004 if (snapshot_code_) { | |
| 2005 isolate_->megamorphic_cache_table()->WriteTo(&writer); | |
| 2006 } | |
|
siva
2015/09/14 20:32:59
Why do you order this in between the object_store
rmacnak
2015/09/15 17:56:42
Dropped.
| |
| 2007 | |
| 1999 // Write out all forwarded objects. | 2008 // Write out all forwarded objects. |
| 2000 writer.WriteForwardedObjects(); | 2009 writer.WriteForwardedObjects(); |
| 2001 | 2010 |
| 2002 writer.FillHeader(writer.kind()); | 2011 writer.FillHeader(writer.kind()); |
| 2003 writer.UnmarkAll(); | 2012 writer.UnmarkAll(); |
| 2004 | 2013 |
| 2005 isolate_snapshot_size_ = writer.BytesWritten(); | 2014 isolate_snapshot_size_ = writer.BytesWritten(); |
| 2006 } else { | 2015 } else { |
| 2007 writer.ThrowException(writer.exception_type(), writer.exception_msg()); | 2016 writer.ThrowException(writer.exception_type(), writer.exception_msg()); |
| 2008 } | 2017 } |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2784 NoSafepointScope no_safepoint; | 2793 NoSafepointScope no_safepoint; |
| 2785 WriteObject(obj.raw()); | 2794 WriteObject(obj.raw()); |
| 2786 UnmarkAll(); | 2795 UnmarkAll(); |
| 2787 } else { | 2796 } else { |
| 2788 ThrowException(exception_type(), exception_msg()); | 2797 ThrowException(exception_type(), exception_msg()); |
| 2789 } | 2798 } |
| 2790 } | 2799 } |
| 2791 | 2800 |
| 2792 | 2801 |
| 2793 } // namespace dart | 2802 } // namespace dart |
| OLD | NEW |