| 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 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 | 1722 |
| 1723 #undef VM_OBJECT_WRITE | 1723 #undef VM_OBJECT_WRITE |
| 1724 | 1724 |
| 1725 | 1725 |
| 1726 // An object visitor which will iterate over all the script objects in the heap | 1726 // An object visitor which will iterate over all the script objects in the heap |
| 1727 // and either count them or collect them into an array. This is used during | 1727 // and either count them or collect them into an array. This is used during |
| 1728 // full snapshot generation of the VM isolate to write out all script | 1728 // full snapshot generation of the VM isolate to write out all script |
| 1729 // objects and their accompanying token streams. | 1729 // objects and their accompanying token streams. |
| 1730 class ScriptVisitor : public ObjectVisitor { | 1730 class ScriptVisitor : public ObjectVisitor { |
| 1731 public: | 1731 public: |
| 1732 explicit ScriptVisitor(Isolate* isolate) : | 1732 explicit ScriptVisitor(Thread* thread) : |
| 1733 ObjectVisitor(isolate), | 1733 ObjectVisitor(thread->isolate()), |
| 1734 objHandle_(Object::Handle(isolate->current_zone())), | 1734 objHandle_(Object::Handle(thread->zone())), |
| 1735 count_(0), | 1735 count_(0), |
| 1736 scripts_(NULL) {} | 1736 scripts_(NULL) {} |
| 1737 | 1737 |
| 1738 ScriptVisitor(Isolate* isolate, const Array* scripts) : | 1738 ScriptVisitor(Thread* thread, const Array* scripts) : |
| 1739 ObjectVisitor(isolate), | 1739 ObjectVisitor(thread->isolate()), |
| 1740 objHandle_(Object::Handle(isolate->current_zone())), | 1740 objHandle_(Object::Handle(thread->zone())), |
| 1741 count_(0), | 1741 count_(0), |
| 1742 scripts_(scripts) {} | 1742 scripts_(scripts) {} |
| 1743 | 1743 |
| 1744 void VisitObject(RawObject* obj) { | 1744 void VisitObject(RawObject* obj) { |
| 1745 if (obj->IsScript()) { | 1745 if (obj->IsScript()) { |
| 1746 if (scripts_ != NULL) { | 1746 if (scripts_ != NULL) { |
| 1747 objHandle_ = obj; | 1747 objHandle_ = obj; |
| 1748 scripts_->SetAt(count_, objHandle_); | 1748 scripts_->SetAt(count_, objHandle_); |
| 1749 } | 1749 } |
| 1750 count_ += 1; | 1750 count_ += 1; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 ASSERT(object_store != NULL); | 1790 ASSERT(object_store != NULL); |
| 1791 // Ensure the class table is valid. | 1791 // Ensure the class table is valid. |
| 1792 #if defined(DEBUG) | 1792 #if defined(DEBUG) |
| 1793 isolate()->ValidateClassTable(); | 1793 isolate()->ValidateClassTable(); |
| 1794 #endif | 1794 #endif |
| 1795 | 1795 |
| 1796 // Collect all the script objects and their accompanying token stream objects | 1796 // Collect all the script objects and their accompanying token stream objects |
| 1797 // into an array so that we can write it out as part of the VM isolate | 1797 // into an array so that we can write it out as part of the VM isolate |
| 1798 // snapshot. We first count the number of script objects, allocate an array | 1798 // snapshot. We first count the number of script objects, allocate an array |
| 1799 // and then fill it up with the script objects. | 1799 // and then fill it up with the script objects. |
| 1800 ScriptVisitor scripts_counter(isolate()); | 1800 ScriptVisitor scripts_counter(thread()); |
| 1801 heap()->IterateOldObjects(&scripts_counter); | 1801 heap()->IterateOldObjects(&scripts_counter); |
| 1802 intptr_t count = scripts_counter.count(); | 1802 intptr_t count = scripts_counter.count(); |
| 1803 scripts_ = Array::New(count, Heap::kOld); | 1803 scripts_ = Array::New(count, Heap::kOld); |
| 1804 ScriptVisitor script_visitor(isolate(), &scripts_); | 1804 ScriptVisitor script_visitor(thread(), &scripts_); |
| 1805 heap()->IterateOldObjects(&script_visitor); | 1805 heap()->IterateOldObjects(&script_visitor); |
| 1806 | 1806 |
| 1807 // Stash the symbol table away for writing and reading into the vm isolate, | 1807 // Stash the symbol table away for writing and reading into the vm isolate, |
| 1808 // and reset the symbol table for the regular isolate so that we do not | 1808 // and reset the symbol table for the regular isolate so that we do not |
| 1809 // write these symbols into the snapshot of a regular dart isolate. | 1809 // write these symbols into the snapshot of a regular dart isolate. |
| 1810 symbol_table_ = object_store->symbol_table(); | 1810 symbol_table_ = object_store->symbol_table(); |
| 1811 Symbols::SetupSymbolTable(isolate()); | 1811 Symbols::SetupSymbolTable(isolate()); |
| 1812 | 1812 |
| 1813 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); | 1813 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); |
| 1814 ASSERT(forward_list_ != NULL); | 1814 ASSERT(forward_list_ != NULL); |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2553 if (setjmp(*jump.Set()) == 0) { | 2553 if (setjmp(*jump.Set()) == 0) { |
| 2554 NoSafepointScope no_safepoint; | 2554 NoSafepointScope no_safepoint; |
| 2555 WriteObject(obj.raw()); | 2555 WriteObject(obj.raw()); |
| 2556 } else { | 2556 } else { |
| 2557 ThrowException(exception_type(), exception_msg()); | 2557 ThrowException(exception_type(), exception_msg()); |
| 2558 } | 2558 } |
| 2559 } | 2559 } |
| 2560 | 2560 |
| 2561 | 2561 |
| 2562 } // namespace dart | 2562 } // namespace dart |
| OLD | NEW |