Chromium Code Reviews| 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/become.h" | 7 #include "vm/become.h" |
| 8 #include "vm/code_observers.h" | 8 #include "vm/code_observers.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 if (FLAG_support_service) { | 303 if (FLAG_support_service) { |
| 304 Service::SetGetServiceAssetsCallback(get_service_assets); | 304 Service::SetGetServiceAssetsCallback(get_service_assets); |
| 305 } | 305 } |
| 306 | 306 |
| 307 ServiceIsolate::Run(); | 307 ServiceIsolate::Run(); |
| 308 | 308 |
| 309 return NULL; | 309 return NULL; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 // This waits until only the VM isolate and the service isolate remains in the | |
| 314 // list, i.e. list length == 2. | |
| 315 void Dart::WaitForApplicationIsolateShutdown() { | |
| 316 ASSERT(!Isolate::creation_enabled_); | |
| 317 MonitorLocker ml(Isolate::isolates_list_monitor_); | |
| 318 while ((Isolate::isolates_list_head_ != NULL) && | |
| 319 (Isolate::isolates_list_head_->next_ != NULL) && | |
| 320 (Isolate::isolates_list_head_->next_->next_ != NULL)) { | |
| 321 ml.Wait(); | |
| 322 } | |
| 323 ASSERT(Isolate::isolates_list_head_ == Dart::vm_isolate()); | |
|
zra
2016/06/10 21:51:07
Is the VM isolate really guaranteed to be first?
Florian Schneider
2016/06/10 21:53:05
good point. I have to fix this assertion.
| |
| 324 ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::isolates_list_head_->next_)); | |
| 325 } | |
| 326 | |
| 327 | |
| 313 // This waits until only the VM isolate remains in the list. | 328 // This waits until only the VM isolate remains in the list. |
| 314 void Dart::WaitForIsolateShutdown() { | 329 void Dart::WaitForIsolateShutdown() { |
| 315 ASSERT(!Isolate::creation_enabled_); | 330 ASSERT(!Isolate::creation_enabled_); |
| 316 MonitorLocker ml(Isolate::isolates_list_monitor_); | 331 MonitorLocker ml(Isolate::isolates_list_monitor_); |
| 317 while ((Isolate::isolates_list_head_ != NULL) && | 332 while ((Isolate::isolates_list_head_ != NULL) && |
| 318 (Isolate::isolates_list_head_->next_ != NULL)) { | 333 (Isolate::isolates_list_head_->next_ != NULL)) { |
| 319 ml.Wait(); | 334 ml.Wait(); |
| 320 } | 335 } |
| 321 ASSERT(Isolate::isolates_list_head_ == Dart::vm_isolate()); | 336 ASSERT(Isolate::isolates_list_head_ == Dart::vm_isolate()); |
| 322 } | 337 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 } | 379 } |
| 365 Isolate::DisableIsolateCreation(); | 380 Isolate::DisableIsolateCreation(); |
| 366 | 381 |
| 367 // Send the OOB Kill message to all remaining application isolates. | 382 // Send the OOB Kill message to all remaining application isolates. |
| 368 if (FLAG_trace_shutdown) { | 383 if (FLAG_trace_shutdown) { |
| 369 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Killing all app isolates\n", | 384 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Killing all app isolates\n", |
| 370 timestamp()); | 385 timestamp()); |
| 371 } | 386 } |
| 372 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); | 387 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); |
| 373 | 388 |
| 389 // Wait for all isolates, but the service and the vm isolate to shut down. | |
| 390 if (FLAG_trace_shutdown) { | |
| 391 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n", | |
| 392 timestamp()); | |
| 393 } | |
| 394 WaitForApplicationIsolateShutdown(); | |
| 395 | |
| 374 // Shutdown the service isolate. | 396 // Shutdown the service isolate. |
| 375 if (FLAG_trace_shutdown) { | 397 if (FLAG_trace_shutdown) { |
| 376 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n", | 398 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n", |
| 377 timestamp()); | 399 timestamp()); |
| 378 } | 400 } |
| 379 ServiceIsolate::Shutdown(); | 401 ServiceIsolate::Shutdown(); |
| 380 | 402 |
| 381 // Wait for all application isolates and the service isolate to shutdown | 403 // Wait for the remaining isolate (service isolate) to shutdown |
| 382 // before shutting down the thread pool. | 404 // before shutting down the thread pool. |
| 383 if (FLAG_trace_shutdown) { | 405 if (FLAG_trace_shutdown) { |
| 384 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n", | 406 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n", |
| 385 timestamp()); | 407 timestamp()); |
| 386 } | 408 } |
| 387 WaitForIsolateShutdown(); | 409 WaitForIsolateShutdown(); |
| 388 | 410 |
| 389 // Shutdown the thread pool. On return, all thread pool threads have exited. | 411 // Shutdown the thread pool. On return, all thread pool threads have exited. |
| 390 if (FLAG_trace_shutdown) { | 412 if (FLAG_trace_shutdown) { |
| 391 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting thread pool\n", | 413 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting thread pool\n", |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 return predefined_handles_->handles_.IsValidScopedHandle(address); | 727 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 706 } | 728 } |
| 707 | 729 |
| 708 | 730 |
| 709 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 731 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 710 ASSERT(predefined_handles_ != NULL); | 732 ASSERT(predefined_handles_ != NULL); |
| 711 return predefined_handles_->api_handles_.IsValidHandle(handle); | 733 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 712 } | 734 } |
| 713 | 735 |
| 714 } // namespace dart | 736 } // namespace dart |
| OLD | NEW |