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

Unified Diff: src/optimizing-compiler-thread.cc

Issue 23902033: Add mutex when accessing concurrent recompilation output queue. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 7 years, 3 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/optimizing-compiler-thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/optimizing-compiler-thread.cc
diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc
index 085143d99839e353b15b7793e606c05b78eff66f..8d5e16636d267cf33915635d8fd65e6e2d40e92a 100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -74,7 +74,6 @@ void OptimizingCompilerThread::Run() {
{ AllowHandleDereference allow_handle_dereference;
FlushInputQueue(true);
}
- Release_Store(&queue_length_, static_cast<AtomicWord>(0));
Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
stop_semaphore_.Signal();
// Return to start of consumer loop.
@@ -114,6 +113,7 @@ void OptimizingCompilerThread::CompileNext() {
osr_candidates_.RemoveElement(optimizing_compiler);
ready_for_osr_.Add(optimizing_compiler);
} else {
+ LockGuard<Mutex> access_queue(&queue_mutex_);
output_queue_.Enqueue(optimizing_compiler);
isolate_->stack_guard()->RequestInstallCode();
}
@@ -134,13 +134,20 @@ void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) {
}
delete info;
}
+ Release_Store(&queue_length_, static_cast<AtomicWord>(0));
+
+ LockGuard<Mutex> access_osr_lists(&osr_list_mutex_);
+ osr_candidates_.Clear();
}
void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) {
OptimizingCompiler* optimizing_compiler;
// The optimizing compiler is allocated in the CompilationInfo's zone.
- while (output_queue_.Dequeue(&optimizing_compiler)) {
+ while (true) {
+ { LockGuard<Mutex> access_queue(&queue_mutex_);
+ if (!output_queue_.Dequeue(&optimizing_compiler)) break;
+ }
CompilationInfo* info = optimizing_compiler->info();
if (restore_function_code) {
Handle<JSFunction> function = info->closure();
@@ -149,7 +156,6 @@ void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) {
delete info;
}
- osr_candidates_.Clear();
RemoveStaleOSRCandidates(0);
}
@@ -196,9 +202,12 @@ void OptimizingCompilerThread::Stop() {
void OptimizingCompilerThread::InstallOptimizedFunctions() {
ASSERT(!IsOptimizerThread());
HandleScope handle_scope(isolate_);
+
OptimizingCompiler* compiler;
while (true) {
- if (!output_queue_.Dequeue(&compiler)) return;
+ { LockGuard<Mutex> access_queue(&queue_mutex_);
+ if (!output_queue_.Dequeue(&optimizing_compiler)) break;
+ }
Compiler::InstallOptimizedCode(compiler);
}
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698