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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 228 { |
229 // Set the VM isolate as current isolate when shutting down | 229 // Set the VM isolate as current isolate when shutting down |
230 // Metrics so that we can use a StackZone. | 230 // Metrics so that we can use a StackZone. |
231 Thread::EnterIsolate(vm_isolate_); | 231 bool result = Thread::EnterIsolate(vm_isolate_); |
| 232 ASSERT(result); |
232 Metric::Cleanup(); | 233 Metric::Cleanup(); |
233 Thread::ExitIsolate(); | 234 Thread::ExitIsolate(); |
234 } | 235 } |
235 | 236 |
236 if (FLAG_shutdown) { | 237 if (FLAG_shutdown) { |
237 // Disable the creation of new isolates. | 238 // Disable the creation of new isolates. |
238 Isolate::DisableIsolateCreation(); | 239 Isolate::DisableIsolateCreation(); |
239 | 240 |
240 // Send the OOB Kill message to all remaining application isolates. | 241 // Send the OOB Kill message to all remaining application isolates. |
241 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); | 242 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); |
242 | 243 |
243 // Shutdown the service isolate. | 244 // Shutdown the service isolate. |
244 ServiceIsolate::Shutdown(); | 245 ServiceIsolate::Shutdown(); |
245 | 246 |
246 // Wait for all application isolates and the service isolate to shutdown | 247 // Wait for all application isolates and the service isolate to shutdown |
247 // before shutting down the thread pool. | 248 // before shutting down the thread pool. |
248 WaitForIsolateShutdown(); | 249 WaitForIsolateShutdown(); |
249 | 250 |
250 // Shutdown the thread pool. On return, all thread pool threads have exited. | 251 // Shutdown the thread pool. On return, all thread pool threads have exited. |
251 delete thread_pool_; | 252 delete thread_pool_; |
252 thread_pool_ = NULL; | 253 thread_pool_ = NULL; |
253 | 254 |
254 // Set the VM isolate as current isolate. | 255 // Set the VM isolate as current isolate. |
255 Thread::EnterIsolate(vm_isolate_); | 256 bool result = Thread::EnterIsolate(vm_isolate_); |
| 257 ASSERT(result); |
256 | 258 |
257 ShutdownIsolate(); | 259 ShutdownIsolate(); |
258 vm_isolate_ = NULL; | 260 vm_isolate_ = NULL; |
259 ASSERT(Isolate::IsolateListLength() == 0); | 261 ASSERT(Isolate::IsolateListLength() == 0); |
260 | 262 |
261 TargetCPUFeatures::Cleanup(); | 263 TargetCPUFeatures::Cleanup(); |
262 StoreBuffer::ShutDown(); | 264 StoreBuffer::ShutDown(); |
263 | 265 |
264 // Delete the current thread's TLS and set it's TLS to null. | 266 // Delete the current thread's TLS and set it's TLS to null. |
265 // If it is the last thread then the destructor would call | 267 // If it is the last thread then the destructor would call |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 ServiceIsolate::SendIsolateShutdownMessage(); | 402 ServiceIsolate::SendIsolateShutdownMessage(); |
401 if (callback != NULL) { | 403 if (callback != NULL) { |
402 (callback)(callback_data); | 404 (callback)(callback_data); |
403 } | 405 } |
404 } | 406 } |
405 | 407 |
406 | 408 |
407 void Dart::ShutdownIsolate(Isolate* isolate) { | 409 void Dart::ShutdownIsolate(Isolate* isolate) { |
408 ASSERT(Isolate::Current() == NULL); | 410 ASSERT(Isolate::Current() == NULL); |
409 // We need to enter the isolate in order to shut it down. | 411 // We need to enter the isolate in order to shut it down. |
410 Thread::EnterIsolate(isolate); | 412 bool result = Thread::EnterIsolate(isolate); |
| 413 ASSERT(result); |
411 ShutdownIsolate(); | 414 ShutdownIsolate(); |
412 // Since the isolate is shutdown and deleted, there is no need to | 415 // Since the isolate is shutdown and deleted, there is no need to |
413 // exit the isolate here. | 416 // exit the isolate here. |
414 ASSERT(Isolate::Current() == NULL); | 417 ASSERT(Isolate::Current() == NULL); |
415 } | 418 } |
416 | 419 |
417 | 420 |
418 void Dart::ShutdownIsolate() { | 421 void Dart::ShutdownIsolate() { |
419 Isolate* isolate = Isolate::Current(); | 422 Isolate* isolate = Isolate::Current(); |
420 isolate->Shutdown(); | 423 isolate->Shutdown(); |
(...skipping 20 matching lines...) Expand all Loading... |
441 return predefined_handles_->handles_.IsValidScopedHandle(address); | 444 return predefined_handles_->handles_.IsValidScopedHandle(address); |
442 } | 445 } |
443 | 446 |
444 | 447 |
445 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 448 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
446 ASSERT(predefined_handles_ != NULL); | 449 ASSERT(predefined_handles_ != NULL); |
447 return predefined_handles_->api_handles_.IsValidHandle(handle); | 450 return predefined_handles_->api_handles_.IsValidHandle(handle); |
448 } | 451 } |
449 | 452 |
450 } // namespace dart | 453 } // namespace dart |
OLD | NEW |