| 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/code_observers.h" | 7 #include "vm/code_observers.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return "VM already initialized or flags not initialized."; | 92 return "VM already initialized or flags not initialized."; |
| 93 } | 93 } |
| 94 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); | 94 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); |
| 95 Isolate::SetEntropySourceCallback(entropy_source); | 95 Isolate::SetEntropySourceCallback(entropy_source); |
| 96 OS::InitOnce(); | 96 OS::InitOnce(); |
| 97 VirtualMemory::InitOnce(); | 97 VirtualMemory::InitOnce(); |
| 98 OSThread::InitOnce(); | 98 OSThread::InitOnce(); |
| 99 if (FLAG_support_timeline) { | 99 if (FLAG_support_timeline) { |
| 100 Timeline::InitOnce(); | 100 Timeline::InitOnce(); |
| 101 } | 101 } |
| 102 #ifndef PRODUCT | 102 NOT_IN_PRODUCT(TimelineDurationScope tds(Timeline::GetVMStream(), |
| 103 TimelineDurationScope tds(Timeline::GetVMStream(), | 103 "Dart::InitOnce")); |
| 104 "Dart::InitOnce"); | |
| 105 #endif | |
| 106 Isolate::InitOnce(); | 104 Isolate::InitOnce(); |
| 107 PortMap::InitOnce(); | 105 PortMap::InitOnce(); |
| 108 FreeListElement::InitOnce(); | 106 FreeListElement::InitOnce(); |
| 109 Api::InitOnce(); | 107 Api::InitOnce(); |
| 110 CodeObservers::InitOnce(); | 108 CodeObservers::InitOnce(); |
| 111 if (FLAG_profiler) { | 109 if (FLAG_profiler) { |
| 112 ThreadInterrupter::InitOnce(); | 110 ThreadInterrupter::InitOnce(); |
| 113 Profiler::InitOnce(); | 111 Profiler::InitOnce(); |
| 114 } | 112 } |
| 115 SemiSpace::InitOnce(); | 113 SemiSpace::InitOnce(); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Create a new isolate. | 384 // Create a new isolate. |
| 387 Isolate* isolate = Isolate::Init(name_prefix, api_flags); | 385 Isolate* isolate = Isolate::Init(name_prefix, api_flags); |
| 388 return isolate; | 386 return isolate; |
| 389 } | 387 } |
| 390 | 388 |
| 391 | 389 |
| 392 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 390 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 393 // Initialize the new isolate. | 391 // Initialize the new isolate. |
| 394 Thread* T = Thread::Current(); | 392 Thread* T = Thread::Current(); |
| 395 Isolate* I = T->isolate(); | 393 Isolate* I = T->isolate(); |
| 396 #ifndef PRODUCT | 394 NOT_IN_PRODUCT( |
| 397 TimelineDurationScope tds(T, I->GetIsolateStream(), "InitializeIsolate"); | 395 TimelineDurationScope tds(T, I->GetIsolateStream(), "InitializeIsolate"); |
| 398 tds.SetNumArguments(1); | 396 tds.SetNumArguments(1); |
| 399 tds.CopyArgument(0, "isolateName", I->name()); | 397 tds.CopyArgument(0, "isolateName", I->name()); |
| 400 #endif // !PRODUCT | 398 ) |
| 401 ASSERT(I != NULL); | 399 ASSERT(I != NULL); |
| 402 StackZone zone(T); | 400 StackZone zone(T); |
| 403 HandleScope handle_scope(T); | 401 HandleScope handle_scope(T); |
| 404 { | 402 { |
| 405 #ifndef PRODUCT | 403 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 406 TimelineDurationScope tds(T, I->GetIsolateStream(), "ObjectStore::Init"); | 404 I->GetIsolateStream(), "ObjectStore::Init")); |
| 407 #endif // !PRODUCT | |
| 408 ObjectStore::Init(I); | 405 ObjectStore::Init(I); |
| 409 } | 406 } |
| 410 | 407 |
| 411 const Error& error = Error::Handle(Object::Init(I)); | 408 const Error& error = Error::Handle(Object::Init(I)); |
| 412 if (!error.IsNull()) { | 409 if (!error.IsNull()) { |
| 413 return error.raw(); | 410 return error.raw(); |
| 414 } | 411 } |
| 415 if (snapshot_buffer != NULL) { | 412 if (snapshot_buffer != NULL) { |
| 416 // Read the snapshot and setup the initial state. | 413 // Read the snapshot and setup the initial state. |
| 417 #ifndef PRODUCT | 414 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 418 TimelineDurationScope tds( | 415 I->GetIsolateStream(), "IsolateSnapshotReader")); |
| 419 T, I->GetIsolateStream(), "IsolateSnapshotReader"); | |
| 420 #endif // !PRODUCT | |
| 421 // TODO(turnidge): Remove once length is not part of the snapshot. | 416 // TODO(turnidge): Remove once length is not part of the snapshot. |
| 422 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 417 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 423 if (snapshot == NULL) { | 418 if (snapshot == NULL) { |
| 424 const String& message = String::Handle( | 419 const String& message = String::Handle( |
| 425 String::New("Invalid snapshot.")); | 420 String::New("Invalid snapshot.")); |
| 426 return ApiError::New(message); | 421 return ApiError::New(message); |
| 427 } | 422 } |
| 428 ASSERT(snapshot->kind() == Snapshot::kFull); | 423 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 429 if (FLAG_trace_isolates) { | 424 if (FLAG_trace_isolates) { |
| 430 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); | 425 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 444 } | 439 } |
| 445 } else { | 440 } else { |
| 446 // Populate the isolate's symbol table with all symbols from the | 441 // Populate the isolate's symbol table with all symbols from the |
| 447 // VM isolate. We do this so that when we generate a full snapshot | 442 // VM isolate. We do this so that when we generate a full snapshot |
| 448 // for the isolate we have a unified symbol table that we can then | 443 // for the isolate we have a unified symbol table that we can then |
| 449 // read into the VM isolate. | 444 // read into the VM isolate. |
| 450 Symbols::AddPredefinedSymbolsToIsolate(); | 445 Symbols::AddPredefinedSymbolsToIsolate(); |
| 451 } | 446 } |
| 452 | 447 |
| 453 Object::VerifyBuiltinVtables(); | 448 Object::VerifyBuiltinVtables(); |
| 454 #if defined(DEBUG) | 449 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); |
| 455 I->heap()->Verify(kForbidMarked); | |
| 456 #endif | |
| 457 | 450 |
| 458 { | 451 { |
| 459 #ifndef PRODUCT | 452 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 460 TimelineDurationScope tds(T, I->GetIsolateStream(), "StubCode::Init"); | 453 I->GetIsolateStream(), "StubCode::Init")); |
| 461 #endif // !PRODUCT | |
| 462 StubCode::Init(I); | 454 StubCode::Init(I); |
| 463 } | 455 } |
| 464 | 456 |
| 465 // When running precompiled, the megamorphic miss function/code comes from the | 457 // When running precompiled, the megamorphic miss function/code comes from the |
| 466 // snapshot. | 458 // snapshot. |
| 467 if (!Dart::IsRunningPrecompiledCode()) { | 459 if (!Dart::IsRunningPrecompiledCode()) { |
| 468 MegamorphicCacheTable::InitMissHandler(I); | 460 MegamorphicCacheTable::InitMissHandler(I); |
| 469 } | 461 } |
| 470 const Code& miss_code = | 462 const Code& miss_code = |
| 471 Code::Handle(I->object_store()->megamorphic_miss_code()); | 463 Code::Handle(I->object_store()->megamorphic_miss_code()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 return predefined_handles_->handles_.IsValidScopedHandle(address); | 556 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 565 } | 557 } |
| 566 | 558 |
| 567 | 559 |
| 568 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 560 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 569 ASSERT(predefined_handles_ != NULL); | 561 ASSERT(predefined_handles_ != NULL); |
| 570 return predefined_handles_->api_handles_.IsValidHandle(handle); | 562 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 571 } | 563 } |
| 572 | 564 |
| 573 } // namespace dart | 565 } // namespace dart |
| OLD | NEW |