OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 job = osr_buffer_[i]; | 161 job = osr_buffer_[i]; |
162 if (job != NULL) DisposeRecompileJob(job, restore_function_code); | 162 if (job != NULL) DisposeRecompileJob(job, restore_function_code); |
163 } | 163 } |
164 osr_cursor_ = 0; | 164 osr_cursor_ = 0; |
165 } | 165 } |
166 | 166 |
167 | 167 |
168 void OptimizingCompilerThread::Flush() { | 168 void OptimizingCompilerThread::Flush() { |
169 ASSERT(!IsOptimizerThread()); | 169 ASSERT(!IsOptimizerThread()); |
170 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH)); | 170 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH)); |
| 171 if (FLAG_block_concurrent_recompilation) Unblock(); |
171 input_queue_semaphore_.Signal(); | 172 input_queue_semaphore_.Signal(); |
172 stop_semaphore_.Wait(); | 173 stop_semaphore_.Wait(); |
173 FlushOutputQueue(true); | 174 FlushOutputQueue(true); |
174 if (FLAG_concurrent_osr) FlushOsrBuffer(true); | 175 if (FLAG_concurrent_osr) FlushOsrBuffer(true); |
175 if (FLAG_trace_concurrent_recompilation) { | 176 if (FLAG_trace_concurrent_recompilation) { |
176 PrintF(" ** Flushed concurrent recompilation queues.\n"); | 177 PrintF(" ** Flushed concurrent recompilation queues.\n"); |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 | 181 |
181 void OptimizingCompilerThread::Stop() { | 182 void OptimizingCompilerThread::Stop() { |
182 ASSERT(!IsOptimizerThread()); | 183 ASSERT(!IsOptimizerThread()); |
183 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP)); | 184 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP)); |
| 185 if (FLAG_block_concurrent_recompilation) Unblock(); |
184 input_queue_semaphore_.Signal(); | 186 input_queue_semaphore_.Signal(); |
185 stop_semaphore_.Wait(); | 187 stop_semaphore_.Wait(); |
186 | 188 |
187 if (FLAG_concurrent_recompilation_delay != 0) { | 189 if (FLAG_concurrent_recompilation_delay != 0) { |
188 // Barrier when loading queue length is not necessary since the write | 190 // Barrier when loading queue length is not necessary since the write |
189 // happens in CompileNext on the same thread. | 191 // happens in CompileNext on the same thread. |
190 // This is used only for testing. | 192 // This is used only for testing. |
191 while (NoBarrier_Load(&queue_length_) > 0) CompileNext(); | 193 while (NoBarrier_Load(&queue_length_) > 0) CompileNext(); |
192 InstallOptimizedFunctions(); | 194 InstallOptimizedFunctions(); |
193 } else { | 195 } else { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 info->closure()->PrintName(); | 247 info->closure()->PrintName(); |
246 PrintF(" for concurrent on-stack replacement.\n"); | 248 PrintF(" for concurrent on-stack replacement.\n"); |
247 } | 249 } |
248 AddToOsrBuffer(job); | 250 AddToOsrBuffer(job); |
249 osr_attempts_++; | 251 osr_attempts_++; |
250 BackEdgeTable::AddStackCheck(info); | 252 BackEdgeTable::AddStackCheck(info); |
251 } else { | 253 } else { |
252 info->closure()->MarkInRecompileQueue(); | 254 info->closure()->MarkInRecompileQueue(); |
253 } | 255 } |
254 input_queue_.Enqueue(job); | 256 input_queue_.Enqueue(job); |
255 input_queue_semaphore_.Signal(); | 257 if (FLAG_block_concurrent_recompilation) { |
| 258 blocked_jobs_++; |
| 259 } else { |
| 260 input_queue_semaphore_.Signal(); |
| 261 } |
256 } | 262 } |
257 | 263 |
258 | 264 |
| 265 void OptimizingCompilerThread::Unblock() { |
| 266 ASSERT(!IsOptimizerThread()); |
| 267 while (blocked_jobs_ > 0) { |
| 268 input_queue_semaphore_.Signal(); |
| 269 blocked_jobs_--; |
| 270 } |
| 271 } |
| 272 |
| 273 |
259 RecompileJob* OptimizingCompilerThread::FindReadyOSRCandidate( | 274 RecompileJob* OptimizingCompilerThread::FindReadyOSRCandidate( |
260 Handle<JSFunction> function, uint32_t osr_pc_offset) { | 275 Handle<JSFunction> function, uint32_t osr_pc_offset) { |
261 ASSERT(!IsOptimizerThread()); | 276 ASSERT(!IsOptimizerThread()); |
262 RecompileJob* result = NULL; | 277 RecompileJob* result = NULL; |
263 for (int i = 0; i < osr_buffer_size_; i++) { | 278 for (int i = 0; i < osr_buffer_size_; i++) { |
264 result = osr_buffer_[i]; | 279 result = osr_buffer_[i]; |
265 if (result == NULL) continue; | 280 if (result == NULL) continue; |
266 if (result->IsWaitingForInstall() && | 281 if (result->IsWaitingForInstall() && |
267 result->info()->HasSameOsrEntry(function, osr_pc_offset)) { | 282 result->info()->HasSameOsrEntry(function, osr_pc_offset)) { |
268 osr_hits_++; | 283 osr_hits_++; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 #ifdef DEBUG | 343 #ifdef DEBUG |
329 bool OptimizingCompilerThread::IsOptimizerThread() { | 344 bool OptimizingCompilerThread::IsOptimizerThread() { |
330 if (!FLAG_concurrent_recompilation) return false; | 345 if (!FLAG_concurrent_recompilation) return false; |
331 LockGuard<Mutex> lock_guard(&thread_id_mutex_); | 346 LockGuard<Mutex> lock_guard(&thread_id_mutex_); |
332 return ThreadId::Current().ToInteger() == thread_id_; | 347 return ThreadId::Current().ToInteger() == thread_id_; |
333 } | 348 } |
334 #endif | 349 #endif |
335 | 350 |
336 | 351 |
337 } } // namespace v8::internal | 352 } } // namespace v8::internal |
OLD | NEW |