Index: src/optimizing-compiler-thread.cc |
diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc |
index b0e37fdc8b2a8ef74d38e98b70d251058a6de581..a040453e4284be23c782b79444847dbc680f7506 100644 |
--- a/src/optimizing-compiler-thread.cc |
+++ b/src/optimizing-compiler-thread.cc |
@@ -234,14 +234,18 @@ void OptimizingCompilerThread::QueueForOptimization( |
OptimizingCompiler* OptimizingCompilerThread::FindReadyOSRCandidate( |
Handle<JSFunction> function, uint32_t osr_pc_offset) { |
ASSERT(!IsOptimizerThread()); |
- LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); |
- for (int i = 0; i < ready_for_osr_.length(); i++) { |
- if (ready_for_osr_[i]->info()->HasSameOsrEntry(function, osr_pc_offset)) { |
- osr_hits_++; |
- return ready_for_osr_.Remove(i); |
+ OptimizingCompiler* result = NULL; |
+ { LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); |
+ for (int i = 0; i < ready_for_osr_.length(); i++) { |
+ if (ready_for_osr_[i]->info()->HasSameOsrEntry(function, osr_pc_offset)) { |
+ osr_hits_++; |
+ result = ready_for_osr_.Remove(i); |
+ break; |
+ } |
} |
} |
- return NULL; |
+ RemoveStaleOSRCandidates(); |
+ return result; |
} |
@@ -258,6 +262,18 @@ bool OptimizingCompilerThread::IsQueuedForOSR(Handle<JSFunction> function, |
} |
+bool OptimizingCompilerThread::IsQueuedForOSR(JSFunction* function) { |
+ ASSERT(!IsOptimizerThread()); |
+ LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); |
+ for (int i = 0; i < osr_candidates_.length(); i++) { |
+ if (*osr_candidates_[i]->info()->closure() == function) { |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
+ |
void OptimizingCompilerThread::RemoveStaleOSRCandidates(int limit) { |
ASSERT(!IsOptimizerThread()); |
LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); |