Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: runtime/vm/dart.cc

Issue 1177153005: Enables clean VM shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix error propagation Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart.cc
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 60439a25d691848b9114471543ca755e13fc7ccf..63ca83a19d1ae9ea4a9e49d7602a3234f71d68d4 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -14,6 +14,7 @@
#include "vm/handles.h"
#include "vm/heap.h"
#include "vm/isolate.h"
+#include "vm/message.h"
#include "vm/metrics.h"
#include "vm/object.h"
#include "vm/object_store.h"
@@ -184,18 +185,21 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
const char* Dart::Cleanup() {
- // Shutdown the service isolate before shutting down the thread pool.
- ServiceIsolate::Shutdown();
-#if 0
- // Ideally we should shutdown the VM isolate here, but the thread pool
- // shutdown does not seem to ensure that all the threads have stopped
- // execution before it terminates, this results in racing isolates.
+ ASSERT(Isolate::Current() == NULL);
if (vm_isolate_ == NULL) {
return "VM already terminated.";
}
- ASSERT(Isolate::Current() == NULL);
+ // Disable the creation of new isolates.
+ Isolate::DisableIsolateCreation();
+
+ // Send the OOB Kill message to all remaining isolates.
+ Isolate::KillAllIsolates();
+
+ // Shutdown the service isolate before shutting down the thread pool.
+ ServiceIsolate::Shutdown();
+ // Shutdown the thread pool. On return, all thread pool threads have exited.
delete thread_pool_;
thread_pool_ = NULL;
@@ -203,19 +207,14 @@ const char* Dart::Cleanup() {
Thread::EnsureInit();
Thread::EnterIsolate(vm_isolate_);
- // There is a planned and known asymmetry here: We exit one scope for the VM
- // isolate to account for the scope that was entered in Dart_InitOnce.
- Dart_ExitScope();
-
ShutdownIsolate();
vm_isolate_ = NULL;
TargetCPUFeatures::Cleanup();
-#endif
-
Profiler::Shutdown();
CodeObservers::DeleteAll();
+ ASSERT(Isolate::IsolateListLength() == 0);
return NULL;
}
@@ -224,7 +223,6 @@ Isolate* Dart::CreateIsolate(const char* name_prefix,
const Dart_IsolateFlags& api_flags) {
// Create a new isolate.
Isolate* isolate = Isolate::Init(name_prefix, api_flags);
- ASSERT(isolate != NULL);
return isolate;
}
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698