| Index: src/optimizing-compiler-thread.h
|
| diff --git a/src/optimizing-compiler-thread.h b/src/optimizing-compiler-thread.h
|
| index eae1f608f9cb27a3e2841466ef65b012724dabf1..0d5a103fb01afee0df4fdd1a0f35abbffa8b591a 100644
|
| --- a/src/optimizing-compiler-thread.h
|
| +++ b/src/optimizing-compiler-thread.h
|
| @@ -29,6 +29,7 @@
|
| #define V8_OPTIMIZING_COMPILER_THREAD_H_
|
|
|
| #include "atomicops.h"
|
| +#include "assert-scope.h"
|
| #include "flags.h"
|
| #include "list.h"
|
| #include "platform.h"
|
| @@ -39,6 +40,7 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +class CompilationInfo;
|
| class HOptimizedGraphBuilder;
|
| class OptimizedCompileJob;
|
| class SharedFunctionInfo;
|
| @@ -53,6 +55,8 @@ class OptimizingCompilerThread : public Thread {
|
| isolate_(isolate),
|
| stop_semaphore_(0),
|
| input_queue_semaphore_(0),
|
| + main_thread_semaphore_(0),
|
| + compiler_thread_semaphore_(0),
|
| input_queue_capacity_(FLAG_concurrent_recompilation_queue_length),
|
| input_queue_length_(0),
|
| input_queue_shift_(0),
|
| @@ -61,7 +65,7 @@ class OptimizingCompilerThread : public Thread {
|
| osr_hits_(0),
|
| osr_attempts_(0),
|
| blocked_jobs_(0) {
|
| - NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
|
| + NoBarrier_Store(&loop_switch_, static_cast<AtomicWord>(CONTINUE));
|
| input_queue_ = NewArray<OptimizedCompileJob*>(input_queue_capacity_);
|
| if (FLAG_concurrent_osr) {
|
| // Allocate and mark OSR buffer slots as empty.
|
| @@ -85,7 +89,7 @@ class OptimizingCompilerThread : public Thread {
|
| bool IsQueuedForOSR(JSFunction* function);
|
|
|
| inline bool IsQueueAvailable() {
|
| - LockGuard<Mutex> access_input_queue(&input_queue_mutex_);
|
| + LockGuard<Mutex> access_input_queue(&mutex_);
|
| return input_queue_length_ < input_queue_capacity_;
|
| }
|
|
|
| @@ -105,12 +109,37 @@ class OptimizingCompilerThread : public Thread {
|
| bool IsOptimizerThread();
|
| #endif
|
|
|
| + void PauseMainThread();
|
| + void ContinueMainThread();
|
| + void YieldToCompilerThread();
|
| +
|
| + // Use this scope during the optimization phase to synchronize with
|
| + // the main thread in order to access the heap.
|
| + class SynchronizedScope {
|
| + public:
|
| + explicit SynchronizedScope(CompilationInfo* info);
|
| + ~SynchronizedScope();
|
| +
|
| + private:
|
| + CompilationInfo* info_;
|
| + AllowHandleAllocation allow_handle_allocation_;
|
| + AllowHandleDereference allow_handle_dereference_;
|
| + AllowHeapAllocation allow_heap_allocation_;
|
| + };
|
| +
|
| private:
|
| - enum StopFlag { CONTINUE, STOP, FLUSH };
|
| + enum LoopSwitch { CONTINUE, STOP, FLUSH };
|
| + enum FlushMode { DO_NOT_RESTORE_FUNCTION_CODE, RESTORE_FUNCTION_CODE };
|
| +
|
| + inline void SetSwitchAndInterceptInterrupt(LoopSwitch loop_switch);
|
| + inline void PrepareInterruption(LoopSwitch loop_switch);
|
| + inline void DisposeOptimizedCompileJob(OptimizedCompileJob* job,
|
| + FlushMode mode);
|
| +
|
| + void FlushInputQueue(FlushMode mode);
|
| + void FlushOutputQueue(FlushMode mode);
|
| + void FlushOsrBuffer(FlushMode mode);
|
|
|
| - void FlushInputQueue(bool restore_function_code);
|
| - void FlushOutputQueue(bool restore_function_code);
|
| - void FlushOsrBuffer(bool restore_function_code);
|
| void CompileNext();
|
| OptimizedCompileJob* NextInput();
|
|
|
| @@ -133,13 +162,15 @@ class OptimizingCompilerThread : public Thread {
|
| Isolate* isolate_;
|
| Semaphore stop_semaphore_;
|
| Semaphore input_queue_semaphore_;
|
| + Semaphore main_thread_semaphore_;
|
| + Semaphore compiler_thread_semaphore_;
|
| + Mutex mutex_;
|
|
|
| // Circular queue of incoming recompilation tasks (including OSR).
|
| OptimizedCompileJob** input_queue_;
|
| int input_queue_capacity_;
|
| int input_queue_length_;
|
| int input_queue_shift_;
|
| - Mutex input_queue_mutex_;
|
|
|
| // Queue of recompilation tasks ready to be installed (excluding OSR).
|
| UnboundQueue<OptimizedCompileJob*> output_queue_;
|
| @@ -149,7 +180,7 @@ class OptimizingCompilerThread : public Thread {
|
| int osr_buffer_capacity_;
|
| int osr_buffer_cursor_;
|
|
|
| - volatile AtomicWord stop_thread_;
|
| + volatile AtomicWord loop_switch_;
|
| TimeDelta time_spent_compiling_;
|
| TimeDelta time_spent_total_;
|
|
|
|
|