OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_COMPILER_DISPATCHER_H_ | 5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ | 6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace v8 { | 21 namespace v8 { |
22 | 22 |
23 class Platform; | 23 class Platform; |
24 enum class MemoryPressureLevel; | 24 enum class MemoryPressureLevel; |
25 | 25 |
26 namespace internal { | 26 namespace internal { |
27 | 27 |
28 class CancelableTaskManager; | 28 class CancelableTaskManager; |
29 class CompilerDispatcherJob; | 29 class CompilerDispatcherJob; |
30 class CompilerDispatcherTracer; | 30 class CompilerDispatcherTracer; |
31 class DeferredHandles; | |
32 class FunctionLiteral; | 31 class FunctionLiteral; |
33 class Isolate; | 32 class Isolate; |
34 class SharedFunctionInfo; | 33 class SharedFunctionInfo; |
35 class Zone; | |
36 | 34 |
37 template <typename T> | 35 template <typename T> |
38 class Handle; | 36 class Handle; |
39 | 37 |
40 // The CompilerDispatcher uses a combination of idle tasks and background tasks | 38 // The CompilerDispatcher uses a combination of idle tasks and background tasks |
41 // to parse and compile lazily parsed functions. | 39 // to parse and compile lazily parsed functions. |
42 // | 40 // |
43 // As both parsing and compilation currently requires a preparation and | 41 // As both parsing and compilation currently requires a preparation and |
44 // finalization step that happens on the main thread, every task has to be | 42 // finalization step that happens on the main thread, every task has to be |
45 // advanced during idle time first. Depending on the properties of the task, it | 43 // advanced during idle time first. Depending on the properties of the task, it |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Enqueue a job for parse and compile. Returns true if a job was enqueued. | 75 // Enqueue a job for parse and compile. Returns true if a job was enqueued. |
78 bool Enqueue(Handle<SharedFunctionInfo> function); | 76 bool Enqueue(Handle<SharedFunctionInfo> function); |
79 | 77 |
80 // Like Enqueue, but also advances the job so that it can potentially | 78 // Like Enqueue, but also advances the job so that it can potentially |
81 // continue running on a background thread (if at all possible). Returns | 79 // continue running on a background thread (if at all possible). Returns |
82 // true if the job was enqueued. | 80 // true if the job was enqueued. |
83 bool EnqueueAndStep(Handle<SharedFunctionInfo> function); | 81 bool EnqueueAndStep(Handle<SharedFunctionInfo> function); |
84 | 82 |
85 // Enqueue a job for compilation. Function must have already been parsed and | 83 // Enqueue a job for compilation. Function must have already been parsed and |
86 // analyzed and be ready for compilation. Returns true if a job was enqueued. | 84 // analyzed and be ready for compilation. Returns true if a job was enqueued. |
87 bool Enqueue(Handle<SharedFunctionInfo> function, FunctionLiteral* literal, | 85 bool Enqueue(Handle<SharedFunctionInfo> function, FunctionLiteral* literal); |
88 std::shared_ptr<Zone> parse_zone, | |
89 std::shared_ptr<DeferredHandles> parse_handles, | |
90 std::shared_ptr<DeferredHandles> compile_handles); | |
91 | 86 |
92 // Like Enqueue, but also advances the job so that it can potentially | 87 // Like Enqueue, but also advances the job so that it can potentially |
93 // continue running on a background thread (if at all possible). Returns | 88 // continue running on a background thread (if at all possible). Returns |
94 // true if the job was enqueued. | 89 // true if the job was enqueued. |
95 bool EnqueueAndStep(Handle<SharedFunctionInfo> function, | 90 bool EnqueueAndStep(Handle<SharedFunctionInfo> function, |
96 FunctionLiteral* literal, | 91 FunctionLiteral* literal); |
97 std::shared_ptr<Zone> parse_zone, | |
98 std::shared_ptr<DeferredHandles> parse_handles, | |
99 std::shared_ptr<DeferredHandles> compile_handles); | |
100 | 92 |
101 // Returns true if there is a pending job for the given function. | 93 // Returns true if there is a pending job for the given function. |
102 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; | 94 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; |
103 | 95 |
104 // Blocks until the given function is compiled (and does so as fast as | 96 // Blocks until the given function is compiled (and does so as fast as |
105 // possible). Returns true if the compile job was successful. | 97 // possible). Returns true if the compile job was successful. |
106 bool FinishNow(Handle<SharedFunctionInfo> function); | 98 bool FinishNow(Handle<SharedFunctionInfo> function); |
107 | 99 |
108 // Blocks until all enqueued jobs have finished. Returns true if all the | 100 // Blocks until all enqueued jobs have finished. Returns true if all the |
109 // compile jobs were successful. | 101 // compile jobs were successful. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::AtomicValue<bool> block_for_testing_; | 187 base::AtomicValue<bool> block_for_testing_; |
196 base::Semaphore semaphore_for_testing_; | 188 base::Semaphore semaphore_for_testing_; |
197 | 189 |
198 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); | 190 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); |
199 }; | 191 }; |
200 | 192 |
201 } // namespace internal | 193 } // namespace internal |
202 } // namespace v8 | 194 } // namespace v8 |
203 | 195 |
204 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ | 196 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
OLD | NEW |