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

Unified Diff: src/runtime-profiler.cc

Issue 7309013: Fix a few issues breaking cctest/test-lockers/Regress1433: (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8threads.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index c0eaf98779d4fff6636828f9c844af0b2fb9df3f..7a0dd91f706b067922180c5875d91aa1cdf8aeb6 100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -323,9 +323,26 @@ bool RuntimeProfiler::WaitForSomeIsolateToEnterJS() {
}
-void RuntimeProfiler::WakeUpRuntimeProfilerThreadBeforeShutdown() {
+void RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(Thread* thread) {
#ifdef ENABLE_LOGGING_AND_PROFILING
- semaphore_->Signal();
+ // Do a fake increment. If the profiler is waiting on the semaphore,
+ // the returned state is 0, which can be left as an initial state in
+ // case profiling is restarted later. If the profiler is not
+ // waiting, the increment will prevent it from waiting, but has to
+ // be undone after the profiler is stopped.
+ Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, 1);
+ ASSERT(new_state >= 0);
+ if (new_state == 0) {
+ // The profiler thread is waiting. Wake it up. It must check for
+ // stop conditions before attempting to wait again.
+ semaphore_->Signal();
+ }
+ thread->Join();
+ // The profiler thread is now stopped. Undo the increment in case it
+ // was not waiting.
+ if (new_state != 0) {
+ NoBarrier_AtomicIncrement(&state_, -1);
+ }
#endif
}
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698