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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 return !current->IsWaitingForInstall(); | 339 return !current->IsWaitingForInstall(); |
340 } | 340 } |
341 } | 341 } |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 | 345 |
346 void OptimizingCompilerThread::AddToOsrBuffer(RecompileJob* job) { | 346 void OptimizingCompilerThread::AddToOsrBuffer(RecompileJob* job) { |
347 ASSERT(!IsOptimizerThread()); | 347 ASSERT(!IsOptimizerThread()); |
348 // Find the next slot that is empty or has a stale job. | 348 // Find the next slot that is empty or has a stale job. |
| 349 RecompileJob* stale; |
349 while (true) { | 350 while (true) { |
350 RecompileJob* stale = osr_buffer_[osr_buffer_cursor_]; | 351 stale = osr_buffer_[osr_buffer_cursor_]; |
351 if (stale == NULL || stale->IsWaitingForInstall()) break; | 352 if (stale == NULL || stale->IsWaitingForInstall()) break; |
352 osr_buffer_cursor_ = (osr_buffer_cursor_ + 1) % osr_buffer_capacity_; | 353 osr_buffer_cursor_ = (osr_buffer_cursor_ + 1) % osr_buffer_capacity_; |
353 } | 354 } |
354 | 355 |
355 // Add to found slot and dispose the evicted job. | 356 // Add to found slot and dispose the evicted job. |
356 RecompileJob* evicted = osr_buffer_[osr_buffer_cursor_]; | 357 if (stale != NULL) { |
357 if (evicted != NULL) { | 358 ASSERT(stale->IsWaitingForInstall()); |
358 ASSERT(evicted->IsWaitingForInstall()); | 359 CompilationInfo* info = stale->info(); |
359 CompilationInfo* info = evicted->info(); | |
360 if (FLAG_trace_osr) { | 360 if (FLAG_trace_osr) { |
361 PrintF("[COSR - Discarded "); | 361 PrintF("[COSR - Discarded "); |
362 info->closure()->PrintName(); | 362 info->closure()->PrintName(); |
363 PrintF(", AST id %d]\n", info->osr_ast_id().ToInt()); | 363 PrintF(", AST id %d]\n", info->osr_ast_id().ToInt()); |
364 } | 364 } |
365 DisposeRecompileJob(evicted, false); | 365 DisposeRecompileJob(stale, false); |
366 } | 366 } |
367 osr_buffer_[osr_buffer_cursor_] = job; | 367 osr_buffer_[osr_buffer_cursor_] = job; |
368 osr_buffer_cursor_ = (osr_buffer_cursor_ + 1) % osr_buffer_capacity_; | 368 osr_buffer_cursor_ = (osr_buffer_cursor_ + 1) % osr_buffer_capacity_; |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 #ifdef DEBUG | 372 #ifdef DEBUG |
373 bool OptimizingCompilerThread::IsOptimizerThread() { | 373 bool OptimizingCompilerThread::IsOptimizerThread() { |
374 if (!FLAG_concurrent_recompilation) return false; | 374 if (!FLAG_concurrent_recompilation) return false; |
375 LockGuard<Mutex> lock_guard(&thread_id_mutex_); | 375 LockGuard<Mutex> lock_guard(&thread_id_mutex_); |
376 return ThreadId::Current().ToInteger() == thread_id_; | 376 return ThreadId::Current().ToInteger() == thread_id_; |
377 } | 377 } |
378 #endif | 378 #endif |
379 | 379 |
380 | 380 |
381 } } // namespace v8::internal | 381 } } // namespace v8::internal |
OLD | NEW |