Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/optimizing-compiler-thread.h" | 5 #include "src/optimizing-compiler-thread.h" |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/full-codegen.h" | 9 #include "src/full-codegen.h" |
| 10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 while (true) { | 45 while (true) { |
| 46 input_queue_semaphore_.Wait(); | 46 input_queue_semaphore_.Wait(); |
| 47 Logger::TimerEventScope timer( | 47 Logger::TimerEventScope timer( |
| 48 isolate_, Logger::TimerEventScope::v8_recompile_concurrent); | 48 isolate_, Logger::TimerEventScope::v8_recompile_concurrent); |
| 49 | 49 |
| 50 if (FLAG_concurrent_recompilation_delay != 0) { | 50 if (FLAG_concurrent_recompilation_delay != 0) { |
| 51 OS::Sleep(FLAG_concurrent_recompilation_delay); | 51 OS::Sleep(FLAG_concurrent_recompilation_delay); |
| 52 } | 52 } |
| 53 | 53 |
| 54 switch (static_cast<StopFlag>(Acquire_Load(&stop_thread_))) { | 54 switch (static_cast<StopFlag>(base::Acquire_Load(&stop_thread_))) { |
|
Jakob Kummerow
2014/06/05 11:49:06
IWYU?
| |
| 55 case CONTINUE: | 55 case CONTINUE: |
| 56 break; | 56 break; |
| 57 case STOP: | 57 case STOP: |
| 58 if (FLAG_trace_concurrent_recompilation) { | 58 if (FLAG_trace_concurrent_recompilation) { |
| 59 time_spent_total_ = total_timer.Elapsed(); | 59 time_spent_total_ = total_timer.Elapsed(); |
| 60 } | 60 } |
| 61 stop_semaphore_.Signal(); | 61 stop_semaphore_.Signal(); |
| 62 return; | 62 return; |
| 63 case FLUSH: | 63 case FLUSH: |
| 64 // The main thread is blocked, waiting for the stop semaphore. | 64 // The main thread is blocked, waiting for the stop semaphore. |
| 65 { AllowHandleDereference allow_handle_dereference; | 65 { AllowHandleDereference allow_handle_dereference; |
| 66 FlushInputQueue(true); | 66 FlushInputQueue(true); |
| 67 } | 67 } |
| 68 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); | 68 base::Release_Store(&stop_thread_, |
| 69 static_cast<base::AtomicWord>(CONTINUE)); | |
| 69 stop_semaphore_.Signal(); | 70 stop_semaphore_.Signal(); |
| 70 // Return to start of consumer loop. | 71 // Return to start of consumer loop. |
| 71 continue; | 72 continue; |
| 72 } | 73 } |
| 73 | 74 |
| 74 ElapsedTimer compiling_timer; | 75 ElapsedTimer compiling_timer; |
| 75 if (FLAG_trace_concurrent_recompilation) compiling_timer.Start(); | 76 if (FLAG_trace_concurrent_recompilation) compiling_timer.Start(); |
| 76 | 77 |
| 77 CompileNext(); | 78 CompileNext(); |
| 78 | 79 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 if (osr_buffer_[i] != NULL) { | 163 if (osr_buffer_[i] != NULL) { |
| 163 DisposeOptimizedCompileJob(osr_buffer_[i], restore_function_code); | 164 DisposeOptimizedCompileJob(osr_buffer_[i], restore_function_code); |
| 164 osr_buffer_[i] = NULL; | 165 osr_buffer_[i] = NULL; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 } | 168 } |
| 168 | 169 |
| 169 | 170 |
| 170 void OptimizingCompilerThread::Flush() { | 171 void OptimizingCompilerThread::Flush() { |
| 171 ASSERT(!IsOptimizerThread()); | 172 ASSERT(!IsOptimizerThread()); |
| 172 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH)); | 173 base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(FLUSH)); |
| 173 if (FLAG_block_concurrent_recompilation) Unblock(); | 174 if (FLAG_block_concurrent_recompilation) Unblock(); |
| 174 input_queue_semaphore_.Signal(); | 175 input_queue_semaphore_.Signal(); |
| 175 stop_semaphore_.Wait(); | 176 stop_semaphore_.Wait(); |
| 176 FlushOutputQueue(true); | 177 FlushOutputQueue(true); |
| 177 if (FLAG_concurrent_osr) FlushOsrBuffer(true); | 178 if (FLAG_concurrent_osr) FlushOsrBuffer(true); |
| 178 if (FLAG_trace_concurrent_recompilation) { | 179 if (FLAG_trace_concurrent_recompilation) { |
| 179 PrintF(" ** Flushed concurrent recompilation queues.\n"); | 180 PrintF(" ** Flushed concurrent recompilation queues.\n"); |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| 183 | 184 |
| 184 void OptimizingCompilerThread::Stop() { | 185 void OptimizingCompilerThread::Stop() { |
| 185 ASSERT(!IsOptimizerThread()); | 186 ASSERT(!IsOptimizerThread()); |
| 186 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP)); | 187 base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(STOP)); |
| 187 if (FLAG_block_concurrent_recompilation) Unblock(); | 188 if (FLAG_block_concurrent_recompilation) Unblock(); |
| 188 input_queue_semaphore_.Signal(); | 189 input_queue_semaphore_.Signal(); |
| 189 stop_semaphore_.Wait(); | 190 stop_semaphore_.Wait(); |
| 190 | 191 |
| 191 if (FLAG_concurrent_recompilation_delay != 0) { | 192 if (FLAG_concurrent_recompilation_delay != 0) { |
| 192 // At this point the optimizing compiler thread's event loop has stopped. | 193 // At this point the optimizing compiler thread's event loop has stopped. |
| 193 // There is no need for a mutex when reading input_queue_length_. | 194 // There is no need for a mutex when reading input_queue_length_. |
| 194 while (input_queue_length_ > 0) CompileNext(); | 195 while (input_queue_length_ > 0) CompileNext(); |
| 195 InstallOptimizedFunctions(); | 196 InstallOptimizedFunctions(); |
| 196 } else { | 197 } else { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 363 |
| 363 | 364 |
| 364 bool OptimizingCompilerThread::IsOptimizerThread() { | 365 bool OptimizingCompilerThread::IsOptimizerThread() { |
| 365 LockGuard<Mutex> lock_guard(&thread_id_mutex_); | 366 LockGuard<Mutex> lock_guard(&thread_id_mutex_); |
| 366 return ThreadId::Current().ToInteger() == thread_id_; | 367 return ThreadId::Current().ToInteger() == thread_id_; |
| 367 } | 368 } |
| 368 #endif | 369 #endif |
| 369 | 370 |
| 370 | 371 |
| 371 } } // namespace v8::internal | 372 } } // namespace v8::internal |
| OLD | NEW |