OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ | 5 #ifndef V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ |
6 #define V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ | 6 #define V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
11 #include "src/base/platform/condition-variable.h" | 11 #include "src/base/platform/condition-variable.h" |
12 #include "src/base/platform/mutex.h" | 12 #include "src/base/platform/mutex.h" |
13 #include "src/base/platform/platform.h" | 13 #include "src/base/platform/platform.h" |
14 #include "src/flags.h" | 14 #include "src/flags.h" |
15 #include "src/list.h" | 15 #include "src/list.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
20 class CompilationJob; | 20 class CompilationJob; |
21 class SharedFunctionInfo; | 21 class SharedFunctionInfo; |
22 | 22 |
23 class OptimizingCompileDispatcher { | 23 class OptimizingCompileDispatcher { |
24 public: | 24 public: |
| 25 enum class BlockingBehavior { kBlock, kDontBlock }; |
| 26 |
25 explicit OptimizingCompileDispatcher(Isolate* isolate) | 27 explicit OptimizingCompileDispatcher(Isolate* isolate) |
26 : isolate_(isolate), | 28 : isolate_(isolate), |
27 input_queue_capacity_(FLAG_concurrent_recompilation_queue_length), | 29 input_queue_capacity_(FLAG_concurrent_recompilation_queue_length), |
28 input_queue_length_(0), | 30 input_queue_length_(0), |
29 input_queue_shift_(0), | 31 input_queue_shift_(0), |
30 blocked_jobs_(0), | 32 blocked_jobs_(0), |
31 ref_count_(0), | 33 ref_count_(0), |
32 recompilation_delay_(FLAG_concurrent_recompilation_delay) { | 34 recompilation_delay_(FLAG_concurrent_recompilation_delay) { |
33 base::NoBarrier_Store(&mode_, static_cast<base::AtomicWord>(COMPILE)); | 35 base::NoBarrier_Store(&mode_, static_cast<base::AtomicWord>(COMPILE)); |
34 input_queue_ = NewArray<CompilationJob*>(input_queue_capacity_); | 36 input_queue_ = NewArray<CompilationJob*>(input_queue_capacity_); |
35 } | 37 } |
36 | 38 |
37 ~OptimizingCompileDispatcher(); | 39 ~OptimizingCompileDispatcher(); |
38 | 40 |
39 void Run(); | 41 void Run(); |
40 void Stop(); | 42 void Stop(); |
41 void Flush(); | 43 void Flush(BlockingBehavior blocking_behavior); |
42 void QueueForOptimization(CompilationJob* job); | 44 void QueueForOptimization(CompilationJob* job); |
43 void Unblock(); | 45 void Unblock(); |
44 void InstallOptimizedFunctions(); | 46 void InstallOptimizedFunctions(); |
45 | 47 |
46 inline bool IsQueueAvailable() { | 48 inline bool IsQueueAvailable() { |
47 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_); | 49 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_); |
48 return input_queue_length_ < input_queue_capacity_; | 50 return input_queue_length_ < input_queue_capacity_; |
49 } | 51 } |
50 | 52 |
51 static bool Enabled() { return FLAG_concurrent_recompilation; } | 53 static bool Enabled() { return FLAG_concurrent_recompilation; } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // background thread. | 95 // background thread. |
94 // | 96 // |
95 // Since flags might get modified while the background thread is running, it | 97 // Since flags might get modified while the background thread is running, it |
96 // is not safe to access them directly. | 98 // is not safe to access them directly. |
97 int recompilation_delay_; | 99 int recompilation_delay_; |
98 }; | 100 }; |
99 } // namespace internal | 101 } // namespace internal |
100 } // namespace v8 | 102 } // namespace v8 |
101 | 103 |
102 #endif // V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ | 104 #endif // V8_COMPILER_DISPATCHER_OPTIMIZING_COMPILE_DISPATCHER_H_ |
OLD | NEW |