From 92523a455370e12fcc001f5001e4b4e4e6b4cf12 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Tue, 2 Jul 2013 09:04:45 +0000 Subject: [PATCH] Join threads after stopping. R=hpayer@chromium.org BUG= Review URL: https://codereview.chromium.org/18287003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15439 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/marking-thread.cc | 1 + src/optimizing-compiler-thread.cc | 2 ++ src/sweeper-thread.cc | 1 + test/cctest/test-mark-compact.cc | 21 +++++++++++++++++++++ 4 files changed, 25 insertions(+) diff --git a/src/marking-thread.cc b/src/marking-thread.cc index 574485a..ac9f944 100644 --- a/src/marking-thread.cc +++ b/src/marking-thread.cc @@ -73,6 +73,7 @@ void MarkingThread::Stop() { Release_Store(&stop_thread_, static_cast(true)); start_marking_semaphore_->Signal(); stop_semaphore_->Wait(); + Join(); } diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc index a4300f5..21ef237 100644 --- a/src/optimizing-compiler-thread.cc +++ b/src/optimizing-compiler-thread.cc @@ -130,6 +130,8 @@ void OptimizingCompilerThread::Stop() { double percentage = (compile_time * 100) / total_time; PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); } + + Join(); } diff --git a/src/sweeper-thread.cc b/src/sweeper-thread.cc index 099f5d1..ede567a 100644 --- a/src/sweeper-thread.cc +++ b/src/sweeper-thread.cc @@ -93,6 +93,7 @@ void SweeperThread::Stop() { Release_Store(&stop_thread_, static_cast(true)); start_sweeping_semaphore_->Signal(); stop_semaphore_->Wait(); + Join(); } diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc index a01c5df..0709704 100644 --- a/test/cctest/test-mark-compact.cc +++ b/test/cctest/test-mark-compact.cc @@ -566,4 +566,25 @@ TEST(BootUpMemoryUse) { } } + +intptr_t ShortLivingIsolate() { + v8::Isolate* isolate = v8::Isolate::New(); + { v8::Isolate::Scope isolate_scope(isolate); + v8::Locker lock(isolate); + v8::HandleScope handle_scope; + v8::Local context = v8::Context::New(isolate); + CHECK(!context.IsEmpty()); + } + isolate->Dispose(); + return MemoryInUse(); +} + + +TEST(RegressJoinThreadsOnIsolateDeinit) { + intptr_t first_size = ShortLivingIsolate(); + for (int i = 0; i < 10; i++) { + CHECK_EQ(first_size, ShortLivingIsolate()); + } +} + #endif // __linux__ and !USE_SIMULATOR -- 2.7.4