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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "src/base/atomic-utils.h" | 13 #include "src/base/atomic-utils.h" |
14 #include "src/base/macros.h" | 14 #include "src/base/macros.h" |
15 #include "src/base/platform/condition-variable.h" | 15 #include "src/base/platform/condition-variable.h" |
16 #include "src/base/platform/mutex.h" | 16 #include "src/base/platform/mutex.h" |
17 #include "src/base/platform/semaphore.h" | 17 #include "src/base/platform/semaphore.h" |
18 #include "src/globals.h" | 18 #include "src/globals.h" |
19 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
20 | 20 |
21 namespace v8 { | 21 namespace v8 { |
22 | 22 |
23 class Platform; | 23 class Platform; |
| 24 enum class MemoryPressureLevel; |
24 | 25 |
25 namespace internal { | 26 namespace internal { |
26 | 27 |
27 class CancelableTaskManager; | 28 class CancelableTaskManager; |
28 class CompilerDispatcherJob; | 29 class CompilerDispatcherJob; |
29 class CompilerDispatcherTracer; | 30 class CompilerDispatcherTracer; |
30 class Isolate; | 31 class Isolate; |
31 class SharedFunctionInfo; | 32 class SharedFunctionInfo; |
32 | 33 |
33 template <typename T> | 34 template <typename T> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Blocks until the given function is compiled (and does so as fast as | 77 // Blocks until the given function is compiled (and does so as fast as |
77 // possible). Returns true if the compile job was succesful. | 78 // possible). Returns true if the compile job was succesful. |
78 bool FinishNow(Handle<SharedFunctionInfo> function); | 79 bool FinishNow(Handle<SharedFunctionInfo> function); |
79 | 80 |
80 // Aborts a given job. Blocks if requested. | 81 // Aborts a given job. Blocks if requested. |
81 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); | 82 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); |
82 | 83 |
83 // Aborts all jobs. Blocks if requested. | 84 // Aborts all jobs. Blocks if requested. |
84 void AbortAll(BlockingBehavior blocking); | 85 void AbortAll(BlockingBehavior blocking); |
85 | 86 |
| 87 // Memory pressure notifications from the embedder. |
| 88 void MemoryPressureNotification(v8::MemoryPressureLevel level, |
| 89 bool is_isolate_locked); |
| 90 |
86 private: | 91 private: |
87 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime); | 92 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime); |
88 FRIEND_TEST(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread); | 93 FRIEND_TEST(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread); |
89 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask); | 94 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask); |
90 FRIEND_TEST(IgnitionCompilerDispatcherTest, | 95 FRIEND_TEST(IgnitionCompilerDispatcherTest, |
91 AsyncAbortAllPendingBackgroundTask); | 96 AsyncAbortAllPendingBackgroundTask); |
92 FRIEND_TEST(IgnitionCompilerDispatcherTest, | 97 FRIEND_TEST(IgnitionCompilerDispatcherTest, |
93 AsyncAbortAllRunningBackgroundTask); | 98 AsyncAbortAllRunningBackgroundTask); |
94 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowDuringAbortAll); | 99 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowDuringAbortAll); |
95 | 100 |
(...skipping 20 matching lines...) Expand all Loading... |
116 Platform* platform_; | 121 Platform* platform_; |
117 size_t max_stack_size_; | 122 size_t max_stack_size_; |
118 std::unique_ptr<CompilerDispatcherTracer> tracer_; | 123 std::unique_ptr<CompilerDispatcherTracer> tracer_; |
119 | 124 |
120 std::unique_ptr<CancelableTaskManager> task_manager_; | 125 std::unique_ptr<CancelableTaskManager> task_manager_; |
121 | 126 |
122 // Mapping from (script id, function literal id) to job. We use a multimap, | 127 // Mapping from (script id, function literal id) to job. We use a multimap, |
123 // as script id is not necessarily unique. | 128 // as script id is not necessarily unique. |
124 JobMap jobs_; | 129 JobMap jobs_; |
125 | 130 |
| 131 base::AtomicValue<v8::MemoryPressureLevel> memory_pressure_level_; |
| 132 |
126 // The following members can be accessed from any thread. Methods need to hold | 133 // The following members can be accessed from any thread. Methods need to hold |
127 // the mutex |mutex_| while accessing them. | 134 // the mutex |mutex_| while accessing them. |
128 base::Mutex mutex_; | 135 base::Mutex mutex_; |
129 | 136 |
130 // True if the dispatcher is in the process of aborting running tasks. | 137 // True if the dispatcher is in the process of aborting running tasks. |
131 bool abort_; | 138 bool abort_; |
132 | 139 |
133 bool idle_task_scheduled_; | 140 bool idle_task_scheduled_; |
134 | 141 |
135 // Number of currently scheduled BackgroundTask objects. | 142 // Number of currently scheduled BackgroundTask objects. |
(...skipping 15 matching lines...) Expand all Loading... |
151 base::AtomicValue<bool> block_for_testing_; | 158 base::AtomicValue<bool> block_for_testing_; |
152 base::Semaphore semaphore_for_testing_; | 159 base::Semaphore semaphore_for_testing_; |
153 | 160 |
154 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); | 161 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); |
155 }; | 162 }; |
156 | 163 |
157 } // namespace internal | 164 } // namespace internal |
158 } // namespace v8 | 165 } // namespace v8 |
159 | 166 |
160 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ | 167 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
OLD | NEW |