diff options
Diffstat (limited to 'deps/v8/src/optimizing-compiler-thread.h')
-rw-r--r-- | deps/v8/src/optimizing-compiler-thread.h | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/deps/v8/src/optimizing-compiler-thread.h b/deps/v8/src/optimizing-compiler-thread.h index cbd4d0e487..d1ed6a2c59 100644 --- a/deps/v8/src/optimizing-compiler-thread.h +++ b/deps/v8/src/optimizing-compiler-thread.h @@ -30,7 +30,10 @@ #include "atomicops.h" #include "flags.h" +#include "list.h" #include "platform.h" +#include "platform/mutex.h" +#include "platform/time.h" #include "unbound-queue-inl.h" namespace v8 { @@ -46,23 +49,29 @@ class OptimizingCompilerThread : public Thread { Thread("OptimizingCompilerThread"), #ifdef DEBUG thread_id_(0), - thread_id_mutex_(OS::CreateMutex()), #endif isolate_(isolate), - stop_semaphore_(OS::CreateSemaphore(0)), - input_queue_semaphore_(OS::CreateSemaphore(0)), - install_mutex_(OS::CreateMutex()), - time_spent_compiling_(0), - time_spent_total_(0) { + stop_semaphore_(0), + input_queue_semaphore_(0), + osr_candidates_(2), + ready_for_osr_(2), + osr_hits_(0), + osr_attempts_(0) { NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0)); } + ~OptimizingCompilerThread() {} void Run(); void Stop(); void Flush(); void QueueForOptimization(OptimizingCompiler* optimizing_compiler); void InstallOptimizedFunctions(); + OptimizingCompiler* FindReadyOSRCandidate(Handle<JSFunction> function, + uint32_t osr_pc_offset); + bool IsQueuedForOSR(Handle<JSFunction> function, uint32_t osr_pc_offset); + + bool IsQueuedForOSR(JSFunction* function); inline bool IsQueueAvailable() { // We don't need a barrier since we have a data dependency right @@ -75,45 +84,52 @@ class OptimizingCompilerThread : public Thread { // only one thread can run inside an Isolate at one time, a direct // doesn't introduce a race -- queue_length_ may decreased in // meantime, but not increased. - return (current_length < FLAG_parallel_recompilation_queue_length); + return (current_length < FLAG_concurrent_recompilation_queue_length); } #ifdef DEBUG bool IsOptimizerThread(); #endif - ~OptimizingCompilerThread() { - delete install_mutex_; - delete input_queue_semaphore_; - delete stop_semaphore_; -#ifdef DEBUG - delete thread_id_mutex_; -#endif - } - private: enum StopFlag { CONTINUE, STOP, FLUSH }; + // Remove the oldest OSR candidates that are ready so that we + // only have |limit| left waiting. + void RemoveStaleOSRCandidates(int limit = kReadyForOSRLimit); + void FlushInputQueue(bool restore_function_code); void FlushOutputQueue(bool restore_function_code); - void CompileNext(); #ifdef DEBUG int thread_id_; - Mutex* thread_id_mutex_; + Mutex thread_id_mutex_; #endif Isolate* isolate_; - Semaphore* stop_semaphore_; - Semaphore* input_queue_semaphore_; + Semaphore stop_semaphore_; + Semaphore input_queue_semaphore_; + + // Queue of incoming recompilation tasks (including OSR). UnboundQueue<OptimizingCompiler*> input_queue_; + // Queue of recompilation tasks ready to be installed (excluding OSR). UnboundQueue<OptimizingCompiler*> output_queue_; - Mutex* install_mutex_; + // List of all OSR related recompilation tasks (both incoming and ready ones). + List<OptimizingCompiler*> osr_candidates_; + // List of recompilation tasks ready for OSR. + List<OptimizingCompiler*> ready_for_osr_; + volatile AtomicWord stop_thread_; volatile Atomic32 queue_length_; - int64_t time_spent_compiling_; - int64_t time_spent_total_; + TimeDelta time_spent_compiling_; + TimeDelta time_spent_total_; + + Mutex osr_list_mutex_; + int osr_hits_; + int osr_attempts_; + + static const int kReadyForOSRLimit = 4; }; } } // namespace v8::internal |