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

Unified Diff: runtime/vm/dart.cc

Issue 2147833002: Make loader lock new-allocated to avoid shutdown crash. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
Index: runtime/vm/dart.cc
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 599d334449a10f11628eff1b9759639dff420f64..ae603daee1816cbd21cbee687dd5b4aeabba3025 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -41,7 +41,6 @@ DECLARE_FLAG(bool, print_class_table);
DECLARE_FLAG(bool, trace_time_all);
DEFINE_FLAG(bool, keep_code, false,
"Keep deoptimized code for profiling.");
-DEFINE_FLAG(bool, shutdown, true, "Do a clean shutdown of the VM");
DEFINE_FLAG(bool, trace_shutdown, false, "Trace VM shutdown on stderr");
Isolate* Dart::vm_isolate_ = NULL;
@@ -375,105 +374,89 @@ const char* Dart::Cleanup() {
Thread::ExitIsolate();
}
- if (FLAG_shutdown) {
- // Disable the creation of new isolates.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling isolate creation\n",
- timestamp());
- }
- Isolate::DisableIsolateCreation();
-
- // Send the OOB Kill message to all remaining application isolates.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Killing all app isolates\n",
- timestamp());
- }
- Isolate::KillAllIsolates(Isolate::kInternalKillMsg);
-
- // Wait for all isolates, but the service and the vm isolate to shut down.
- // Only do that if there is a service isolate running.
- if (ServiceIsolate::IsRunning()) {
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n",
- timestamp());
- }
- WaitForApplicationIsolateShutdown();
- }
-
- // Shutdown the service isolate.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n",
- timestamp());
- }
- ServiceIsolate::Shutdown();
+ // Disable the creation of new isolates.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling isolate creation\n",
+ timestamp());
+ }
+ Isolate::DisableIsolateCreation();
- // Wait for the remaining isolate (service isolate) to shutdown
- // before shutting down the thread pool.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n",
- timestamp());
- }
- WaitForIsolateShutdown();
+ // Send the OOB Kill message to all remaining application isolates.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Killing all app isolates\n",
+ timestamp());
+ }
+ Isolate::KillAllIsolates(Isolate::kInternalKillMsg);
- // Shutdown the thread pool. On return, all thread pool threads have exited.
+ // Wait for all isolates, but the service and the vm isolate to shut down.
+ // Only do that if there is a service isolate running.
+ if (ServiceIsolate::IsRunning()) {
if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting thread pool\n",
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n",
timestamp());
}
- delete thread_pool_;
- thread_pool_ = NULL;
-
- // Disable creation of any new OSThread structures which means no more new
- // threads can do an EnterIsolate. This must come after isolate shutdown
- // because new threads may need to be spawned to shutdown the isolates.
- // This must come after deletion of the thread pool to avoid a race in which
- // a thread spawned by the thread pool does not exit through the thread
- // pool, messing up its bookkeeping.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling OS Thread creation\n",
- timestamp());
- }
- OSThread::DisableOSThreadCreation();
+ WaitForApplicationIsolateShutdown();
+ }
- // Set the VM isolate as current isolate.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Cleaning up vm isolate\n",
- timestamp());
- }
- bool result = Thread::EnterIsolate(vm_isolate_);
- ASSERT(result);
+ // Shutdown the service isolate.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n",
+ timestamp());
+ }
+ ServiceIsolate::Shutdown();
- ShutdownIsolate();
- vm_isolate_ = NULL;
- ASSERT(Isolate::IsolateListLength() == 0);
+ // Wait for the remaining isolate (service isolate) to shutdown
+ // before shutting down the thread pool.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n",
+ timestamp());
+ }
+ WaitForIsolateShutdown();
- TargetCPUFeatures::Cleanup();
- StoreBuffer::ShutDown();
+ // Shutdown the thread pool. On return, all thread pool threads have exited.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting thread pool\n",
+ timestamp());
+ }
+ delete thread_pool_;
+ thread_pool_ = NULL;
+
+ // Disable creation of any new OSThread structures which means no more new
+ // threads can do an EnterIsolate. This must come after isolate shutdown
+ // because new threads may need to be spawned to shutdown the isolates.
+ // This must come after deletion of the thread pool to avoid a race in which
+ // a thread spawned by the thread pool does not exit through the thread
+ // pool, messing up its bookkeeping.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling OS Thread creation\n",
+ timestamp());
+ }
+ OSThread::DisableOSThreadCreation();
- // Delete the current thread's TLS and set it's TLS to null.
- // If it is the last thread then the destructor would call
- // OSThread::Cleanup.
- OSThread* os_thread = OSThread::Current();
- OSThread::SetCurrent(NULL);
- delete os_thread;
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleted os_thread\n",
- timestamp());
- }
- } else {
- // Shutdown the service isolate.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n",
- timestamp());
- }
- ServiceIsolate::Shutdown();
+ // Set the VM isolate as current isolate.
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Cleaning up vm isolate\n",
+ timestamp());
+ }
+ bool result = Thread::EnterIsolate(vm_isolate_);
+ ASSERT(result);
- // Disable thread creation.
- if (FLAG_trace_shutdown) {
- OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling OS Thread creation\n",
- timestamp());
- }
- OSThread::DisableOSThreadCreation();
+ ShutdownIsolate();
+ vm_isolate_ = NULL;
+ ASSERT(Isolate::IsolateListLength() == 0);
+
+ TargetCPUFeatures::Cleanup();
+ StoreBuffer::ShutDown();
+
+ // Delete the current thread's TLS and set it's TLS to null.
+ // If it is the last thread then the destructor would call
+ // OSThread::Cleanup.
+ OSThread* os_thread = OSThread::Current();
+ OSThread::SetCurrent(NULL);
+ delete os_thread;
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleted os_thread\n",
+ timestamp());
}
if (FLAG_trace_shutdown) {
« runtime/bin/loader.cc ('K') | « runtime/bin/main.cc ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698