OLD | NEW |
---|---|
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 Loading... | |
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 if (kernel_program != NULL) { |
Kevin Millikin (Google)
2016/11/22 15:51:17
Here you can just unconditionally call Object::Ini
kustermann
2016/11/23 08:31:46
Done.
| |
516 ASSERT(snapshot_buffer != NULL); | 516 error = Object::Init(I, kernel_program); |
517 ASSERT(snapshot_length > 0); | |
518 error = Object::Init(I, snapshot_buffer, snapshot_length); | |
519 } else { | 517 } else { |
520 error = Object::Init(I, NULL, -1); | 518 error = Object::Init(I, NULL); |
521 } | 519 } |
522 if (!error.IsNull()) { | 520 if (!error.IsNull()) { |
523 return error.raw(); | 521 return error.raw(); |
524 } | 522 } |
525 if ((snapshot_buffer != NULL) && !from_kernel) { | 523 if ((snapshot_buffer != NULL) && kernel_program == NULL) { |
526 // Read the snapshot and setup the initial state. | 524 // Read the snapshot and setup the initial state. |
527 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 525 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
528 "IsolateSnapshotReader")); | 526 "IsolateSnapshotReader")); |
529 // TODO(turnidge): Remove once length is not part of the snapshot. | 527 // TODO(turnidge): Remove once length is not part of the snapshot. |
530 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 528 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
531 if (snapshot == NULL) { | 529 if (snapshot == NULL) { |
532 const String& message = String::Handle(String::New("Invalid snapshot")); | 530 const String& message = String::Handle(String::New("Invalid snapshot")); |
533 return ApiError::New(message); | 531 return ApiError::New(message); |
534 } | 532 } |
535 if (snapshot->kind() != snapshot_kind_) { | 533 if (snapshot->kind() != snapshot_kind_) { |
(...skipping 20 matching lines...) Expand all Loading... | |
556 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); | 554 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); |
557 tds.FormatArgument(1, "heapSize", "%" Pd64, | 555 tds.FormatArgument(1, "heapSize", "%" Pd64, |
558 I->heap()->UsedInWords(Heap::kOld) * kWordSize); | 556 I->heap()->UsedInWords(Heap::kOld) * kWordSize); |
559 } | 557 } |
560 #endif // !defined(PRODUCT) | 558 #endif // !defined(PRODUCT) |
561 if (FLAG_trace_isolates) { | 559 if (FLAG_trace_isolates) { |
562 I->heap()->PrintSizes(); | 560 I->heap()->PrintSizes(); |
563 MegamorphicCacheTable::PrintSizes(I); | 561 MegamorphicCacheTable::PrintSizes(I); |
564 } | 562 } |
565 } else { | 563 } else { |
566 if ((snapshot_kind_ != Snapshot::kNone) && !from_kernel) { | 564 if ((snapshot_kind_ != Snapshot::kNone) && kernel_program == NULL) { |
567 const String& message = | 565 const String& message = |
568 String::Handle(String::New("Missing isolate snapshot")); | 566 String::Handle(String::New("Missing isolate snapshot")); |
569 return ApiError::New(message); | 567 return ApiError::New(message); |
570 } | 568 } |
571 } | 569 } |
572 | 570 |
573 Object::VerifyBuiltinVtables(); | 571 Object::VerifyBuiltinVtables(); |
574 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); | 572 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); |
575 | 573 |
576 { | 574 { |
577 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 575 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
578 "StubCode::Init")); | 576 "StubCode::Init")); |
579 StubCode::Init(I); | 577 StubCode::Init(I); |
580 } | 578 } |
581 | 579 |
582 #if !defined(DART_PRECOMPILED_RUNTIME) | 580 #if !defined(DART_PRECOMPILED_RUNTIME) |
583 // When running precompiled, the megamorphic miss function/code comes from the | 581 // When running precompiled, the megamorphic miss function/code comes from the |
584 // snapshot. | 582 // snapshot. |
585 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { | 583 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { |
586 MegamorphicCacheTable::InitMissHandler(I); | 584 MegamorphicCacheTable::InitMissHandler(I); |
587 } | 585 } |
588 #endif | 586 #endif |
589 | 587 |
590 const Code& miss_code = | 588 const Code& miss_code = |
591 Code::Handle(I->object_store()->megamorphic_miss_code()); | 589 Code::Handle(I->object_store()->megamorphic_miss_code()); |
592 I->set_ic_miss_code(miss_code); | 590 I->set_ic_miss_code(miss_code); |
593 | 591 |
594 if ((snapshot_buffer == NULL) || from_kernel) { | 592 if ((snapshot_buffer == NULL) || (kernel_program != NULL)) { |
595 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); | 593 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); |
596 if (!error.IsNull()) { | 594 if (!error.IsNull()) { |
597 return error.raw(); | 595 return error.raw(); |
598 } | 596 } |
599 } | 597 } |
600 | 598 |
601 I->heap()->InitGrowthControl(); | 599 I->heap()->InitGrowthControl(); |
602 I->set_init_callback_data(data); | 600 I->set_init_callback_data(data); |
603 Api::SetupAcquiredError(I); | 601 Api::SetupAcquiredError(I); |
604 if (FLAG_print_class_table) { | 602 if (FLAG_print_class_table) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 return predefined_handles_->handles_.IsValidScopedHandle(address); | 733 return predefined_handles_->handles_.IsValidScopedHandle(address); |
736 } | 734 } |
737 | 735 |
738 | 736 |
739 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 737 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
740 ASSERT(predefined_handles_ != NULL); | 738 ASSERT(predefined_handles_ != NULL); |
741 return predefined_handles_->api_handles_.IsValidHandle(handle); | 739 return predefined_handles_->api_handles_.IsValidHandle(handle); |
742 } | 740 } |
743 | 741 |
744 } // namespace dart | 742 } // namespace dart |
OLD | NEW |