| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/dart_api_state.h" | 7 #include "vm/dart_api_state.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
| 10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
| 11 #include "vm/heap.h" | 11 #include "vm/heap.h" |
| 12 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 13 #include "vm/object.h" | 13 #include "vm/object.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/port.h" | 15 #include "vm/port.h" |
| 16 #include "vm/snapshot.h" | 16 #include "vm/snapshot.h" |
| 17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 18 #include "vm/thread_pool.h" |
| 18 #include "vm/virtual_memory.h" | 19 #include "vm/virtual_memory.h" |
| 19 #include "vm/zone.h" | 20 #include "vm/zone.h" |
| 20 | 21 |
| 21 namespace dart { | 22 namespace dart { |
| 22 | 23 |
| 23 DECLARE_FLAG(bool, trace_isolates); | 24 DECLARE_FLAG(bool, trace_isolates); |
| 24 | 25 |
| 25 Isolate* Dart::vm_isolate_ = NULL; | 26 Isolate* Dart::vm_isolate_ = NULL; |
| 27 ThreadPool* Dart::thread_pool_ = NULL; |
| 26 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 28 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
| 27 | 29 |
| 30 // TODO(turnidge): We should add a corresponding Dart::Cleanup. |
| 28 bool Dart::InitOnce(Dart_IsolateCreateCallback create, | 31 bool Dart::InitOnce(Dart_IsolateCreateCallback create, |
| 29 Dart_IsolateInterruptCallback interrupt) { | 32 Dart_IsolateInterruptCallback interrupt) { |
| 30 // TODO(iposva): Fix race condition here. | 33 // TODO(iposva): Fix race condition here. |
| 31 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 34 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
| 32 return false; | 35 return false; |
| 33 } | 36 } |
| 34 OS::InitOnce(); | 37 OS::InitOnce(); |
| 35 VirtualMemory::InitOnce(); | 38 VirtualMemory::InitOnce(); |
| 36 Isolate::InitOnce(); | 39 Isolate::InitOnce(); |
| 37 PortMap::InitOnce(); | 40 PortMap::InitOnce(); |
| 38 FreeListElement::InitOnce(); | 41 FreeListElement::InitOnce(); |
| 39 Api::InitOnce(); | 42 Api::InitOnce(); |
| 40 // Create the VM isolate and finish the VM initialization. | 43 // Create the VM isolate and finish the VM initialization. |
| 44 ASSERT(thread_pool_ == NULL); |
| 45 thread_pool_ = new ThreadPool(); |
| 41 { | 46 { |
| 42 ASSERT(vm_isolate_ == NULL); | 47 ASSERT(vm_isolate_ == NULL); |
| 43 ASSERT(Flags::Initialized()); | 48 ASSERT(Flags::Initialized()); |
| 44 vm_isolate_ = Isolate::Init("vm-isolate"); | 49 vm_isolate_ = Isolate::Init("vm-isolate"); |
| 45 Zone zone(vm_isolate_); | 50 Zone zone(vm_isolate_); |
| 46 HandleScope handle_scope(vm_isolate_); | 51 HandleScope handle_scope(vm_isolate_); |
| 47 Heap::Init(vm_isolate_); | 52 Heap::Init(vm_isolate_); |
| 48 ObjectStore::Init(vm_isolate_); | 53 ObjectStore::Init(vm_isolate_); |
| 49 Object::InitOnce(); | 54 Object::InitOnce(); |
| 50 StubCode::InitOnce(); | 55 StubCode::InitOnce(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 103 } |
| 99 | 104 |
| 100 | 105 |
| 101 void Dart::ShutdownIsolate() { | 106 void Dart::ShutdownIsolate() { |
| 102 Isolate* isolate = Isolate::Current(); | 107 Isolate* isolate = Isolate::Current(); |
| 103 isolate->Shutdown(); | 108 isolate->Shutdown(); |
| 104 delete isolate; | 109 delete isolate; |
| 105 } | 110 } |
| 106 | 111 |
| 107 } // namespace dart | 112 } // namespace dart |
| OLD | NEW |