OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/clustered_snapshot.h" | 5 #include "vm/clustered_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 4648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4659 ClassTable* table = isolate()->class_table(); | 4659 ClassTable* table = isolate()->class_table(); |
4660 for (intptr_t cid = kClassCid; cid < kInstanceCid; cid++) { | 4660 for (intptr_t cid = kClassCid; cid < kInstanceCid; cid++) { |
4661 // Error has no class object. | 4661 // Error has no class object. |
4662 if (cid != kErrorCid) { | 4662 if (cid != kErrorCid) { |
4663 ASSERT(table->HasValidClassAt(cid)); | 4663 ASSERT(table->HasValidClassAt(cid)); |
4664 AddBaseObject(table->At(cid)); | 4664 AddBaseObject(table->At(cid)); |
4665 } | 4665 } |
4666 } | 4666 } |
4667 AddBaseObject(table->At(kDynamicCid)); | 4667 AddBaseObject(table->At(kDynamicCid)); |
4668 AddBaseObject(table->At(kVoidCid)); | 4668 AddBaseObject(table->At(kVoidCid)); |
| 4669 |
| 4670 if (kind_ != Snapshot::kAppAOT) { |
| 4671 for (intptr_t i = 0; i < StubCode::NumEntries(); i++) { |
| 4672 AddBaseObject(StubCode::EntryAt(i)->code()); |
| 4673 } |
| 4674 } |
4669 } | 4675 } |
4670 | 4676 |
4671 | 4677 |
4672 intptr_t Serializer::WriteVMSnapshot(const Array& symbols, | 4678 intptr_t Serializer::WriteVMSnapshot(const Array& symbols, |
4673 const Array& scripts) { | 4679 const Array& scripts) { |
4674 NoSafepointScope no_safepoint; | 4680 NoSafepointScope no_safepoint; |
4675 | 4681 |
4676 AddVMIsolateBaseObjects(); | 4682 AddVMIsolateBaseObjects(); |
4677 | 4683 |
4678 // Push roots. | 4684 // Push roots. |
4679 Push(symbols.raw()); | 4685 Push(symbols.raw()); |
4680 Push(scripts.raw()); | 4686 Push(scripts.raw()); |
4681 if (Snapshot::IncludesCode(kind_)) { | 4687 if (Snapshot::IncludesCode(kind_)) { |
4682 StubCode::Push(this); | 4688 for (intptr_t i = 0; i < StubCode::NumEntries(); i++) { |
| 4689 Push(StubCode::EntryAt(i)->code()); |
| 4690 } |
4683 } | 4691 } |
4684 | 4692 |
4685 Serialize(); | 4693 Serialize(); |
4686 | 4694 |
4687 // Write roots. | 4695 // Write roots. |
4688 WriteRef(symbols.raw()); | 4696 WriteRef(symbols.raw()); |
4689 WriteRef(scripts.raw()); | 4697 WriteRef(scripts.raw()); |
4690 if (Snapshot::IncludesCode(kind_)) { | 4698 if (Snapshot::IncludesCode(kind_)) { |
4691 StubCode::WriteRef(this); | 4699 for (intptr_t i = 0; i < StubCode::NumEntries(); i++) { |
| 4700 WriteRef(StubCode::EntryAt(i)->code()); |
| 4701 } |
4692 } | 4702 } |
4693 | 4703 |
4694 #if defined(DEBUG) | 4704 #if defined(DEBUG) |
4695 Write<int32_t>(kSectionMarker); | 4705 Write<int32_t>(kSectionMarker); |
4696 #endif | 4706 #endif |
4697 | 4707 |
4698 // Note we are not clearing the object id table. The full ref table | 4708 // Note we are not clearing the object id table. The full ref table |
4699 // of the vm isolate snapshot serves as the base objects for the | 4709 // of the vm isolate snapshot serves as the base objects for the |
4700 // regular isolate snapshot. | 4710 // regular isolate snapshot. |
4701 | 4711 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5043 ClassTable* table = isolate()->class_table(); | 5053 ClassTable* table = isolate()->class_table(); |
5044 for (intptr_t cid = kClassCid; cid <= kUnwindErrorCid; cid++) { | 5054 for (intptr_t cid = kClassCid; cid <= kUnwindErrorCid; cid++) { |
5045 // Error has no class object. | 5055 // Error has no class object. |
5046 if (cid != kErrorCid) { | 5056 if (cid != kErrorCid) { |
5047 ASSERT(table->HasValidClassAt(cid)); | 5057 ASSERT(table->HasValidClassAt(cid)); |
5048 AddBaseObject(table->At(cid)); | 5058 AddBaseObject(table->At(cid)); |
5049 } | 5059 } |
5050 } | 5060 } |
5051 AddBaseObject(table->At(kDynamicCid)); | 5061 AddBaseObject(table->At(kDynamicCid)); |
5052 AddBaseObject(table->At(kVoidCid)); | 5062 AddBaseObject(table->At(kVoidCid)); |
| 5063 |
| 5064 if (kind_ != Snapshot::kAppAOT) { |
| 5065 for (intptr_t i = 0; i < StubCode::NumEntries(); i++) { |
| 5066 AddBaseObject(StubCode::EntryAt(i)->code()); |
| 5067 } |
| 5068 } |
5053 } | 5069 } |
5054 | 5070 |
5055 | 5071 |
5056 void Deserializer::ReadVMSnapshot() { | 5072 void Deserializer::ReadVMSnapshot() { |
5057 Array& symbol_table = Array::Handle(zone_); | 5073 Array& symbol_table = Array::Handle(zone_); |
5058 Array& refs = Array::Handle(zone_); | 5074 Array& refs = Array::Handle(zone_); |
5059 Prepare(); | 5075 Prepare(); |
5060 | 5076 |
5061 { | 5077 { |
5062 NoSafepointScope no_safepoint; | 5078 NoSafepointScope no_safepoint; |
5063 HeapLocker hl(thread(), heap_->old_space()); | 5079 HeapLocker hl(thread(), heap_->old_space()); |
5064 | 5080 |
5065 AddVMIsolateBaseObjects(); | 5081 AddVMIsolateBaseObjects(); |
5066 | 5082 |
5067 Deserialize(); | 5083 Deserialize(); |
5068 | 5084 |
5069 // Read roots. | 5085 // Read roots. |
5070 symbol_table ^= ReadRef(); | 5086 symbol_table ^= ReadRef(); |
5071 isolate()->object_store()->set_symbol_table(symbol_table); | 5087 isolate()->object_store()->set_symbol_table(symbol_table); |
5072 ReadRef(); // Script list. | 5088 ReadRef(); // Script list. |
5073 if (Snapshot::IncludesCode(kind_)) { | 5089 if (Snapshot::IncludesCode(kind_)) { |
5074 StubCode::ReadRef(this); | 5090 Code& code = Code::Handle(zone_); |
| 5091 for (intptr_t i = 0; i < StubCode::NumEntries(); i++) { |
| 5092 code ^= ReadRef(); |
| 5093 StubCode::EntryAtPut(i, new StubEntry(code)); |
| 5094 } |
5075 } | 5095 } |
5076 | 5096 |
5077 #if defined(DEBUG) | 5097 #if defined(DEBUG) |
5078 int32_t section_marker = Read<int32_t>(); | 5098 int32_t section_marker = Read<int32_t>(); |
5079 ASSERT(section_marker == kSectionMarker); | 5099 ASSERT(section_marker == kSectionMarker); |
5080 #endif | 5100 #endif |
5081 | 5101 |
5082 refs = refs_; | 5102 refs = refs_; |
5083 refs_ = NULL; | 5103 refs_ = NULL; |
5084 } | 5104 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5309 WriteIsolateFullSnapshot(num_base_objects); | 5329 WriteIsolateFullSnapshot(num_base_objects); |
5310 | 5330 |
5311 if (FLAG_print_snapshot_sizes) { | 5331 if (FLAG_print_snapshot_sizes) { |
5312 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); | 5332 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); |
5313 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); | 5333 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); |
5314 } | 5334 } |
5315 intptr_t total_size = VmIsolateSnapshotSize() + IsolateSnapshotSize(); | 5335 intptr_t total_size = VmIsolateSnapshotSize() + IsolateSnapshotSize(); |
5316 | 5336 |
5317 if (Snapshot::IncludesCode(kind_)) { | 5337 if (Snapshot::IncludesCode(kind_)) { |
5318 instructions_writer_->Write( | 5338 instructions_writer_->Write( |
5319 *vm_isolate_snapshot_buffer_, vm_isolate_snapshot_size_, | 5339 vm_isolate_snapshot_buffer_ == NULL ? NULL |
5320 *isolate_snapshot_buffer_, isolate_snapshot_size_); | 5340 : *vm_isolate_snapshot_buffer_, |
| 5341 vm_isolate_snapshot_size_, *isolate_snapshot_buffer_, |
| 5342 isolate_snapshot_size_); |
5321 | 5343 |
5322 if (FLAG_print_snapshot_sizes) { | 5344 if (FLAG_print_snapshot_sizes) { |
5323 OS::Print("ReadOnlyData(CodeSize): %" Pd "\n", | 5345 OS::Print("ReadOnlyData(CodeSize): %" Pd "\n", |
5324 instructions_writer_->data_size()); | 5346 instructions_writer_->data_size()); |
5325 OS::Print("Instructions(CodeSize): %" Pd "\n", | 5347 OS::Print("Instructions(CodeSize): %" Pd "\n", |
5326 instructions_writer_->text_size()); | 5348 instructions_writer_->text_size()); |
5327 } | 5349 } |
5328 total_size += | 5350 total_size += |
5329 instructions_writer_->data_size() + instructions_writer_->text_size(); | 5351 instructions_writer_->data_size() + instructions_writer_->text_size(); |
5330 } | 5352 } |
(...skipping 30 matching lines...) Expand all Loading... |
5361 | 5383 |
5362 deserializer.ReadVMSnapshot(); | 5384 deserializer.ReadVMSnapshot(); |
5363 | 5385 |
5364 Dart::set_instructions_snapshot_buffer(instructions_buffer_); | 5386 Dart::set_instructions_snapshot_buffer(instructions_buffer_); |
5365 Dart::set_data_snapshot_buffer(data_buffer_); | 5387 Dart::set_data_snapshot_buffer(data_buffer_); |
5366 | 5388 |
5367 return ApiError::null(); | 5389 return ApiError::null(); |
5368 } | 5390 } |
5369 | 5391 |
5370 } // namespace dart | 5392 } // namespace dart |
OLD | NEW |