Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: src/compiler-dispatcher/compiler-dispatcher.h

Issue 2558293004: Add a basic compiler dispatcher (Closed)
Patch Set: play it safe Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 static bool DoNextStepOnMainThread(CompilerDispatcherJob* job);
marja 2016/12/12 09:00:02 Afaics these don't need to be in the header, they
marja 2016/12/12 09:02:08 Or hmm, do they need to be here because of friends
jochen (gone - plz use gerrit) 2016/12/12 10:51:17 yeah, I was first thinking about adding unit tests
51 static bool IsDone(CompilerDispatcherJob* job);
52
53 Isolate* isolate_;
54 size_t max_stack_size_;
55 std::unique_ptr<CompilerDispatcherTracer> tracer_;
56
57 // Mapping from (script id, function literal id) to job.
58 std::map<std::pair<int, int>, std::unique_ptr<CompilerDispatcherJob>> jobs_;
59
60 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher);
61 };
62
63 } // namespace internal
64 } // namespace v8
65
66 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698