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