diff --git a/src/d8.cc b/src/d8.cc index 5fd99174d2..ea723dc7d2 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -1378,6 +1378,7 @@ void Shell::OnExit() { "-------------+\n"); delete [] counters; } + delete context_mutex_; delete counters_file_; delete counter_map_; #endif // V8_SHARED diff --git a/src/isolate.cc b/src/isolate.cc index c8d9c3a4f6..cb63b2b3bf 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1548,6 +1548,14 @@ Isolate::ThreadDataTable::ThreadDataTable() } +Isolate::ThreadDataTable::~ThreadDataTable() { + // TODO(svenpanne) The assertion below would fire if an embedder does not + // cleanly dispose all Isolates before disposing v8, so we are conservative + // and leave it out for now. + // ASSERT_EQ(NULL, list_); +} + + Isolate::PerIsolateThreadData* Isolate::ThreadDataTable::Lookup(Isolate* isolate, ThreadId thread_id) { @@ -1735,6 +1743,11 @@ void Isolate::TearDown() { } +void Isolate::GlobalTearDown() { + delete thread_data_table_; +} + + void Isolate::Deinit() { if (state_ == INITIALIZED) { TRACE_ISOLATE(deinit); diff --git a/src/isolate.h b/src/isolate.h index df70ba9efd..b0142bff0d 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -470,6 +470,8 @@ class Isolate { // for legacy API reasons. void TearDown(); + static void GlobalTearDown(); + bool IsDefaultIsolate() const { return this == default_isolate_; } // Ensures that process-wide resources and the default isolate have been diff --git a/src/v8.cc b/src/v8.cc index 6c86d8ebba..1753650f25 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -115,6 +115,7 @@ void V8::TearDown() { LOperand::TearDownCaches(); ExternalReference::TearDownMathExpData(); RegisteredExtension::UnregisterAll(); + Isolate::GlobalTearDown(); is_running_ = false; has_been_disposed_ = true; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index a12c560a42..f94f658f46 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -16422,6 +16422,7 @@ TEST(IsolateDifferentContexts) { CHECK(v->IsNumber()); CHECK_EQ(22, static_cast(v->NumberValue())); } + isolate->Dispose(); } class InitDefaultIsolateThread : public v8::internal::Thread { diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc index b0f2b62236..cd37546510 100644 --- a/test/cctest/test-lockers.cc +++ b/test/cctest/test-lockers.cc @@ -289,6 +289,7 @@ TEST(IsolateNestedLocking) { threads.Add(new IsolateNestedLockingThread(isolate)); } StartJoinAndDeleteThreads(threads); + isolate->Dispose(); } @@ -584,6 +585,7 @@ TEST(LockUnlockLockMultithreaded) { threads.Add(new LockUnlockLockThread(isolate, context)); } StartJoinAndDeleteThreads(threads); + isolate->Dispose(); } class LockUnlockLockDefaultIsolateThread : public JoinableThread {