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/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
11 #include "vm/freelist.h" | 11 #include "vm/freelist.h" |
12 #include "vm/handles.h" | 12 #include "vm/handles.h" |
13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
14 #include "vm/isolate.h" | 14 #include "vm/isolate.h" |
15 #include "vm/object.h" | 15 #include "vm/object.h" |
16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
17 #include "vm/port.h" | 17 #include "vm/port.h" |
18 #include "vm/simulator.h" | 18 #include "vm/simulator.h" |
19 #include "vm/snapshot.h" | 19 #include "vm/snapshot.h" |
20 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
21 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
22 #include "vm/thread_pool.h" | 22 #include "vm/thread_pool.h" |
23 #include "vm/virtual_memory.h" | 23 #include "vm/virtual_memory.h" |
24 #include "vm/zone.h" | 24 #include "vm/zone.h" |
25 | 25 |
26 namespace dart { | 26 namespace dart { |
27 | 27 |
28 DEFINE_FLAG(bool, heap_profile_initialize, false, | 28 DEFINE_FLAG(bool, heap_profile_initialize, false, |
29 "Writes a heap profile on isolate initialization."); | 29 "Writes a heap profile on isolate initialization."); |
30 DECLARE_FLAG(bool, heap_trace); | |
31 DECLARE_FLAG(bool, print_bootstrap); | 30 DECLARE_FLAG(bool, print_bootstrap); |
32 DECLARE_FLAG(bool, print_class_table); | 31 DECLARE_FLAG(bool, print_class_table); |
33 DECLARE_FLAG(bool, trace_isolates); | 32 DECLARE_FLAG(bool, trace_isolates); |
34 | 33 |
35 Isolate* Dart::vm_isolate_ = NULL; | 34 Isolate* Dart::vm_isolate_ = NULL; |
36 ThreadPool* Dart::thread_pool_ = NULL; | 35 ThreadPool* Dart::thread_pool_ = NULL; |
37 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 36 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
38 ReadOnlyHandles* Dart::predefined_handles_ = NULL; | 37 ReadOnlyHandles* Dart::predefined_handles_ = NULL; |
39 | 38 |
40 // An object visitor which will mark all visited objects. This is used to | 39 // An object visitor which will mark all visited objects. This is used to |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 #endif | 126 #endif |
128 PremarkingVisitor premarker(vm_isolate_); | 127 PremarkingVisitor premarker(vm_isolate_); |
129 vm_isolate_->heap()->IterateOldObjects(&premarker); | 128 vm_isolate_->heap()->IterateOldObjects(&premarker); |
130 vm_isolate_->heap()->WriteProtect(true); | 129 vm_isolate_->heap()->WriteProtect(true); |
131 } | 130 } |
132 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 131 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
133 Isolate::SetCreateCallback(create); | 132 Isolate::SetCreateCallback(create); |
134 Isolate::SetInterruptCallback(interrupt); | 133 Isolate::SetInterruptCallback(interrupt); |
135 Isolate::SetUnhandledExceptionCallback(unhandled); | 134 Isolate::SetUnhandledExceptionCallback(unhandled); |
136 Isolate::SetShutdownCallback(shutdown); | 135 Isolate::SetShutdownCallback(shutdown); |
137 if (FLAG_heap_trace) { | |
138 HeapTrace::InitOnce(file_open, file_write, file_close); | |
139 } | |
140 return NULL; | 136 return NULL; |
141 } | 137 } |
142 | 138 |
143 | 139 |
144 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 140 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
145 // Create a new isolate. | 141 // Create a new isolate. |
146 Isolate* isolate = Isolate::Init(name_prefix); | 142 Isolate* isolate = Isolate::Init(name_prefix); |
147 ASSERT(isolate != NULL); | 143 ASSERT(isolate != NULL); |
148 return isolate; | 144 return isolate; |
149 } | 145 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 211 |
216 if (FLAG_heap_profile_initialize) { | 212 if (FLAG_heap_profile_initialize) { |
217 isolate->heap()->ProfileToFile("initialize"); | 213 isolate->heap()->ProfileToFile("initialize"); |
218 } | 214 } |
219 | 215 |
220 Object::VerifyBuiltinVtables(); | 216 Object::VerifyBuiltinVtables(); |
221 | 217 |
222 StubCode::Init(isolate); | 218 StubCode::Init(isolate); |
223 isolate->megamorphic_cache_table()->InitMissHandler(); | 219 isolate->megamorphic_cache_table()->InitMissHandler(); |
224 | 220 |
225 if (FLAG_heap_trace) { | |
226 isolate->heap()->trace()->Init(isolate); | |
227 } | |
228 isolate->heap()->EnableGrowthControl(); | 221 isolate->heap()->EnableGrowthControl(); |
229 isolate->set_init_callback_data(data); | 222 isolate->set_init_callback_data(data); |
230 Api::SetupAcquiredError(isolate); | 223 Api::SetupAcquiredError(isolate); |
231 if (FLAG_print_class_table) { | 224 if (FLAG_print_class_table) { |
232 isolate->class_table()->Print(); | 225 isolate->class_table()->Print(); |
233 } | 226 } |
234 return Error::null(); | 227 return Error::null(); |
235 } | 228 } |
236 | 229 |
237 | 230 |
(...skipping 16 matching lines...) Expand all Loading... |
254 return predefined_handles_->handles_.AllocateScopedHandle(); | 247 return predefined_handles_->handles_.AllocateScopedHandle(); |
255 } | 248 } |
256 | 249 |
257 | 250 |
258 bool Dart::IsReadOnlyHandle(uword address) { | 251 bool Dart::IsReadOnlyHandle(uword address) { |
259 ASSERT(predefined_handles_ != NULL); | 252 ASSERT(predefined_handles_ != NULL); |
260 return predefined_handles_->handles_.IsValidScopedHandle(address); | 253 return predefined_handles_->handles_.IsValidScopedHandle(address); |
261 } | 254 } |
262 | 255 |
263 } // namespace dart | 256 } // namespace dart |
OLD | NEW |