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_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/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/symbols.h" | 19 #include "vm/symbols.h" |
20 #include "vm/thread_pool.h" | 20 #include "vm/thread_pool.h" |
21 #include "vm/virtual_memory.h" | 21 #include "vm/virtual_memory.h" |
22 #include "vm/zone.h" | 22 #include "vm/zone.h" |
23 | 23 |
24 namespace dart { | 24 namespace dart { |
25 | 25 |
| 26 DECLARE_FLAG(bool, heap_trace); |
26 DECLARE_FLAG(bool, print_bootstrap); | 27 DECLARE_FLAG(bool, print_bootstrap); |
27 DECLARE_FLAG(bool, print_class_table); | 28 DECLARE_FLAG(bool, print_class_table); |
28 DECLARE_FLAG(bool, trace_isolates); | 29 DECLARE_FLAG(bool, trace_isolates); |
29 | 30 |
30 Isolate* Dart::vm_isolate_ = NULL; | 31 Isolate* Dart::vm_isolate_ = NULL; |
31 ThreadPool* Dart::thread_pool_ = NULL; | 32 ThreadPool* Dart::thread_pool_ = NULL; |
32 void* Dart::perf_events_file_ = NULL; | 33 void* Dart::perf_events_file_ = NULL; |
33 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 34 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
34 | 35 |
35 // An object visitor which will mark all visited objects. This is used to | 36 // An object visitor which will mark all visited objects. This is used to |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #endif | 92 #endif |
92 PremarkingVisitor premarker(vm_isolate_); | 93 PremarkingVisitor premarker(vm_isolate_); |
93 vm_isolate_->heap()->IterateOldObjects(&premarker); | 94 vm_isolate_->heap()->IterateOldObjects(&premarker); |
94 vm_isolate_->heap()->WriteProtect(true); | 95 vm_isolate_->heap()->WriteProtect(true); |
95 } | 96 } |
96 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. | 97 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. |
97 Isolate::SetCreateCallback(create); | 98 Isolate::SetCreateCallback(create); |
98 Isolate::SetInterruptCallback(interrupt); | 99 Isolate::SetInterruptCallback(interrupt); |
99 Isolate::SetUnhandledExceptionCallback(unhandled); | 100 Isolate::SetUnhandledExceptionCallback(unhandled); |
100 Isolate::SetShutdownCallback(shutdown); | 101 Isolate::SetShutdownCallback(shutdown); |
| 102 if (FLAG_heap_trace) { |
| 103 HeapTrace::InitOnce(file_open, file_write, file_close); |
| 104 } |
101 return NULL; | 105 return NULL; |
102 } | 106 } |
103 | 107 |
104 | 108 |
105 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 109 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
106 // Create a new isolate. | 110 // Create a new isolate. |
107 Isolate* isolate = Isolate::Init(name_prefix); | 111 Isolate* isolate = Isolate::Init(name_prefix); |
108 ASSERT(isolate != NULL); | 112 ASSERT(isolate != NULL); |
109 return isolate; | 113 return isolate; |
110 } | 114 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 reader.ReadFullSnapshot(); | 171 reader.ReadFullSnapshot(); |
168 if (FLAG_trace_isolates) { | 172 if (FLAG_trace_isolates) { |
169 isolate->heap()->PrintSizes(); | 173 isolate->heap()->PrintSizes(); |
170 } | 174 } |
171 if (FLAG_print_bootstrap) { | 175 if (FLAG_print_bootstrap) { |
172 PrintLibrarySources(isolate); | 176 PrintLibrarySources(isolate); |
173 } | 177 } |
174 } | 178 } |
175 | 179 |
176 StubCode::Init(isolate); | 180 StubCode::Init(isolate); |
| 181 if (FLAG_heap_trace) { |
| 182 isolate->heap()->trace()->Init(isolate); |
| 183 } |
177 isolate->heap()->EnableGrowthControl(); | 184 isolate->heap()->EnableGrowthControl(); |
178 isolate->set_init_callback_data(data); | 185 isolate->set_init_callback_data(data); |
179 if (FLAG_print_class_table) { | 186 if (FLAG_print_class_table) { |
180 isolate->class_table()->Print(); | 187 isolate->class_table()->Print(); |
181 } | 188 } |
182 return Error::null(); | 189 return Error::null(); |
183 } | 190 } |
184 | 191 |
185 | 192 |
186 void Dart::ShutdownIsolate() { | 193 void Dart::ShutdownIsolate() { |
187 Isolate* isolate = Isolate::Current(); | 194 Isolate* isolate = Isolate::Current(); |
188 if (FLAG_trace_isolates) { | 195 if (FLAG_trace_isolates) { |
189 isolate->heap()->PrintSizes(); | 196 isolate->heap()->PrintSizes(); |
190 } | 197 } |
191 void* callback_data = isolate->init_callback_data(); | 198 void* callback_data = isolate->init_callback_data(); |
192 isolate->Shutdown(); | 199 isolate->Shutdown(); |
193 delete isolate; | 200 delete isolate; |
194 | 201 |
195 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); | 202 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); |
196 if (callback != NULL) { | 203 if (callback != NULL) { |
197 (callback)(callback_data); | 204 (callback)(callback_data); |
198 } | 205 } |
199 } | 206 } |
200 | 207 |
201 | 208 |
202 } // namespace dart | 209 } // namespace dart |
OLD | NEW |