Revision: 15262
Author: [email protected]
Date: Fri Jun 21 01:38:12 2013
Log: Use mutex instead of busy wait when installing optimized function.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/17099012
http://code.google.com/p/v8/source/detail?r=15262
Modified:
/branches/bleeding_edge/src/optimizing-compiler-thread.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Fri Jun 21
01:37:05 2013
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Fri Jun 21
01:38:12 2013
@@ -89,8 +89,9 @@
ASSERT(status != OptimizingCompiler::FAILED);
// The function may have already been optimized by OSR. Simply continue.
- // Mark it for installing before queuing so that we can be sure of the
write
- // order: marking first and (after being queued) installing code second.
+ // Use a mutex to make sure that functions marked for install
+ // are always also queued.
+ ScopedLock mark_and_queue(install_mutex_);
{ Heap::RelocationLock relocation_lock(isolate_->heap());
AllowHandleDereference ahd;
optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
@@ -130,11 +131,13 @@
void OptimizingCompilerThread::InstallOptimizedFunctions() {
ASSERT(!IsOptimizerThread());
HandleScope handle_scope(isolate_);
- int functions_installed = 0;
OptimizingCompiler* compiler;
- while (output_queue_.Dequeue(&compiler)) {
+ while (true) {
+ { // Memory barrier to ensure marked functions are queued.
+ ScopedLock marked_and_queued(install_mutex_);
+ if (!output_queue_.Dequeue(&compiler)) return;
+ }
Compiler::InstallOptimizedCode(compiler);
- functions_installed++;
}
}
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.h Wed Mar 13
04:44:07 2013
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.h Fri Jun 21
01:38:12 2013
@@ -50,6 +50,7 @@
isolate_(isolate),
stop_semaphore_(OS::CreateSemaphore(0)),
input_queue_semaphore_(OS::CreateSemaphore(0)),
+ install_mutex_(OS::CreateMutex()),
time_spent_compiling_(0),
time_spent_total_(0) {
NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
@@ -95,6 +96,7 @@
Semaphore* input_queue_semaphore_;
UnboundQueue<OptimizingCompiler*> input_queue_;
UnboundQueue<OptimizingCompiler*> output_queue_;
+ Mutex* install_mutex_;
volatile AtomicWord stop_thread_;
volatile Atomic32 queue_length_;
int64_t time_spent_compiling_;
=======================================
--- /branches/bleeding_edge/src/runtime.cc Thu Jun 20 05:59:45 2013
+++ /branches/bleeding_edge/src/runtime.cc Fri Jun 21 01:38:12 2013
@@ -7912,12 +7912,7 @@
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
ASSERT(V8::UseCrankshaft() && FLAG_parallel_recompilation);
- OptimizingCompilerThread* opt_thread =
isolate->optimizing_compiler_thread();
- do {
- // The function could have been marked for installing, but not queued
just
- // yet. In this case, retry until installed.
- opt_thread->InstallOptimizedFunctions();
- } while (function->IsMarkedForInstallingRecompiledCode());
+ isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
return function->code();
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.