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

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

Issue 2525623002: VM: [Kernel] Split kernel API into 3 steps: ([read binary], parse-binary, bootstrap, load program) (Closed)
Patch Set: addressed comments Created 4 years 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
« no previous file with comments | « runtime/vm/dart.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 Isolate* Dart::CreateIsolate(const char* name_prefix, 486 Isolate* Dart::CreateIsolate(const char* name_prefix,
487 const Dart_IsolateFlags& api_flags) { 487 const Dart_IsolateFlags& api_flags) {
488 // Create a new isolate. 488 // Create a new isolate.
489 Isolate* isolate = Isolate::Init(name_prefix, api_flags); 489 Isolate* isolate = Isolate::Init(name_prefix, api_flags);
490 return isolate; 490 return isolate;
491 } 491 }
492 492
493 493
494 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, 494 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer,
495 intptr_t snapshot_length, 495 intptr_t snapshot_length,
496 bool from_kernel, 496 kernel::Program* kernel_program,
497 void* data) { 497 void* data) {
498 // Initialize the new isolate. 498 // Initialize the new isolate.
499 Thread* T = Thread::Current(); 499 Thread* T = Thread::Current();
500 Isolate* I = T->isolate(); 500 Isolate* I = T->isolate();
501 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), 501 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
502 "InitializeIsolate"); 502 "InitializeIsolate");
503 tds.SetNumArguments(1); 503 tds.SetNumArguments(1);
504 tds.CopyArgument(0, "isolateName", I->name());) 504 tds.CopyArgument(0, "isolateName", I->name());)
505 ASSERT(I != NULL); 505 ASSERT(I != NULL);
506 StackZone zone(T); 506 StackZone zone(T);
507 HandleScope handle_scope(T); 507 HandleScope handle_scope(T);
508 { 508 {
509 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), 509 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
510 "ObjectStore::Init")); 510 "ObjectStore::Init"));
511 ObjectStore::Init(I); 511 ObjectStore::Init(I);
512 } 512 }
513 513
514 Error& error = Error::Handle(T->zone()); 514 Error& error = Error::Handle(T->zone());
515 if (from_kernel) { 515 error = Object::Init(I, kernel_program);
516 ASSERT(snapshot_buffer != NULL);
517 ASSERT(snapshot_length > 0);
518 error = Object::Init(I, snapshot_buffer, snapshot_length);
519 } else {
520 error = Object::Init(I, NULL, -1);
521 }
522 if (!error.IsNull()) { 516 if (!error.IsNull()) {
523 return error.raw(); 517 return error.raw();
524 } 518 }
525 if ((snapshot_buffer != NULL) && !from_kernel) { 519 if ((snapshot_buffer != NULL) && kernel_program == NULL) {
526 // Read the snapshot and setup the initial state. 520 // Read the snapshot and setup the initial state.
527 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), 521 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
528 "IsolateSnapshotReader")); 522 "IsolateSnapshotReader"));
529 // TODO(turnidge): Remove once length is not part of the snapshot. 523 // TODO(turnidge): Remove once length is not part of the snapshot.
530 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); 524 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
531 if (snapshot == NULL) { 525 if (snapshot == NULL) {
532 const String& message = String::Handle(String::New("Invalid snapshot")); 526 const String& message = String::Handle(String::New("Invalid snapshot"));
533 return ApiError::New(message); 527 return ApiError::New(message);
534 } 528 }
535 if (snapshot->kind() != snapshot_kind_) { 529 if (snapshot->kind() != snapshot_kind_) {
(...skipping 20 matching lines...) Expand all
556 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); 550 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
557 tds.FormatArgument(1, "heapSize", "%" Pd64, 551 tds.FormatArgument(1, "heapSize", "%" Pd64,
558 I->heap()->UsedInWords(Heap::kOld) * kWordSize); 552 I->heap()->UsedInWords(Heap::kOld) * kWordSize);
559 } 553 }
560 #endif // !defined(PRODUCT) 554 #endif // !defined(PRODUCT)
561 if (FLAG_trace_isolates) { 555 if (FLAG_trace_isolates) {
562 I->heap()->PrintSizes(); 556 I->heap()->PrintSizes();
563 MegamorphicCacheTable::PrintSizes(I); 557 MegamorphicCacheTable::PrintSizes(I);
564 } 558 }
565 } else { 559 } else {
566 if ((snapshot_kind_ != Snapshot::kNone) && !from_kernel) { 560 if ((snapshot_kind_ != Snapshot::kNone) && kernel_program == NULL) {
567 const String& message = 561 const String& message =
568 String::Handle(String::New("Missing isolate snapshot")); 562 String::Handle(String::New("Missing isolate snapshot"));
569 return ApiError::New(message); 563 return ApiError::New(message);
570 } 564 }
571 } 565 }
572 566
573 Object::VerifyBuiltinVtables(); 567 Object::VerifyBuiltinVtables();
574 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); 568 DEBUG_ONLY(I->heap()->Verify(kForbidMarked));
575 569
576 { 570 {
577 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), 571 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
578 "StubCode::Init")); 572 "StubCode::Init"));
579 StubCode::Init(I); 573 StubCode::Init(I);
580 } 574 }
581 575
582 #if !defined(DART_PRECOMPILED_RUNTIME) 576 #if !defined(DART_PRECOMPILED_RUNTIME)
583 // When running precompiled, the megamorphic miss function/code comes from the 577 // When running precompiled, the megamorphic miss function/code comes from the
584 // snapshot. 578 // snapshot.
585 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { 579 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) {
586 MegamorphicCacheTable::InitMissHandler(I); 580 MegamorphicCacheTable::InitMissHandler(I);
587 } 581 }
588 #endif 582 #endif
589 583
590 const Code& miss_code = 584 const Code& miss_code =
591 Code::Handle(I->object_store()->megamorphic_miss_code()); 585 Code::Handle(I->object_store()->megamorphic_miss_code());
592 I->set_ic_miss_code(miss_code); 586 I->set_ic_miss_code(miss_code);
593 587
594 if ((snapshot_buffer == NULL) || from_kernel) { 588 if ((snapshot_buffer == NULL) || (kernel_program != NULL)) {
595 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); 589 const Error& error = Error::Handle(I->object_store()->PreallocateObjects());
596 if (!error.IsNull()) { 590 if (!error.IsNull()) {
597 return error.raw(); 591 return error.raw();
598 } 592 }
599 } 593 }
600 594
601 I->heap()->InitGrowthControl(); 595 I->heap()->InitGrowthControl();
602 I->set_init_callback_data(data); 596 I->set_init_callback_data(data);
603 Api::SetupAcquiredError(I); 597 Api::SetupAcquiredError(I);
604 if (FLAG_print_class_table) { 598 if (FLAG_print_class_table) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return predefined_handles_->handles_.IsValidScopedHandle(address); 729 return predefined_handles_->handles_.IsValidScopedHandle(address);
736 } 730 }
737 731
738 732
739 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 733 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
740 ASSERT(predefined_handles_ != NULL); 734 ASSERT(predefined_handles_ != NULL);
741 return predefined_handles_->api_handles_.IsValidHandle(handle); 735 return predefined_handles_->api_handles_.IsValidHandle(handle);
742 } 736 }
743 737
744 } // namespace dart 738 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698