Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: src/optimizing-compile-dispatcher.h

Issue 1925743002: [compiler] Rename OptimizingCompileJob to CompilationJob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-compiler-simplify-29
Patch Set: Fix tests as well. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/optimizing-compile-dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_OPTIMIZING_COMPILE_DISPATCHER_H_ 5 #ifndef V8_OPTIMIZING_COMPILE_DISPATCHER_H_
6 #define V8_OPTIMIZING_COMPILE_DISPATCHER_H_ 6 #define V8_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 HOptimizedGraphBuilder; 20 class CompilationJob;
21 class OptimizedCompileJob;
22 class SharedFunctionInfo; 21 class SharedFunctionInfo;
23 22
24 class OptimizingCompileDispatcher { 23 class OptimizingCompileDispatcher {
25 public: 24 public:
26 explicit OptimizingCompileDispatcher(Isolate* isolate) 25 explicit OptimizingCompileDispatcher(Isolate* isolate)
27 : isolate_(isolate), 26 : isolate_(isolate),
28 input_queue_capacity_(FLAG_concurrent_recompilation_queue_length), 27 input_queue_capacity_(FLAG_concurrent_recompilation_queue_length),
29 input_queue_length_(0), 28 input_queue_length_(0),
30 input_queue_shift_(0), 29 input_queue_shift_(0),
31 blocked_jobs_(0), 30 blocked_jobs_(0),
32 ref_count_(0), 31 ref_count_(0),
33 recompilation_delay_(FLAG_concurrent_recompilation_delay) { 32 recompilation_delay_(FLAG_concurrent_recompilation_delay) {
34 base::NoBarrier_Store(&mode_, static_cast<base::AtomicWord>(COMPILE)); 33 base::NoBarrier_Store(&mode_, static_cast<base::AtomicWord>(COMPILE));
35 input_queue_ = NewArray<OptimizedCompileJob*>(input_queue_capacity_); 34 input_queue_ = NewArray<CompilationJob*>(input_queue_capacity_);
36 } 35 }
37 36
38 ~OptimizingCompileDispatcher(); 37 ~OptimizingCompileDispatcher();
39 38
40 void Run(); 39 void Run();
41 void Stop(); 40 void Stop();
42 void Flush(); 41 void Flush();
43 void QueueForOptimization(OptimizedCompileJob* optimizing_compiler); 42 void QueueForOptimization(CompilationJob* job);
44 void Unblock(); 43 void Unblock();
45 void InstallOptimizedFunctions(); 44 void InstallOptimizedFunctions();
46 45
47 inline bool IsQueueAvailable() { 46 inline bool IsQueueAvailable() {
48 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_); 47 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_);
49 return input_queue_length_ < input_queue_capacity_; 48 return input_queue_length_ < input_queue_capacity_;
50 } 49 }
51 50
52 static bool Enabled() { return FLAG_concurrent_recompilation; } 51 static bool Enabled() { return FLAG_concurrent_recompilation; }
53 52
54 private: 53 private:
55 class CompileTask; 54 class CompileTask;
56 55
57 enum ModeFlag { COMPILE, FLUSH }; 56 enum ModeFlag { COMPILE, FLUSH };
58 57
59 void FlushOutputQueue(bool restore_function_code); 58 void FlushOutputQueue(bool restore_function_code);
60 void CompileNext(OptimizedCompileJob* job); 59 void CompileNext(CompilationJob* job);
61 OptimizedCompileJob* NextInput(bool check_if_flushing = false); 60 CompilationJob* NextInput(bool check_if_flushing = false);
62 61
63 inline int InputQueueIndex(int i) { 62 inline int InputQueueIndex(int i) {
64 int result = (i + input_queue_shift_) % input_queue_capacity_; 63 int result = (i + input_queue_shift_) % input_queue_capacity_;
65 DCHECK_LE(0, result); 64 DCHECK_LE(0, result);
66 DCHECK_LT(result, input_queue_capacity_); 65 DCHECK_LT(result, input_queue_capacity_);
67 return result; 66 return result;
68 } 67 }
69 68
70 Isolate* isolate_; 69 Isolate* isolate_;
71 70
72 // Circular queue of incoming recompilation tasks (including OSR). 71 // Circular queue of incoming recompilation tasks (including OSR).
73 OptimizedCompileJob** input_queue_; 72 CompilationJob** input_queue_;
74 int input_queue_capacity_; 73 int input_queue_capacity_;
75 int input_queue_length_; 74 int input_queue_length_;
76 int input_queue_shift_; 75 int input_queue_shift_;
77 base::Mutex input_queue_mutex_; 76 base::Mutex input_queue_mutex_;
78 77
79 // Queue of recompilation tasks ready to be installed (excluding OSR). 78 // Queue of recompilation tasks ready to be installed (excluding OSR).
80 std::queue<OptimizedCompileJob*> output_queue_; 79 std::queue<CompilationJob*> output_queue_;
81 // Used for job based recompilation which has multiple producers on 80 // Used for job based recompilation which has multiple producers on
82 // different threads. 81 // different threads.
83 base::Mutex output_queue_mutex_; 82 base::Mutex output_queue_mutex_;
84 83
85 volatile base::AtomicWord mode_; 84 volatile base::AtomicWord mode_;
86 85
87 int blocked_jobs_; 86 int blocked_jobs_;
88 87
89 int ref_count_; 88 int ref_count_;
90 base::Mutex ref_count_mutex_; 89 base::Mutex ref_count_mutex_;
91 base::ConditionVariable ref_count_zero_; 90 base::ConditionVariable ref_count_zero_;
92 91
93 // Copy of FLAG_concurrent_recompilation_delay that will be used from the 92 // Copy of FLAG_concurrent_recompilation_delay that will be used from the
94 // background thread. 93 // background thread.
95 // 94 //
96 // Since flags might get modified while the background thread is running, it 95 // Since flags might get modified while the background thread is running, it
97 // is not safe to access them directly. 96 // is not safe to access them directly.
98 int recompilation_delay_; 97 int recompilation_delay_;
99 }; 98 };
100 } // namespace internal 99 } // namespace internal
101 } // namespace v8 100 } // namespace v8
102 101
103 #endif // V8_OPTIMIZING_COMPILE_DISPATCHER_H_ 102 #endif // V8_OPTIMIZING_COMPILE_DISPATCHER_H_
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/optimizing-compile-dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698