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

Side by Side Diff: runtime/vm/clustered_snapshot.cc

Issue 2654183002: Rename references to "external pages" as "snapshot pages" to avoid confusion with the kind of exter… (Closed)
Patch Set: image Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 4448 matching lines...) Expand 10 before | Expand all | Expand 10 after
4459 } 4459 }
4460 } 4460 }
4461 }; 4461 };
4462 4462
4463 4463
4464 Serializer::Serializer(Thread* thread, 4464 Serializer::Serializer(Thread* thread,
4465 Snapshot::Kind kind, 4465 Snapshot::Kind kind,
4466 uint8_t** buffer, 4466 uint8_t** buffer,
4467 ReAlloc alloc, 4467 ReAlloc alloc,
4468 intptr_t initial_size, 4468 intptr_t initial_size,
4469 InstructionsWriter* instructions_writer) 4469 ImageWriter* image_writer)
4470 : StackResource(thread), 4470 : StackResource(thread),
4471 heap_(thread->isolate()->heap()), 4471 heap_(thread->isolate()->heap()),
4472 zone_(thread->zone()), 4472 zone_(thread->zone()),
4473 kind_(kind), 4473 kind_(kind),
4474 stream_(buffer, alloc, initial_size), 4474 stream_(buffer, alloc, initial_size),
4475 instructions_writer_(instructions_writer), 4475 image_writer_(image_writer),
4476 clusters_by_cid_(NULL), 4476 clusters_by_cid_(NULL),
4477 stack_(), 4477 stack_(),
4478 num_cids_(0), 4478 num_cids_(0),
4479 num_base_objects_(0), 4479 num_base_objects_(0),
4480 num_written_objects_(0), 4480 num_written_objects_(0),
4481 next_ref_index_(1) { 4481 next_ref_index_(1) {
4482 num_cids_ = thread->isolate()->class_table()->NumCids(); 4482 num_cids_ = thread->isolate()->class_table()->NumCids();
4483 clusters_by_cid_ = new SerializationCluster*[num_cids_]; 4483 clusters_by_cid_ = new SerializationCluster*[num_cids_];
4484 for (intptr_t i = 0; i < num_cids_; i++) { 4484 for (intptr_t i = 0; i < num_cids_; i++) {
4485 clusters_by_cid_[i] = NULL; 4485 clusters_by_cid_[i] = NULL;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
5273 5273
5274 intptr_t count() const { return count_; } 5274 intptr_t count() const { return count_; }
5275 5275
5276 private: 5276 private:
5277 Object& objHandle_; 5277 Object& objHandle_;
5278 intptr_t count_; 5278 intptr_t count_;
5279 const Array* token_streams_; 5279 const Array* token_streams_;
5280 }; 5280 };
5281 5281
5282 5282
5283 FullSnapshotWriter::FullSnapshotWriter( 5283 FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
5284 Snapshot::Kind kind, 5284 uint8_t** vm_snapshot_data_buffer,
5285 uint8_t** vm_snapshot_data_buffer, 5285 uint8_t** isolate_snapshot_data_buffer,
5286 uint8_t** isolate_snapshot_data_buffer, 5286 ReAlloc alloc,
5287 ReAlloc alloc, 5287 ImageWriter* vm_image_writer,
5288 InstructionsWriter* vm_instructions_writer, 5288 ImageWriter* isolate_image_writer)
5289 InstructionsWriter* isolate_instructions_writer)
5290 : thread_(Thread::Current()), 5289 : thread_(Thread::Current()),
5291 kind_(kind), 5290 kind_(kind),
5292 vm_snapshot_data_buffer_(vm_snapshot_data_buffer), 5291 vm_snapshot_data_buffer_(vm_snapshot_data_buffer),
5293 isolate_snapshot_data_buffer_(isolate_snapshot_data_buffer), 5292 isolate_snapshot_data_buffer_(isolate_snapshot_data_buffer),
5294 alloc_(alloc), 5293 alloc_(alloc),
5295 vm_isolate_snapshot_size_(0), 5294 vm_isolate_snapshot_size_(0),
5296 isolate_snapshot_size_(0), 5295 isolate_snapshot_size_(0),
5297 vm_instructions_writer_(vm_instructions_writer), 5296 vm_image_writer_(vm_image_writer),
5298 isolate_instructions_writer_(isolate_instructions_writer), 5297 isolate_image_writer_(isolate_image_writer),
5299 token_streams_(Array::Handle(zone())), 5298 token_streams_(Array::Handle(zone())),
5300 saved_symbol_table_(Array::Handle(zone())), 5299 saved_symbol_table_(Array::Handle(zone())),
5301 new_vm_symbol_table_(Array::Handle(zone())), 5300 new_vm_symbol_table_(Array::Handle(zone())),
5302 clustered_vm_size_(0), 5301 clustered_vm_size_(0),
5303 clustered_isolate_size_(0), 5302 clustered_isolate_size_(0),
5304 mapped_data_size_(0), 5303 mapped_data_size_(0),
5305 mapped_instructions_size_(0) { 5304 mapped_instructions_size_(0) {
5306 ASSERT(isolate_snapshot_data_buffer_ != NULL); 5305 ASSERT(isolate_snapshot_data_buffer_ != NULL);
5307 ASSERT(alloc_ != NULL); 5306 ASSERT(alloc_ != NULL);
5308 ASSERT(isolate() != NULL); 5307 ASSERT(isolate() != NULL);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5362 token_streams_ = Array::null(); 5361 token_streams_ = Array::null();
5363 } 5362 }
5364 5363
5365 5364
5366 intptr_t FullSnapshotWriter::WriteVMSnapshot() { 5365 intptr_t FullSnapshotWriter::WriteVMSnapshot() {
5367 NOT_IN_PRODUCT(TimelineDurationScope tds( 5366 NOT_IN_PRODUCT(TimelineDurationScope tds(
5368 thread(), Timeline::GetIsolateStream(), "WriteVMSnapshot")); 5367 thread(), Timeline::GetIsolateStream(), "WriteVMSnapshot"));
5369 5368
5370 ASSERT(vm_snapshot_data_buffer_ != NULL); 5369 ASSERT(vm_snapshot_data_buffer_ != NULL);
5371 Serializer serializer(thread(), kind_, vm_snapshot_data_buffer_, alloc_, 5370 Serializer serializer(thread(), kind_, vm_snapshot_data_buffer_, alloc_,
5372 kInitialSize, vm_instructions_writer_); 5371 kInitialSize, vm_image_writer_);
5373 5372
5374 serializer.ReserveHeader(); 5373 serializer.ReserveHeader();
5375 serializer.WriteVersionAndFeatures(); 5374 serializer.WriteVersionAndFeatures();
5376 // VM snapshot roots are: 5375 // VM snapshot roots are:
5377 // - the symbol table 5376 // - the symbol table
5378 // - all the token streams 5377 // - all the token streams
5379 // - the stub code (precompiled snapshots only) 5378 // - the stub code (precompiled snapshots only)
5380 intptr_t num_objects = 5379 intptr_t num_objects =
5381 serializer.WriteVMSnapshot(new_vm_symbol_table_, token_streams_); 5380 serializer.WriteVMSnapshot(new_vm_symbol_table_, token_streams_);
5382 serializer.FillHeader(serializer.kind()); 5381 serializer.FillHeader(serializer.kind());
5383 clustered_vm_size_ = serializer.bytes_written(); 5382 clustered_vm_size_ = serializer.bytes_written();
5384 5383
5385 if (Snapshot::IncludesCode(kind_)) { 5384 if (Snapshot::IncludesCode(kind_)) {
5386 vm_instructions_writer_->Write(serializer.stream(), true); 5385 vm_image_writer_->Write(serializer.stream(), true);
5387 mapped_data_size_ += vm_instructions_writer_->data_size(); 5386 mapped_data_size_ += vm_image_writer_->data_size();
5388 mapped_instructions_size_ += vm_instructions_writer_->text_size(); 5387 mapped_instructions_size_ += vm_image_writer_->text_size();
5389 vm_instructions_writer_->ResetOffsets(); 5388 vm_image_writer_->ResetOffsets();
5390 } 5389 }
5391 5390
5392 // The clustered part + the direct mapped data part. 5391 // The clustered part + the direct mapped data part.
5393 vm_isolate_snapshot_size_ = serializer.bytes_written(); 5392 vm_isolate_snapshot_size_ = serializer.bytes_written();
5394 return num_objects; 5393 return num_objects;
5395 } 5394 }
5396 5395
5397 5396
5398 void FullSnapshotWriter::WriteIsolateSnapshot(intptr_t num_base_objects) { 5397 void FullSnapshotWriter::WriteIsolateSnapshot(intptr_t num_base_objects) {
5399 NOT_IN_PRODUCT(TimelineDurationScope tds( 5398 NOT_IN_PRODUCT(TimelineDurationScope tds(
5400 thread(), Timeline::GetIsolateStream(), "WriteIsolateSnapshot")); 5399 thread(), Timeline::GetIsolateStream(), "WriteIsolateSnapshot"));
5401 5400
5402 Serializer serializer(thread(), kind_, isolate_snapshot_data_buffer_, alloc_, 5401 Serializer serializer(thread(), kind_, isolate_snapshot_data_buffer_, alloc_,
5403 kInitialSize, isolate_instructions_writer_); 5402 kInitialSize, isolate_image_writer_);
5404 ObjectStore* object_store = isolate()->object_store(); 5403 ObjectStore* object_store = isolate()->object_store();
5405 ASSERT(object_store != NULL); 5404 ASSERT(object_store != NULL);
5406 5405
5407 serializer.ReserveHeader(); 5406 serializer.ReserveHeader();
5408 serializer.WriteVersionAndFeatures(); 5407 serializer.WriteVersionAndFeatures();
5409 // Isolate snapshot roots are: 5408 // Isolate snapshot roots are:
5410 // - the object store 5409 // - the object store
5411 serializer.WriteIsolateSnapshot(num_base_objects, object_store); 5410 serializer.WriteIsolateSnapshot(num_base_objects, object_store);
5412 serializer.FillHeader(serializer.kind()); 5411 serializer.FillHeader(serializer.kind());
5413 clustered_isolate_size_ = serializer.bytes_written(); 5412 clustered_isolate_size_ = serializer.bytes_written();
5414 5413
5415 if (Snapshot::IncludesCode(kind_)) { 5414 if (Snapshot::IncludesCode(kind_)) {
5416 isolate_instructions_writer_->Write(serializer.stream(), false); 5415 isolate_image_writer_->Write(serializer.stream(), false);
5417 mapped_data_size_ += isolate_instructions_writer_->data_size(); 5416 mapped_data_size_ += isolate_image_writer_->data_size();
5418 mapped_instructions_size_ += isolate_instructions_writer_->text_size(); 5417 mapped_instructions_size_ += isolate_image_writer_->text_size();
5419 isolate_instructions_writer_->ResetOffsets(); 5418 isolate_image_writer_->ResetOffsets();
5420 } 5419 }
5421 5420
5422 // The clustered part + the direct mapped data part. 5421 // The clustered part + the direct mapped data part.
5423 isolate_snapshot_size_ = serializer.bytes_written(); 5422 isolate_snapshot_size_ = serializer.bytes_written();
5424 } 5423 }
5425 5424
5426 5425
5427 void FullSnapshotWriter::WriteFullSnapshot() { 5426 void FullSnapshotWriter::WriteFullSnapshot() {
5428 intptr_t num_base_objects; 5427 intptr_t num_base_objects;
5429 if (vm_snapshot_data_buffer() != NULL) { 5428 if (vm_snapshot_data_buffer() != NULL) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5474 Deserializer deserializer(thread_, kind_, buffer_, size_, 5473 Deserializer deserializer(thread_, kind_, buffer_, size_,
5475 instructions_buffer_, data_buffer_); 5474 instructions_buffer_, data_buffer_);
5476 5475
5477 RawApiError* error = deserializer.VerifyVersionAndFeatures(); 5476 RawApiError* error = deserializer.VerifyVersionAndFeatures();
5478 if (error != ApiError::null()) { 5477 if (error != ApiError::null()) {
5479 return error; 5478 return error;
5480 } 5479 }
5481 5480
5482 if (Snapshot::IncludesCode(kind_)) { 5481 if (Snapshot::IncludesCode(kind_)) {
5483 ASSERT(instructions_buffer_ != NULL); 5482 ASSERT(instructions_buffer_ != NULL);
5484 thread_->isolate()->SetupInstructionsSnapshotPage(instructions_buffer_); 5483 thread_->isolate()->SetupImagePage(instructions_buffer_,
5484 /* is_executable */ true);
5485 ASSERT(data_buffer_ != NULL); 5485 ASSERT(data_buffer_ != NULL);
5486 thread_->isolate()->SetupDataSnapshotPage(data_buffer_); 5486 thread_->isolate()->SetupImagePage(data_buffer_,
5487 /* is_executable */ false);
5487 } 5488 }
5488 5489
5489 deserializer.ReadVMSnapshot(); 5490 deserializer.ReadVMSnapshot();
5490 5491
5491 return ApiError::null(); 5492 return ApiError::null();
5492 } 5493 }
5493 5494
5494 5495
5495 RawApiError* FullSnapshotReader::ReadIsolateSnapshot() { 5496 RawApiError* FullSnapshotReader::ReadIsolateSnapshot() {
5496 Deserializer deserializer(thread_, kind_, buffer_, size_, 5497 Deserializer deserializer(thread_, kind_, buffer_, size_,
5497 instructions_buffer_, data_buffer_); 5498 instructions_buffer_, data_buffer_);
5498 5499
5499 RawApiError* error = deserializer.VerifyVersionAndFeatures(); 5500 RawApiError* error = deserializer.VerifyVersionAndFeatures();
5500 if (error != ApiError::null()) { 5501 if (error != ApiError::null()) {
5501 return error; 5502 return error;
5502 } 5503 }
5503 5504
5504 if (Snapshot::IncludesCode(kind_)) { 5505 if (Snapshot::IncludesCode(kind_)) {
5505 ASSERT(instructions_buffer_ != NULL); 5506 ASSERT(instructions_buffer_ != NULL);
5506 thread_->isolate()->SetupInstructionsSnapshotPage(instructions_buffer_); 5507 thread_->isolate()->SetupImagePage(instructions_buffer_,
5508 /* is_executable */ true);
5507 ASSERT(data_buffer_ != NULL); 5509 ASSERT(data_buffer_ != NULL);
5508 thread_->isolate()->SetupDataSnapshotPage(data_buffer_); 5510 thread_->isolate()->SetupImagePage(data_buffer_,
5511 /* is_executable */ false);
5509 } 5512 }
5510 5513
5511 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store()); 5514 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store());
5512 5515
5513 return ApiError::null(); 5516 return ApiError::null();
5514 } 5517 }
5515 5518
5516 } // namespace dart 5519 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698