| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Dart_EntropySource entropy_source) { | 83 Dart_EntropySource entropy_source) { |
| 84 // TODO(iposva): Fix race condition here. | 84 // TODO(iposva): Fix race condition here. |
| 85 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 85 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
| 86 return "VM already initialized or flags not initialized."; | 86 return "VM already initialized or flags not initialized."; |
| 87 } | 87 } |
| 88 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); | 88 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); |
| 89 Isolate::SetEntropySourceCallback(entropy_source); | 89 Isolate::SetEntropySourceCallback(entropy_source); |
| 90 OS::InitOnce(); | 90 OS::InitOnce(); |
| 91 VirtualMemory::InitOnce(); | 91 VirtualMemory::InitOnce(); |
| 92 Thread::InitOnceBeforeIsolate(); | 92 Thread::InitOnceBeforeIsolate(); |
| 93 Thread::EnsureInit(); |
| 93 Timeline::InitOnce(); | 94 Timeline::InitOnce(); |
| 94 Thread::EnsureInit(); | |
| 95 TimelineDurationScope tds(Timeline::GetVMStream(), | 95 TimelineDurationScope tds(Timeline::GetVMStream(), |
| 96 "Dart::InitOnce"); | 96 "Dart::InitOnce"); |
| 97 Isolate::InitOnce(); | 97 Isolate::InitOnce(); |
| 98 PortMap::InitOnce(); | 98 PortMap::InitOnce(); |
| 99 FreeListElement::InitOnce(); | 99 FreeListElement::InitOnce(); |
| 100 Api::InitOnce(); | 100 Api::InitOnce(); |
| 101 CodeObservers::InitOnce(); | 101 CodeObservers::InitOnce(); |
| 102 ThreadInterrupter::InitOnce(); | 102 ThreadInterrupter::InitOnce(); |
| 103 Profiler::InitOnce(); | 103 Profiler::InitOnce(); |
| 104 SemiSpace::InitOnce(); | 104 SemiSpace::InitOnce(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // Create a new isolate. | 274 // Create a new isolate. |
| 275 Isolate* isolate = Isolate::Init(name_prefix, api_flags); | 275 Isolate* isolate = Isolate::Init(name_prefix, api_flags); |
| 276 return isolate; | 276 return isolate; |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 280 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 281 // Initialize the new isolate. | 281 // Initialize the new isolate. |
| 282 Thread* T = Thread::Current(); | 282 Thread* T = Thread::Current(); |
| 283 Isolate* I = T->isolate(); | 283 Isolate* I = T->isolate(); |
| 284 TimelineDurationScope tds(I, I->GetIsolateStream(), "InitializeIsolate"); | 284 TimelineDurationScope tds(T, I->GetIsolateStream(), "InitializeIsolate"); |
| 285 tds.SetNumArguments(1); | 285 tds.SetNumArguments(1); |
| 286 tds.CopyArgument(0, "isolateName", I->name()); | 286 tds.CopyArgument(0, "isolateName", I->name()); |
| 287 | 287 |
| 288 ASSERT(I != NULL); | 288 ASSERT(I != NULL); |
| 289 StackZone zone(T); | 289 StackZone zone(T); |
| 290 HandleScope handle_scope(T); | 290 HandleScope handle_scope(T); |
| 291 { | 291 { |
| 292 TimelineDurationScope tds(I, I->GetIsolateStream(), "ObjectStore::Init"); | 292 TimelineDurationScope tds(T, I->GetIsolateStream(), "ObjectStore::Init"); |
| 293 ObjectStore::Init(I); | 293 ObjectStore::Init(I); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Setup for profiling. | 296 // Setup for profiling. |
| 297 Profiler::InitProfilingForIsolate(I); | 297 Profiler::InitProfilingForIsolate(I); |
| 298 | 298 |
| 299 const Error& error = Error::Handle(Object::Init(I)); | 299 const Error& error = Error::Handle(Object::Init(I)); |
| 300 if (!error.IsNull()) { | 300 if (!error.IsNull()) { |
| 301 return error.raw(); | 301 return error.raw(); |
| 302 } | 302 } |
| 303 if (snapshot_buffer != NULL) { | 303 if (snapshot_buffer != NULL) { |
| 304 // Read the snapshot and setup the initial state. | 304 // Read the snapshot and setup the initial state. |
| 305 TimelineDurationScope tds( | 305 TimelineDurationScope tds( |
| 306 I, I->GetIsolateStream(), "IsolateSnapshotReader"); | 306 T, I->GetIsolateStream(), "IsolateSnapshotReader"); |
| 307 // TODO(turnidge): Remove once length is not part of the snapshot. | 307 // TODO(turnidge): Remove once length is not part of the snapshot. |
| 308 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 308 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 309 if (snapshot == NULL) { | 309 if (snapshot == NULL) { |
| 310 const String& message = String::Handle( | 310 const String& message = String::Handle( |
| 311 String::New("Invalid snapshot.")); | 311 String::New("Invalid snapshot.")); |
| 312 return ApiError::New(message); | 312 return ApiError::New(message); |
| 313 } | 313 } |
| 314 ASSERT(snapshot->kind() == Snapshot::kFull); | 314 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 315 if (FLAG_trace_isolates) { | 315 if (FLAG_trace_isolates) { |
| 316 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); | 316 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 334 // read into the VM isolate. | 334 // read into the VM isolate. |
| 335 Symbols::AddPredefinedSymbolsToIsolate(); | 335 Symbols::AddPredefinedSymbolsToIsolate(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 Object::VerifyBuiltinVtables(); | 338 Object::VerifyBuiltinVtables(); |
| 339 #if defined(DEBUG) | 339 #if defined(DEBUG) |
| 340 I->heap()->Verify(kForbidMarked); | 340 I->heap()->Verify(kForbidMarked); |
| 341 #endif | 341 #endif |
| 342 | 342 |
| 343 { | 343 { |
| 344 TimelineDurationScope tds(I, I->GetIsolateStream(), "StubCode::Init"); | 344 TimelineDurationScope tds(T, I->GetIsolateStream(), "StubCode::Init"); |
| 345 StubCode::Init(I); | 345 StubCode::Init(I); |
| 346 } | 346 } |
| 347 | 347 |
| 348 // When running precompiled, the megamorphic miss function/code comes from the | 348 // When running precompiled, the megamorphic miss function/code comes from the |
| 349 // snapshot. | 349 // snapshot. |
| 350 if (!Dart::IsRunningPrecompiledCode()) { | 350 if (!Dart::IsRunningPrecompiledCode()) { |
| 351 MegamorphicCacheTable::InitMissHandler(I); | 351 MegamorphicCacheTable::InitMissHandler(I); |
| 352 } | 352 } |
| 353 if (snapshot_buffer == NULL) { | 353 if (snapshot_buffer == NULL) { |
| 354 if (!I->object_store()->PreallocateObjects()) { | 354 if (!I->object_store()->PreallocateObjects()) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return predefined_handles_->handles_.IsValidScopedHandle(address); | 419 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 420 } | 420 } |
| 421 | 421 |
| 422 | 422 |
| 423 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 423 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 424 ASSERT(predefined_handles_ != NULL); | 424 ASSERT(predefined_handles_ != NULL); |
| 425 return predefined_handles_->api_handles_.IsValidHandle(handle); | 425 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace dart | 428 } // namespace dart |
| OLD | NEW |