| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_COMPILER_H_ | 5 #ifndef VM_COMPILER_H_ |
| 6 #define VM_COMPILER_H_ | 6 #define VM_COMPILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Current implementation: one task per isolate, it dies with the owning | 156 // Current implementation: one task per isolate, it dies with the owning |
| 157 // isolate. | 157 // isolate. |
| 158 // No OSR compilation in the background compiler. | 158 // No OSR compilation in the background compiler. |
| 159 class BackgroundCompiler : public ThreadPool::Task { | 159 class BackgroundCompiler : public ThreadPool::Task { |
| 160 public: | 160 public: |
| 161 virtual ~BackgroundCompiler(); | 161 virtual ~BackgroundCompiler(); |
| 162 | 162 |
| 163 static void EnsureInit(Thread* thread); | 163 static void EnsureInit(Thread* thread); |
| 164 | 164 |
| 165 // Stops background compiler of the given isolate. | 165 // Stops background compiler of the given isolate. |
| 166 // TODO(turnidge): Give Stop and Disable more distinct names. |
| 166 static void Stop(Isolate* isolate); | 167 static void Stop(Isolate* isolate); |
| 167 | 168 |
| 169 static void Disable(); |
| 170 |
| 171 static void Enable(); |
| 172 |
| 173 static bool IsDisabled(); |
| 174 |
| 168 // Call to optimize a function in the background, enters the function in the | 175 // Call to optimize a function in the background, enters the function in the |
| 169 // compilation queue. | 176 // compilation queue. |
| 170 void CompileOptimized(const Function& function); | 177 void CompileOptimized(const Function& function); |
| 171 | 178 |
| 172 void VisitPointers(ObjectPointerVisitor* visitor); | 179 void VisitPointers(ObjectPointerVisitor* visitor); |
| 173 | 180 |
| 174 BackgroundCompilationQueue* function_queue() const { return function_queue_; } | 181 BackgroundCompilationQueue* function_queue() const { return function_queue_; } |
| 175 bool is_running() const { return running_; } | 182 bool is_running() const { return running_; } |
| 176 | 183 |
| 177 private: | 184 private: |
| 178 explicit BackgroundCompiler(Isolate* isolate); | 185 explicit BackgroundCompiler(Isolate* isolate); |
| 179 | 186 |
| 180 virtual void Run(); | 187 virtual void Run(); |
| 181 | 188 |
| 182 Isolate* isolate_; | 189 Isolate* isolate_; |
| 183 bool running_; // While true, will try to read queue and compile. | 190 bool running_; // While true, will try to read queue and compile. |
| 184 bool* done_; // True if the thread is done. | 191 bool* done_; // True if the thread is done. |
| 185 Monitor* queue_monitor_; // Controls access to the queue. | 192 Monitor* queue_monitor_; // Controls access to the queue. |
| 186 Monitor* done_monitor_; // Notify/wait that the thread is done. | 193 Monitor* done_monitor_; // Notify/wait that the thread is done. |
| 187 | 194 |
| 188 BackgroundCompilationQueue* function_queue_; | 195 BackgroundCompilationQueue* function_queue_; |
| 189 | 196 |
| 190 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); | 197 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); |
| 191 }; | 198 }; |
| 192 | 199 |
| 193 } // namespace dart | 200 } // namespace dart |
| 194 | 201 |
| 195 #endif // VM_COMPILER_H_ | 202 #endif // VM_COMPILER_H_ |
| OLD | NEW |