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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 const char* Dart::Cleanup() { | 219 const char* Dart::Cleanup() { |
220 ASSERT(Isolate::Current() == NULL); | 220 ASSERT(Isolate::Current() == NULL); |
221 if (vm_isolate_ == NULL) { | 221 if (vm_isolate_ == NULL) { |
222 return "VM already terminated."; | 222 return "VM already terminated."; |
223 } | 223 } |
224 | 224 |
225 // Shut down profiling. | 225 // Shut down profiling. |
226 Profiler::Shutdown(); | 226 Profiler::Shutdown(); |
227 | 227 |
| 228 { |
| 229 // Set the VM isolate as current isolate when shutting down |
| 230 // Metrics so that we can use a StackZone. |
| 231 Thread::EnterIsolate(vm_isolate_); |
| 232 Metric::Cleanup(); |
| 233 Thread::ExitIsolate(); |
| 234 } |
| 235 |
228 if (FLAG_shutdown) { | 236 if (FLAG_shutdown) { |
229 // Disable the creation of new isolates. | 237 // Disable the creation of new isolates. |
230 Isolate::DisableIsolateCreation(); | 238 Isolate::DisableIsolateCreation(); |
231 | 239 |
232 // Send the OOB Kill message to all remaining application isolates. | 240 // Send the OOB Kill message to all remaining application isolates. |
233 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); | 241 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); |
234 | 242 |
235 // Shutdown the service isolate. | 243 // Shutdown the service isolate. |
236 ServiceIsolate::Shutdown(); | 244 ServiceIsolate::Shutdown(); |
237 | 245 |
(...skipping 21 matching lines...) Expand all Loading... |
259 OSThread* os_thread = OSThread::Current(); | 267 OSThread* os_thread = OSThread::Current(); |
260 OSThread::SetCurrent(NULL); | 268 OSThread::SetCurrent(NULL); |
261 delete os_thread; | 269 delete os_thread; |
262 } else { | 270 } else { |
263 // Shutdown the service isolate. | 271 // Shutdown the service isolate. |
264 ServiceIsolate::Shutdown(); | 272 ServiceIsolate::Shutdown(); |
265 } | 273 } |
266 | 274 |
267 CodeObservers::DeleteAll(); | 275 CodeObservers::DeleteAll(); |
268 Timeline::Shutdown(); | 276 Timeline::Shutdown(); |
269 Metric::Cleanup(); | |
270 | 277 |
271 return NULL; | 278 return NULL; |
272 } | 279 } |
273 | 280 |
274 | 281 |
275 Isolate* Dart::CreateIsolate(const char* name_prefix, | 282 Isolate* Dart::CreateIsolate(const char* name_prefix, |
276 const Dart_IsolateFlags& api_flags) { | 283 const Dart_IsolateFlags& api_flags) { |
277 // Create a new isolate. | 284 // Create a new isolate. |
278 Isolate* isolate = Isolate::Init(name_prefix, api_flags); | 285 Isolate* isolate = Isolate::Init(name_prefix, api_flags); |
279 return isolate; | 286 return isolate; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return predefined_handles_->handles_.IsValidScopedHandle(address); | 441 return predefined_handles_->handles_.IsValidScopedHandle(address); |
435 } | 442 } |
436 | 443 |
437 | 444 |
438 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 445 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
439 ASSERT(predefined_handles_ != NULL); | 446 ASSERT(predefined_handles_ != NULL); |
440 return predefined_handles_->api_handles_.IsValidHandle(handle); | 447 return predefined_handles_->api_handles_.IsValidHandle(handle); |
441 } | 448 } |
442 | 449 |
443 } // namespace dart | 450 } // namespace dart |
OLD | NEW |