| 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 11 matching lines...) Expand all Loading... |
| 22 #include "vm/port.h" | 22 #include "vm/port.h" |
| 23 #include "vm/profiler.h" | 23 #include "vm/profiler.h" |
| 24 #include "vm/service_isolate.h" | 24 #include "vm/service_isolate.h" |
| 25 #include "vm/simulator.h" | 25 #include "vm/simulator.h" |
| 26 #include "vm/snapshot.h" | 26 #include "vm/snapshot.h" |
| 27 #include "vm/store_buffer.h" | 27 #include "vm/store_buffer.h" |
| 28 #include "vm/stub_code.h" | 28 #include "vm/stub_code.h" |
| 29 #include "vm/symbols.h" | 29 #include "vm/symbols.h" |
| 30 #include "vm/thread_interrupter.h" | 30 #include "vm/thread_interrupter.h" |
| 31 #include "vm/thread_pool.h" | 31 #include "vm/thread_pool.h" |
| 32 #include "vm/timeline.h" |
| 32 #include "vm/virtual_memory.h" | 33 #include "vm/virtual_memory.h" |
| 33 #include "vm/zone.h" | 34 #include "vm/zone.h" |
| 34 | 35 |
| 35 namespace dart { | 36 namespace dart { |
| 36 | 37 |
| 37 DECLARE_FLAG(bool, print_class_table); | 38 DECLARE_FLAG(bool, print_class_table); |
| 38 DECLARE_FLAG(bool, trace_isolates); | 39 DECLARE_FLAG(bool, trace_isolates); |
| 39 DECLARE_FLAG(bool, trace_time_all); | 40 DECLARE_FLAG(bool, trace_time_all); |
| 40 DECLARE_FLAG(bool, pause_isolates_on_start); | 41 DECLARE_FLAG(bool, pause_isolates_on_start); |
| 41 DECLARE_FLAG(bool, pause_isolates_on_exit); | 42 DECLARE_FLAG(bool, pause_isolates_on_exit); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Isolate* isolate = Isolate::Init(name_prefix, api_flags); | 385 Isolate* isolate = Isolate::Init(name_prefix, api_flags); |
| 385 return isolate; | 386 return isolate; |
| 386 } | 387 } |
| 387 | 388 |
| 388 | 389 |
| 389 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 390 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 390 // Initialize the new isolate. | 391 // Initialize the new isolate. |
| 391 Thread* T = Thread::Current(); | 392 Thread* T = Thread::Current(); |
| 392 Isolate* I = T->isolate(); | 393 Isolate* I = T->isolate(); |
| 393 NOT_IN_PRODUCT( | 394 NOT_IN_PRODUCT( |
| 394 TimelineDurationScope tds(T, I->GetIsolateStream(), "InitializeIsolate"); | 395 TimelineDurationScope tds(T, |
| 396 Timeline::GetIsolateStream(), |
| 397 "InitializeIsolate"); |
| 395 tds.SetNumArguments(1); | 398 tds.SetNumArguments(1); |
| 396 tds.CopyArgument(0, "isolateName", I->name()); | 399 tds.CopyArgument(0, "isolateName", I->name()); |
| 397 ) | 400 ) |
| 398 ASSERT(I != NULL); | 401 ASSERT(I != NULL); |
| 399 StackZone zone(T); | 402 StackZone zone(T); |
| 400 HandleScope handle_scope(T); | 403 HandleScope handle_scope(T); |
| 401 { | 404 { |
| 402 NOT_IN_PRODUCT(TimelineDurationScope tds(T, | 405 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 403 I->GetIsolateStream(), "ObjectStore::Init")); | 406 Timeline::GetIsolateStream(), "ObjectStore::Init")); |
| 404 ObjectStore::Init(I); | 407 ObjectStore::Init(I); |
| 405 } | 408 } |
| 406 | 409 |
| 407 const Error& error = Error::Handle(Object::Init(I)); | 410 const Error& error = Error::Handle(Object::Init(I)); |
| 408 if (!error.IsNull()) { | 411 if (!error.IsNull()) { |
| 409 return error.raw(); | 412 return error.raw(); |
| 410 } | 413 } |
| 411 if (snapshot_buffer != NULL) { | 414 if (snapshot_buffer != NULL) { |
| 412 // Read the snapshot and setup the initial state. | 415 // Read the snapshot and setup the initial state. |
| 413 NOT_IN_PRODUCT(TimelineDurationScope tds(T, | 416 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 414 I->GetIsolateStream(), "IsolateSnapshotReader")); | 417 Timeline::GetIsolateStream(), "IsolateSnapshotReader")); |
| 415 // TODO(turnidge): Remove once length is not part of the snapshot. | 418 // TODO(turnidge): Remove once length is not part of the snapshot. |
| 416 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 419 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 417 if (snapshot == NULL) { | 420 if (snapshot == NULL) { |
| 418 const String& message = String::Handle( | 421 const String& message = String::Handle( |
| 419 String::New("Invalid snapshot.")); | 422 String::New("Invalid snapshot.")); |
| 420 return ApiError::New(message); | 423 return ApiError::New(message); |
| 421 } | 424 } |
| 422 ASSERT(snapshot->kind() == Snapshot::kFull); | 425 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 423 if (FLAG_trace_isolates) { | 426 if (FLAG_trace_isolates) { |
| 424 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); | 427 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 442 // for the isolate we have a unified symbol table that we can then | 445 // for the isolate we have a unified symbol table that we can then |
| 443 // read into the VM isolate. | 446 // read into the VM isolate. |
| 444 Symbols::AddPredefinedSymbolsToIsolate(); | 447 Symbols::AddPredefinedSymbolsToIsolate(); |
| 445 } | 448 } |
| 446 | 449 |
| 447 Object::VerifyBuiltinVtables(); | 450 Object::VerifyBuiltinVtables(); |
| 448 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); | 451 DEBUG_ONLY(I->heap()->Verify(kForbidMarked)); |
| 449 | 452 |
| 450 { | 453 { |
| 451 NOT_IN_PRODUCT(TimelineDurationScope tds(T, | 454 NOT_IN_PRODUCT(TimelineDurationScope tds(T, |
| 452 I->GetIsolateStream(), "StubCode::Init")); | 455 Timeline::GetIsolateStream(), "StubCode::Init")); |
| 453 StubCode::Init(I); | 456 StubCode::Init(I); |
| 454 } | 457 } |
| 455 | 458 |
| 456 #if !defined(DART_PRECOMPILED_RUNTIME) | 459 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 457 // When running precompiled, the megamorphic miss function/code comes from the | 460 // When running precompiled, the megamorphic miss function/code comes from the |
| 458 // snapshot. | 461 // snapshot. |
| 459 if (!Dart::IsRunningPrecompiledCode()) { | 462 if (!Dart::IsRunningPrecompiledCode()) { |
| 460 MegamorphicCacheTable::InitMissHandler(I); | 463 MegamorphicCacheTable::InitMissHandler(I); |
| 461 } | 464 } |
| 462 #endif | 465 #endif |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 return predefined_handles_->handles_.IsValidScopedHandle(address); | 562 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 560 } | 563 } |
| 561 | 564 |
| 562 | 565 |
| 563 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 566 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 564 ASSERT(predefined_handles_ != NULL); | 567 ASSERT(predefined_handles_ != NULL); |
| 565 return predefined_handles_->api_handles_.IsValidHandle(handle); | 568 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 566 } | 569 } |
| 567 | 570 |
| 568 } // namespace dart | 571 } // namespace dart |
| OLD | NEW |