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 66 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. | 77 // Enqueue a job for parse and compile. Returns true if a job was enqueued. |
78 bool Enqueue(Handle<SharedFunctionInfo> function); | 78 bool Enqueue(Handle<SharedFunctionInfo> function); |
79 | 79 |
80 // Like Enqueue, but also advances the job so that it can potentially | 80 // Like Enqueue, but also advances the job so that it can potentially |
81 // continue running on a background thread (if at all possible). Returns | 81 // continue running on a background thread (if at all possible). Returns |
82 // true if the job was enqueued. | 82 // true if the job was enqueued. |
83 bool EnqueueAndStep(Handle<SharedFunctionInfo> function); | 83 bool EnqueueAndStep(Handle<SharedFunctionInfo> function); |
84 | 84 |
85 // Enqueue a job for compilation. Function must have already been parsed and | 85 // 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. | 86 // analyzed and be ready for compilation. Returns true if a job was enqueued. |
87 bool Enqueue(Handle<SharedFunctionInfo> function, FunctionLiteral* literal, | 87 bool Enqueue(Handle<Script> script, Handle<SharedFunctionInfo> function, |
88 std::shared_ptr<Zone> parse_zone, | 88 FunctionLiteral* literal, std::shared_ptr<Zone> parse_zone, |
89 std::shared_ptr<DeferredHandles> parse_handles, | 89 std::shared_ptr<DeferredHandles> parse_handles, |
90 std::shared_ptr<DeferredHandles> compile_handles); | 90 std::shared_ptr<DeferredHandles> compile_handles); |
91 | 91 |
92 // Like Enqueue, but also advances the job so that it can potentially | 92 // Like Enqueue, but also advances the job so that it can potentially |
93 // continue running on a background thread (if at all possible). Returns | 93 // continue running on a background thread (if at all possible). Returns |
94 // true if the job was enqueued. | 94 // true if the job was enqueued. |
95 bool EnqueueAndStep(Handle<SharedFunctionInfo> function, | 95 bool EnqueueAndStep(Handle<Script> script, |
| 96 Handle<SharedFunctionInfo> function, |
96 FunctionLiteral* literal, | 97 FunctionLiteral* literal, |
97 std::shared_ptr<Zone> parse_zone, | 98 std::shared_ptr<Zone> parse_zone, |
98 std::shared_ptr<DeferredHandles> parse_handles, | 99 std::shared_ptr<DeferredHandles> parse_handles, |
99 std::shared_ptr<DeferredHandles> compile_handles); | 100 std::shared_ptr<DeferredHandles> compile_handles); |
100 | 101 |
101 // Returns true if there is a pending job for the given function. | 102 // Returns true if there is a pending job for the given function. |
102 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; | 103 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; |
103 | 104 |
104 // Blocks until the given function is compiled (and does so as fast as | 105 // Blocks until the given function is compiled (and does so as fast as |
105 // possible). Returns true if the compile job was successful. | 106 // possible). Returns true if the compile job was successful. |
106 bool FinishNow(Handle<SharedFunctionInfo> function); | 107 bool FinishNow(Handle<SharedFunctionInfo> function); |
107 | 108 |
108 // Blocks until all enqueued jobs have finished. Returns true if all the | |
109 // compile jobs were successful. | |
110 bool FinishAllNow(); | |
111 | |
112 // Aborts a given job. Blocks if requested. | 109 // Aborts a given job. Blocks if requested. |
113 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); | 110 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); |
114 | 111 |
115 // Aborts all jobs. Blocks if requested. | 112 // Aborts all jobs. Blocks if requested. |
116 void AbortAll(BlockingBehavior blocking); | 113 void AbortAll(BlockingBehavior blocking); |
117 | 114 |
118 // Memory pressure notifications from the embedder. | 115 // Memory pressure notifications from the embedder. |
119 void MemoryPressureNotification(v8::MemoryPressureLevel level, | 116 void MemoryPressureNotification(v8::MemoryPressureLevel level, |
120 bool is_isolate_locked); | 117 bool is_isolate_locked); |
121 | 118 |
(...skipping 12 matching lines...) Expand all Loading... |
134 std::unique_ptr<CompilerDispatcherJob>> | 131 std::unique_ptr<CompilerDispatcherJob>> |
135 JobMap; | 132 JobMap; |
136 class AbortTask; | 133 class AbortTask; |
137 class BackgroundTask; | 134 class BackgroundTask; |
138 class IdleTask; | 135 class IdleTask; |
139 | 136 |
140 void WaitForJobIfRunningOnBackground(CompilerDispatcherJob* job); | 137 void WaitForJobIfRunningOnBackground(CompilerDispatcherJob* job); |
141 void AbortInactiveJobs(); | 138 void AbortInactiveJobs(); |
142 bool CanEnqueue(Handle<SharedFunctionInfo> function); | 139 bool CanEnqueue(Handle<SharedFunctionInfo> function); |
143 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; | 140 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; |
144 bool FinishNow(CompilerDispatcherJob* job); | |
145 void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job); | 141 void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job); |
146 void ScheduleMoreBackgroundTasksIfNeeded(); | 142 void ScheduleMoreBackgroundTasksIfNeeded(); |
147 void ScheduleIdleTaskFromAnyThread(); | 143 void ScheduleIdleTaskFromAnyThread(); |
148 void ScheduleIdleTaskIfNeeded(); | 144 void ScheduleIdleTaskIfNeeded(); |
149 void ScheduleAbortTask(); | 145 void ScheduleAbortTask(); |
150 void DoBackgroundWork(); | 146 void DoBackgroundWork(); |
151 void DoIdleWork(double deadline_in_seconds); | 147 void DoIdleWork(double deadline_in_seconds); |
152 | 148 |
153 Isolate* isolate_; | 149 Isolate* isolate_; |
154 Platform* platform_; | 150 Platform* platform_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::AtomicValue<bool> block_for_testing_; | 191 base::AtomicValue<bool> block_for_testing_; |
196 base::Semaphore semaphore_for_testing_; | 192 base::Semaphore semaphore_for_testing_; |
197 | 193 |
198 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); | 194 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); |
199 }; | 195 }; |
200 | 196 |
201 } // namespace internal | 197 } // namespace internal |
202 } // namespace v8 | 198 } // namespace v8 |
203 | 199 |
204 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ | 200 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
OLD | NEW |