| Index: src/optimizing-compiler-thread.cc
|
| diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc
|
| index 788f0270611eb913300e8877c02c1d172505da57..96847dcc84d76ad75949a136c4125dcf0e8bc7da 100644
|
| --- a/src/optimizing-compiler-thread.cc
|
| +++ b/src/optimizing-compiler-thread.cc
|
| @@ -39,7 +39,7 @@ namespace internal {
|
|
|
| void OptimizingCompilerThread::Run() {
|
| #ifdef DEBUG
|
| - { ScopedLock lock(thread_id_mutex_);
|
| + { LockGuard<Mutex> lock_guard(&thread_id_mutex_);
|
| thread_id_ = ThreadId::Current().ToInteger();
|
| }
|
| #endif
|
| @@ -48,11 +48,11 @@ void OptimizingCompilerThread::Run() {
|
| DisallowHandleAllocation no_handles;
|
| DisallowHandleDereference no_deref;
|
|
|
| - int64_t epoch = 0;
|
| - if (FLAG_trace_concurrent_recompilation) epoch = OS::Ticks();
|
| + ElapsedTimer total_timer;
|
| + if (FLAG_trace_concurrent_recompilation) total_timer.Start();
|
|
|
| while (true) {
|
| - input_queue_semaphore_->Wait();
|
| + input_queue_semaphore_.Wait();
|
| Logger::TimerEventScope timer(
|
| isolate_, Logger::TimerEventScope::v8_recompile_concurrent);
|
|
|
| @@ -65,9 +65,9 @@ void OptimizingCompilerThread::Run() {
|
| break;
|
| case STOP:
|
| if (FLAG_trace_concurrent_recompilation) {
|
| - time_spent_total_ = OS::Ticks() - epoch;
|
| + time_spent_total_ = total_timer.Elapsed();
|
| }
|
| - stop_semaphore_->Signal();
|
| + stop_semaphore_.Signal();
|
| return;
|
| case FLUSH:
|
| // The main thread is blocked, waiting for the stop semaphore.
|
| @@ -76,18 +76,18 @@ void OptimizingCompilerThread::Run() {
|
| }
|
| Release_Store(&queue_length_, static_cast<AtomicWord>(0));
|
| Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
|
| - stop_semaphore_->Signal();
|
| + stop_semaphore_.Signal();
|
| // Return to start of consumer loop.
|
| continue;
|
| }
|
|
|
| - int64_t compiling_start = 0;
|
| - if (FLAG_trace_concurrent_recompilation) compiling_start = OS::Ticks();
|
| + ElapsedTimer compiling_timer;
|
| + if (FLAG_trace_concurrent_recompilation) compiling_timer.Start();
|
|
|
| CompileNext();
|
|
|
| if (FLAG_trace_concurrent_recompilation) {
|
| - time_spent_compiling_ += OS::Ticks() - compiling_start;
|
| + time_spent_compiling_ += compiling_timer.Elapsed();
|
| }
|
| }
|
| }
|
| @@ -108,7 +108,7 @@ void OptimizingCompilerThread::CompileNext() {
|
| // The function may have already been optimized by OSR. Simply continue.
|
| // Use a mutex to make sure that functions marked for install
|
| // are always also queued.
|
| - ScopedLock mark_and_queue(install_mutex_);
|
| + LockGuard<Mutex> mark_and_queue(&install_mutex_);
|
| { Heap::RelocationLock relocation_lock(isolate_->heap());
|
| AllowHandleDereference ahd;
|
| optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
|
| @@ -123,7 +123,7 @@ void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) {
|
| while (input_queue_.Dequeue(&optimizing_compiler)) {
|
| // This should not block, since we have one signal on the input queue
|
| // semaphore corresponding to each element in the input queue.
|
| - input_queue_semaphore_->Wait();
|
| + input_queue_semaphore_.Wait();
|
| CompilationInfo* info = optimizing_compiler->info();
|
| if (restore_function_code) {
|
| Handle<JSFunction> function = info->closure();
|
| @@ -151,8 +151,8 @@ void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) {
|
| void OptimizingCompilerThread::Flush() {
|
| ASSERT(!IsOptimizerThread());
|
| Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH));
|
| - input_queue_semaphore_->Signal();
|
| - stop_semaphore_->Wait();
|
| + input_queue_semaphore_.Signal();
|
| + stop_semaphore_.Wait();
|
| FlushOutputQueue(true);
|
| }
|
|
|
| @@ -160,8 +160,8 @@ void OptimizingCompilerThread::Flush() {
|
| void OptimizingCompilerThread::Stop() {
|
| ASSERT(!IsOptimizerThread());
|
| Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP));
|
| - input_queue_semaphore_->Signal();
|
| - stop_semaphore_->Wait();
|
| + input_queue_semaphore_.Signal();
|
| + stop_semaphore_.Wait();
|
|
|
| if (FLAG_concurrent_recompilation_delay != 0) {
|
| // Barrier when loading queue length is not necessary since the write
|
| @@ -175,9 +175,7 @@ void OptimizingCompilerThread::Stop() {
|
| }
|
|
|
| if (FLAG_trace_concurrent_recompilation) {
|
| - double compile_time = static_cast<double>(time_spent_compiling_);
|
| - double total_time = static_cast<double>(time_spent_total_);
|
| - double percentage = (compile_time * 100) / total_time;
|
| + double percentage = time_spent_compiling_.PercentOf(time_spent_total_);
|
| PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
|
| }
|
|
|
| @@ -191,7 +189,7 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() {
|
| OptimizingCompiler* compiler;
|
| while (true) {
|
| { // Memory barrier to ensure marked functions are queued.
|
| - ScopedLock marked_and_queued(install_mutex_);
|
| + LockGuard<Mutex> marked_and_queued(&install_mutex_);
|
| if (!output_queue_.Dequeue(&compiler)) return;
|
| }
|
| Compiler::InstallOptimizedCode(compiler);
|
| @@ -206,14 +204,14 @@ void OptimizingCompilerThread::QueueForOptimization(
|
| Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1));
|
| optimizing_compiler->info()->closure()->MarkInRecompileQueue();
|
| input_queue_.Enqueue(optimizing_compiler);
|
| - input_queue_semaphore_->Signal();
|
| + input_queue_semaphore_.Signal();
|
| }
|
|
|
|
|
| #ifdef DEBUG
|
| bool OptimizingCompilerThread::IsOptimizerThread() {
|
| if (!FLAG_concurrent_recompilation) return false;
|
| - ScopedLock lock(thread_id_mutex_);
|
| + LockGuard<Mutex> lock_guard(&thread_id_mutex_);
|
| return ThreadId::Current().ToInteger() == thread_id_;
|
| }
|
| #endif
|
|
|