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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 484 |
485 | 485 |
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, void* data) { | 494 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, |
| 495 intptr_t snapshot_length, |
| 496 bool from_kernel, |
| 497 void* data) { |
495 // Initialize the new isolate. | 498 // Initialize the new isolate. |
496 Thread* T = Thread::Current(); | 499 Thread* T = Thread::Current(); |
497 Isolate* I = T->isolate(); | 500 Isolate* I = T->isolate(); |
498 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 501 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
499 "InitializeIsolate"); | 502 "InitializeIsolate"); |
500 tds.SetNumArguments(1); | 503 tds.SetNumArguments(1); |
501 tds.CopyArgument(0, "isolateName", I->name());) | 504 tds.CopyArgument(0, "isolateName", I->name());) |
502 ASSERT(I != NULL); | 505 ASSERT(I != NULL); |
503 StackZone zone(T); | 506 StackZone zone(T); |
504 HandleScope handle_scope(T); | 507 HandleScope handle_scope(T); |
505 { | 508 { |
506 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 509 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
507 "ObjectStore::Init")); | 510 "ObjectStore::Init")); |
508 ObjectStore::Init(I); | 511 ObjectStore::Init(I); |
509 } | 512 } |
510 | 513 |
511 const Error& error = Error::Handle(Object::Init(I)); | 514 Error& error = Error::Handle(T->zone()); |
| 515 if (from_kernel) { |
| 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 } |
512 if (!error.IsNull()) { | 522 if (!error.IsNull()) { |
513 return error.raw(); | 523 return error.raw(); |
514 } | 524 } |
515 if (snapshot_buffer != NULL) { | 525 if ((snapshot_buffer != NULL) && !from_kernel) { |
516 // Read the snapshot and setup the initial state. | 526 // Read the snapshot and setup the initial state. |
517 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 527 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
518 "IsolateSnapshotReader")); | 528 "IsolateSnapshotReader")); |
519 // TODO(turnidge): Remove once length is not part of the snapshot. | 529 // TODO(turnidge): Remove once length is not part of the snapshot. |
520 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 530 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
521 if (snapshot == NULL) { | 531 if (snapshot == NULL) { |
522 const String& message = String::Handle(String::New("Invalid snapshot")); | 532 const String& message = String::Handle(String::New("Invalid snapshot")); |
523 return ApiError::New(message); | 533 return ApiError::New(message); |
524 } | 534 } |
525 if (snapshot->kind() != snapshot_kind_) { | 535 if (snapshot->kind() != snapshot_kind_) { |
(...skipping 20 matching lines...) Expand all Loading... |
546 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); | 556 tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); |
547 tds.FormatArgument(1, "heapSize", "%" Pd64, | 557 tds.FormatArgument(1, "heapSize", "%" Pd64, |
548 I->heap()->UsedInWords(Heap::kOld) * kWordSize); | 558 I->heap()->UsedInWords(Heap::kOld) * kWordSize); |
549 } | 559 } |
550 #endif // !defined(PRODUCT) | 560 #endif // !defined(PRODUCT) |
551 if (FLAG_trace_isolates) { | 561 if (FLAG_trace_isolates) { |
552 I->heap()->PrintSizes(); | 562 I->heap()->PrintSizes(); |
553 MegamorphicCacheTable::PrintSizes(I); | 563 MegamorphicCacheTable::PrintSizes(I); |
554 } | 564 } |
555 } else { | 565 } else { |
556 if (snapshot_kind_ != Snapshot::kNone) { | 566 if ((snapshot_kind_ != Snapshot::kNone) && !from_kernel) { |
557 const String& message = | 567 const String& message = |
558 String::Handle(String::New("Missing isolate snapshot")); | 568 String::Handle(String::New("Missing isolate snapshot")); |
559 return ApiError::New(message); | 569 return ApiError::New(message); |
560 } | 570 } |
561 } | 571 } |
562 | 572 |
563 Object::VerifyBuiltinVtables(); | 573 Object::VerifyBuiltinVtables(); |
564 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); | 574 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); |
565 | 575 |
566 { | 576 { |
567 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 577 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
568 "StubCode::Init")); | 578 "StubCode::Init")); |
569 StubCode::Init(I); | 579 StubCode::Init(I); |
570 } | 580 } |
571 | 581 |
572 #if !defined(DART_PRECOMPILED_RUNTIME) | 582 #if !defined(DART_PRECOMPILED_RUNTIME) |
573 // When running precompiled, the megamorphic miss function/code comes from the | 583 // When running precompiled, the megamorphic miss function/code comes from the |
574 // snapshot. | 584 // snapshot. |
575 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { | 585 if (!Snapshot::IncludesCode(Dart::snapshot_kind())) { |
576 MegamorphicCacheTable::InitMissHandler(I); | 586 MegamorphicCacheTable::InitMissHandler(I); |
577 } | 587 } |
578 #endif | 588 #endif |
579 | 589 |
580 const Code& miss_code = | 590 const Code& miss_code = |
581 Code::Handle(I->object_store()->megamorphic_miss_code()); | 591 Code::Handle(I->object_store()->megamorphic_miss_code()); |
582 I->set_ic_miss_code(miss_code); | 592 I->set_ic_miss_code(miss_code); |
583 | 593 |
584 if (snapshot_buffer == NULL) { | 594 if ((snapshot_buffer == NULL) || from_kernel) { |
585 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); | 595 const Error& error = Error::Handle(I->object_store()->PreallocateObjects()); |
586 if (!error.IsNull()) { | 596 if (!error.IsNull()) { |
587 return error.raw(); | 597 return error.raw(); |
588 } | 598 } |
589 } | 599 } |
590 | 600 |
591 I->heap()->InitGrowthControl(); | 601 I->heap()->InitGrowthControl(); |
592 I->set_init_callback_data(data); | 602 I->set_init_callback_data(data); |
593 Api::SetupAcquiredError(I); | 603 Api::SetupAcquiredError(I); |
594 if (FLAG_print_class_table) { | 604 if (FLAG_print_class_table) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 return predefined_handles_->handles_.IsValidScopedHandle(address); | 735 return predefined_handles_->handles_.IsValidScopedHandle(address); |
726 } | 736 } |
727 | 737 |
728 | 738 |
729 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 739 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
730 ASSERT(predefined_handles_ != NULL); | 740 ASSERT(predefined_handles_ != NULL); |
731 return predefined_handles_->api_handles_.IsValidHandle(handle); | 741 return predefined_handles_->api_handles_.IsValidHandle(handle); |
732 } | 742 } |
733 | 743 |
734 } // namespace dart | 744 } // namespace dart |
OLD | NEW |