OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
| 6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <utility> |
| 11 |
| 12 #include "src/base/macros.h" |
| 13 #include "src/globals.h" |
| 14 |
| 15 namespace v8 { |
| 16 namespace internal { |
| 17 |
| 18 class CompilerDispatcherJob; |
| 19 class CompilerDispatcherTracer; |
| 20 class Isolate; |
| 21 class SharedFunctionInfo; |
| 22 |
| 23 template <typename T> |
| 24 class Handle; |
| 25 |
| 26 class V8_EXPORT_PRIVATE CompilerDispatcher { |
| 27 public: |
| 28 enum class BlockingBehavior { kBlock, kDontBlock }; |
| 29 |
| 30 CompilerDispatcher(Isolate* isolate, size_t max_stack_size); |
| 31 ~CompilerDispatcher(); |
| 32 |
| 33 // Returns true if a job was enqueued. |
| 34 bool Enqueue(Handle<SharedFunctionInfo> function); |
| 35 |
| 36 // Returns true if there is a pending job for the given function. |
| 37 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; |
| 38 |
| 39 // Blocks until the given function is compiled (and does so as fast as |
| 40 // possible). Returns true if the compile job was succesful. |
| 41 bool FinishNow(Handle<SharedFunctionInfo> function); |
| 42 |
| 43 // Aborts a given job. Blocks if requested. |
| 44 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); |
| 45 |
| 46 // Aborts all jobs. Blocks if requested. |
| 47 void AbortAll(BlockingBehavior blocking); |
| 48 |
| 49 private: |
| 50 typedef std::multimap<std::pair<int, int>, |
| 51 std::unique_ptr<CompilerDispatcherJob>> |
| 52 JobMap; |
| 53 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; |
| 54 |
| 55 Isolate* isolate_; |
| 56 size_t max_stack_size_; |
| 57 std::unique_ptr<CompilerDispatcherTracer> tracer_; |
| 58 |
| 59 // Mapping from (script id, function literal id) to job. We use a multimap, |
| 60 // as script id is not necessarily unique. |
| 61 JobMap jobs_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); |
| 64 }; |
| 65 |
| 66 } // namespace internal |
| 67 } // namespace v8 |
| 68 |
| 69 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ |
OLD | NEW |