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/compiler-dispatcher/optimizing-compile-dispatcher.h" | 5 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_); | 127 base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_); |
128 if (output_queue_.empty()) return; | 128 if (output_queue_.empty()) return; |
129 job = output_queue_.front(); | 129 job = output_queue_.front(); |
130 output_queue_.pop(); | 130 output_queue_.pop(); |
131 } | 131 } |
132 | 132 |
133 DisposeCompilationJob(job, restore_function_code); | 133 DisposeCompilationJob(job, restore_function_code); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void OptimizingCompileDispatcher::Flush() { | 137 void OptimizingCompileDispatcher::Flush(BlockingBehavior blocking_behavior) { |
| 138 if (FLAG_block_concurrent_recompilation) Unblock(); |
| 139 if (blocking_behavior == BlockingBehavior::kDontBlock) { |
| 140 base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_); |
| 141 while (input_queue_length_ > 0) { |
| 142 CompilationJob* job = input_queue_[InputQueueIndex(0)]; |
| 143 DCHECK_NOT_NULL(job); |
| 144 input_queue_shift_ = InputQueueIndex(1); |
| 145 input_queue_length_--; |
| 146 DisposeCompilationJob(job, true); |
| 147 } |
| 148 FlushOutputQueue(true); |
| 149 if (FLAG_trace_concurrent_recompilation) { |
| 150 PrintF(" ** Flushed concurrent recompilation queues (not blocking).\n"); |
| 151 } |
| 152 return; |
| 153 } |
138 base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH)); | 154 base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH)); |
139 if (FLAG_block_concurrent_recompilation) Unblock(); | 155 if (FLAG_block_concurrent_recompilation) Unblock(); |
140 { | 156 { |
141 base::LockGuard<base::Mutex> lock_guard(&ref_count_mutex_); | 157 base::LockGuard<base::Mutex> lock_guard(&ref_count_mutex_); |
142 while (ref_count_ > 0) ref_count_zero_.Wait(&ref_count_mutex_); | 158 while (ref_count_ > 0) ref_count_zero_.Wait(&ref_count_mutex_); |
143 base::Release_Store(&mode_, static_cast<base::AtomicWord>(COMPILE)); | 159 base::Release_Store(&mode_, static_cast<base::AtomicWord>(COMPILE)); |
144 } | 160 } |
145 FlushOutputQueue(true); | 161 FlushOutputQueue(true); |
146 if (FLAG_trace_concurrent_recompilation) { | 162 if (FLAG_trace_concurrent_recompilation) { |
147 PrintF(" ** Flushed concurrent recompilation queues.\n"); | 163 PrintF(" ** Flushed concurrent recompilation queues.\n"); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 void OptimizingCompileDispatcher::Unblock() { | 229 void OptimizingCompileDispatcher::Unblock() { |
214 while (blocked_jobs_ > 0) { | 230 while (blocked_jobs_ > 0) { |
215 V8::GetCurrentPlatform()->CallOnBackgroundThread( | 231 V8::GetCurrentPlatform()->CallOnBackgroundThread( |
216 new CompileTask(isolate_), v8::Platform::kShortRunningTask); | 232 new CompileTask(isolate_), v8::Platform::kShortRunningTask); |
217 blocked_jobs_--; | 233 blocked_jobs_--; |
218 } | 234 } |
219 } | 235 } |
220 | 236 |
221 } // namespace internal | 237 } // namespace internal |
222 } // namespace v8 | 238 } // namespace v8 |
OLD | NEW |