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