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

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

Issue 2485993002: VM: Support bootstrapping core libraries from Kernel binaries instead of source. (Closed)
Patch Set: Done Created 4 years, 1 month 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/become.h" 7 #include "vm/become.h"
8 #include "vm/clustered_snapshot.h" 8 #include "vm/clustered_snapshot.h"
9 #include "vm/code_observers.h" 9 #include "vm/code_observers.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 489
490 Isolate* Dart::CreateIsolate(const char* name_prefix, 490 Isolate* Dart::CreateIsolate(const char* name_prefix,
491 const Dart_IsolateFlags& api_flags) { 491 const Dart_IsolateFlags& api_flags) {
492 // Create a new isolate. 492 // Create a new isolate.
493 Isolate* isolate = Isolate::Init(name_prefix, api_flags); 493 Isolate* isolate = Isolate::Init(name_prefix, api_flags);
494 return isolate; 494 return isolate;
495 } 495 }
496 496
497 497
498 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { 498 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer,
499 intptr_t snapshot_length,
500 bool from_kernel,
501 void* data) {
499 // Initialize the new isolate. 502 // Initialize the new isolate.
500 Thread* T = Thread::Current(); 503 Thread* T = Thread::Current();
501 Isolate* I = T->isolate(); 504 Isolate* I = T->isolate();
502 NOT_IN_PRODUCT( 505 NOT_IN_PRODUCT(
503 TimelineDurationScope tds(T, 506 TimelineDurationScope tds(T,
504 Timeline::GetIsolateStream(), 507 Timeline::GetIsolateStream(),
505 "InitializeIsolate"); 508 "InitializeIsolate");
506 tds.SetNumArguments(1); 509 tds.SetNumArguments(1);
507 tds.CopyArgument(0, "isolateName", I->name()); 510 tds.CopyArgument(0, "isolateName", I->name());
508 ) 511 )
509 ASSERT(I != NULL); 512 ASSERT(I != NULL);
510 StackZone zone(T); 513 StackZone zone(T);
511 HandleScope handle_scope(T); 514 HandleScope handle_scope(T);
512 { 515 {
513 NOT_IN_PRODUCT(TimelineDurationScope tds(T, 516 NOT_IN_PRODUCT(TimelineDurationScope tds(T,
514 Timeline::GetIsolateStream(), "ObjectStore::Init")); 517 Timeline::GetIsolateStream(), "ObjectStore::Init"));
515 ObjectStore::Init(I); 518 ObjectStore::Init(I);
516 } 519 }
517 520
518 const Error& error = Error::Handle(Object::Init(I)); 521 Error& error = Error::Handle(T->zone());
522 if (from_kernel) {
523 ASSERT(snapshot_buffer != NULL);
524 ASSERT(snapshot_length > 0);
525 error = Object::Init(I, snapshot_buffer, snapshot_length);
526 } else {
527 error = Object::Init(I, NULL, -1);
528 }
519 if (!error.IsNull()) { 529 if (!error.IsNull()) {
520 return error.raw(); 530 return error.raw();
521 } 531 }
522 if (snapshot_buffer != NULL) { 532 if ((snapshot_buffer != NULL) && !from_kernel) {
523 // Read the snapshot and setup the initial state. 533 // Read the snapshot and setup the initial state.
524 NOT_IN_PRODUCT(TimelineDurationScope tds(T, 534 NOT_IN_PRODUCT(TimelineDurationScope tds(T,
525 Timeline::GetIsolateStream(), "IsolateSnapshotReader")); 535 Timeline::GetIsolateStream(), "IsolateSnapshotReader"));
526 // TODO(turnidge): Remove once length is not part of the snapshot. 536 // TODO(turnidge): Remove once length is not part of the snapshot.
527 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); 537 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
528 if (snapshot == NULL) { 538 if (snapshot == NULL) {
529 const String& message = String::Handle( 539 const String& message = String::Handle(
530 String::New("Invalid snapshot")); 540 String::New("Invalid snapshot"));
531 return ApiError::New(message); 541 return ApiError::New(message);
532 } 542 }
(...skipping 16 matching lines...) Expand all
549 tds.SetNumArguments(2); 559 tds.SetNumArguments(2);
550 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); 560 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
551 tds.FormatArgument(1, "heapSize", "%" Pd64, 561 tds.FormatArgument(1, "heapSize", "%" Pd64,
552 I->heap()->UsedInWords(Heap::kOld) * kWordSize); 562 I->heap()->UsedInWords(Heap::kOld) * kWordSize);
553 }); 563 });
554 if (FLAG_trace_isolates) { 564 if (FLAG_trace_isolates) {
555 I->heap()->PrintSizes(); 565 I->heap()->PrintSizes();
556 MegamorphicCacheTable::PrintSizes(I); 566 MegamorphicCacheTable::PrintSizes(I);
557 } 567 }
558 } else { 568 } else {
559 if (snapshot_kind_ != Snapshot::kNone) { 569 if ((snapshot_kind_ != Snapshot::kNone) && !from_kernel) {
560 const String& message = String::Handle( 570 const String& message = String::Handle(
561 String::New("Missing isolate snapshot")); 571 String::New("Missing isolate snapshot"));
562 return ApiError::New(message); 572 return ApiError::New(message);
563 } 573 }
564 } 574 }
565 575
566 Object::VerifyBuiltinVtables(); 576 Object::VerifyBuiltinVtables();
567 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); 577 DEBUG_ONLY(I->heap()->Verify(kForbidMarked));
568 578
569 { 579 {
570 NOT_IN_PRODUCT(TimelineDurationScope tds(T, 580 NOT_IN_PRODUCT(TimelineDurationScope tds(T,
571 Timeline::GetIsolateStream(), "StubCode::Init")); 581 Timeline::GetIsolateStream(), "StubCode::Init"));
572 StubCode::Init(I); 582 StubCode::Init(I);
573 } 583 }
574 584
575 #if !defined(DART_PRECOMPILED_RUNTIME) 585 #if !defined(DART_PRECOMPILED_RUNTIME)
576 // When running precompiled, the megamorphic miss function/code comes from the 586 // When running precompiled, the megamorphic miss function/code comes from the
577 // snapshot. 587 // snapshot.
578 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { 588 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) {
579 MegamorphicCacheTable::InitMissHandler(I); 589 MegamorphicCacheTable::InitMissHandler(I);
580 } 590 }
581 #endif 591 #endif
582 592
583 const Code& miss_code = 593 const Code& miss_code =
584 Code::Handle(I->object_store()->megamorphic_miss_code()); 594 Code::Handle(I->object_store()->megamorphic_miss_code());
585 I->set_ic_miss_code(miss_code); 595 I->set_ic_miss_code(miss_code);
586 596
587 if (snapshot_buffer == NULL) { 597 if ((snapshot_buffer == NULL) || from_kernel) {
588 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); 598 const Error& error = Error::Handle(I->object_store()->PreallocateObjects());
589 if (!error.IsNull()) { 599 if (!error.IsNull()) {
590 return error.raw(); 600 return error.raw();
591 } 601 }
592 } 602 }
593 603
594 I->heap()->InitGrowthControl(); 604 I->heap()->InitGrowthControl();
595 I->set_init_callback_data(data); 605 I->set_init_callback_data(data);
596 Api::SetupAcquiredError(I); 606 Api::SetupAcquiredError(I);
597 if (FLAG_print_class_table) { 607 if (FLAG_print_class_table) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return predefined_handles_->handles_.IsValidScopedHandle(address); 739 return predefined_handles_->handles_.IsValidScopedHandle(address);
730 } 740 }
731 741
732 742
733 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 743 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
734 ASSERT(predefined_handles_ != NULL); 744 ASSERT(predefined_handles_ != NULL);
735 return predefined_handles_->api_handles_.IsValidHandle(handle); 745 return predefined_handles_->api_handles_.IsValidHandle(handle);
736 } 746 }
737 747
738 } // namespace dart 748 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698