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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 public: | 64 public: |
65 enum class BlockingBehavior { kBlock, kDontBlock }; | 65 enum class BlockingBehavior { kBlock, kDontBlock }; |
66 | 66 |
67 CompilerDispatcher(Isolate* isolate, Platform* platform, | 67 CompilerDispatcher(Isolate* isolate, Platform* platform, |
68 size_t max_stack_size); | 68 size_t max_stack_size); |
69 ~CompilerDispatcher(); | 69 ~CompilerDispatcher(); |
70 | 70 |
71 // Returns true if a job was enqueued. | 71 // Returns true if a job was enqueued. |
72 bool Enqueue(Handle<SharedFunctionInfo> function); | 72 bool Enqueue(Handle<SharedFunctionInfo> function); |
73 | 73 |
| 74 // Like Enqueue, but also advances the job so that it can potentially |
| 75 // continue running on a background thread (if at all possible). Returns |
| 76 // true if the job was enqueued. |
| 77 bool EnqueueAndStep(Handle<SharedFunctionInfo> function); |
| 78 |
74 // Returns true if there is a pending job for the given function. | 79 // Returns true if there is a pending job for the given function. |
75 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; | 80 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; |
76 | 81 |
77 // Blocks until the given function is compiled (and does so as fast as | 82 // Blocks until the given function is compiled (and does so as fast as |
78 // possible). Returns true if the compile job was succesful. | 83 // possible). Returns true if the compile job was succesful. |
79 bool FinishNow(Handle<SharedFunctionInfo> function); | 84 bool FinishNow(Handle<SharedFunctionInfo> function); |
80 | 85 |
81 // Aborts a given job. Blocks if requested. | 86 // Aborts a given job. Blocks if requested. |
82 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); | 87 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); |
83 | 88 |
84 // Aborts all jobs. Blocks if requested. | 89 // Aborts all jobs. Blocks if requested. |
85 void AbortAll(BlockingBehavior blocking); | 90 void AbortAll(BlockingBehavior blocking); |
86 | 91 |
87 // Memory pressure notifications from the embedder. | 92 // Memory pressure notifications from the embedder. |
88 void MemoryPressureNotification(v8::MemoryPressureLevel level, | 93 void MemoryPressureNotification(v8::MemoryPressureLevel level, |
89 bool is_isolate_locked); | 94 bool is_isolate_locked); |
90 | 95 |
91 private: | 96 private: |
| 97 FRIEND_TEST(CompilerDispatcherTest, EnqueueAndStep); |
92 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime); | 98 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime); |
93 FRIEND_TEST(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread); | 99 FRIEND_TEST(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread); |
94 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask); | 100 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask); |
95 FRIEND_TEST(IgnitionCompilerDispatcherTest, | 101 FRIEND_TEST(IgnitionCompilerDispatcherTest, |
96 AsyncAbortAllPendingBackgroundTask); | 102 AsyncAbortAllPendingBackgroundTask); |
97 FRIEND_TEST(IgnitionCompilerDispatcherTest, | 103 FRIEND_TEST(IgnitionCompilerDispatcherTest, |
98 AsyncAbortAllRunningBackgroundTask); | 104 AsyncAbortAllRunningBackgroundTask); |
99 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowDuringAbortAll); | 105 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowDuringAbortAll); |
100 | 106 |
101 typedef std::multimap<std::pair<int, int>, | 107 typedef std::multimap<std::pair<int, int>, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 base::AtomicValue<bool> block_for_testing_; | 168 base::AtomicValue<bool> block_for_testing_; |
163 base::Semaphore semaphore_for_testing_; | 169 base::Semaphore semaphore_for_testing_; |
164 | 170 |
165 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); | 171 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); |
166 }; | 172 }; |
167 | 173 |
168 } // namespace internal | 174 } // namespace internal |
169 } // namespace v8 | 175 } // namespace v8 |
170 | 176 |
171 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ | 177 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
OLD | NEW |