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

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

Issue 2573493002: Use idle time to make progress on scheduled compilation jobs (Closed)
Patch Set: updates 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
« no previous file with comments | « no previous file | src/compiler-dispatcher/compiler-dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 10 #include <utility>
11 11
12 #include "src/base/macros.h" 12 #include "src/base/macros.h"
13 #include "src/globals.h" 13 #include "src/globals.h"
14 #include "testing/gtest/include/gtest/gtest_prod.h"
14 15
15 namespace v8 { 16 namespace v8 {
17
18 class Platform;
19
16 namespace internal { 20 namespace internal {
17 21
18 class CompilerDispatcherJob; 22 class CompilerDispatcherJob;
19 class CompilerDispatcherTracer; 23 class CompilerDispatcherTracer;
20 class Isolate; 24 class Isolate;
21 class SharedFunctionInfo; 25 class SharedFunctionInfo;
22 26
23 template <typename T> 27 template <typename T>
24 class Handle; 28 class Handle;
25 29
30 // The CompilerDispatcher uses a combination of idle tasks and background tasks
31 // to parse and compile lazily parsed functions.
26 class V8_EXPORT_PRIVATE CompilerDispatcher { 32 class V8_EXPORT_PRIVATE CompilerDispatcher {
27 public: 33 public:
28 enum class BlockingBehavior { kBlock, kDontBlock }; 34 enum class BlockingBehavior { kBlock, kDontBlock };
29 35
30 CompilerDispatcher(Isolate* isolate, size_t max_stack_size); 36 CompilerDispatcher(Isolate* isolate, Platform* platform,
37 size_t max_stack_size);
31 ~CompilerDispatcher(); 38 ~CompilerDispatcher();
32 39
33 // Returns true if a job was enqueued. 40 // Returns true if a job was enqueued.
34 bool Enqueue(Handle<SharedFunctionInfo> function); 41 bool Enqueue(Handle<SharedFunctionInfo> function);
35 42
36 // Returns true if there is a pending job for the given function. 43 // Returns true if there is a pending job for the given function.
37 bool IsEnqueued(Handle<SharedFunctionInfo> function) const; 44 bool IsEnqueued(Handle<SharedFunctionInfo> function) const;
38 45
39 // Blocks until the given function is compiled (and does so as fast as 46 // Blocks until the given function is compiled (and does so as fast as
40 // possible). Returns true if the compile job was succesful. 47 // possible). Returns true if the compile job was succesful.
41 bool FinishNow(Handle<SharedFunctionInfo> function); 48 bool FinishNow(Handle<SharedFunctionInfo> function);
42 49
43 // Aborts a given job. Blocks if requested. 50 // Aborts a given job. Blocks if requested.
44 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); 51 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking);
45 52
46 // Aborts all jobs. Blocks if requested. 53 // Aborts all jobs. Blocks if requested.
47 void AbortAll(BlockingBehavior blocking); 54 void AbortAll(BlockingBehavior blocking);
48 55
49 private: 56 private:
57 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime);
58
50 typedef std::multimap<std::pair<int, int>, 59 typedef std::multimap<std::pair<int, int>,
51 std::unique_ptr<CompilerDispatcherJob>> 60 std::unique_ptr<CompilerDispatcherJob>>
52 JobMap; 61 JobMap;
62 class IdleTask;
63
53 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; 64 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
65 void ScheduleIdleTaskIfNeeded();
66 void DoIdleWork(double deadline_in_seconds);
54 67
55 Isolate* isolate_; 68 Isolate* isolate_;
69 Platform* platform_;
56 size_t max_stack_size_; 70 size_t max_stack_size_;
57 std::unique_ptr<CompilerDispatcherTracer> tracer_; 71 std::unique_ptr<CompilerDispatcherTracer> tracer_;
58 72
73 bool idle_task_scheduled_;
74
59 // Mapping from (script id, function literal id) to job. We use a multimap, 75 // Mapping from (script id, function literal id) to job. We use a multimap,
60 // as script id is not necessarily unique. 76 // as script id is not necessarily unique.
61 JobMap jobs_; 77 JobMap jobs_;
62 78
63 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); 79 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher);
64 }; 80 };
65 81
66 } // namespace internal 82 } // namespace internal
67 } // namespace v8 83 } // namespace v8
68 84
69 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ 85 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler-dispatcher/compiler-dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698