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

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

Issue 2606263002: Use background tasks for the compiler dispatcher (Closed)
Patch Set: unit tests Created 3 years, 11 months 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
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 <set>
10 #include <utility> 11 #include <utility>
11 12
12 #include "src/base/macros.h" 13 #include "src/base/macros.h"
14 #include "src/base/platform/condition-variable.h"
15 #include "src/base/platform/mutex.h"
13 #include "src/globals.h" 16 #include "src/globals.h"
14 #include "testing/gtest/include/gtest/gtest_prod.h" 17 #include "testing/gtest/include/gtest/gtest_prod.h"
15 18
16 namespace v8 { 19 namespace v8 {
17 20
18 class Platform; 21 class Platform;
19 22
20 namespace internal { 23 namespace internal {
21 24
22 class CompilerDispatcherJob; 25 class CompilerDispatcherJob;
(...skipping 25 matching lines...) Expand all
48 bool FinishNow(Handle<SharedFunctionInfo> function); 51 bool FinishNow(Handle<SharedFunctionInfo> function);
49 52
50 // Aborts a given job. Blocks if requested. 53 // Aborts a given job. Blocks if requested.
51 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking); 54 void Abort(Handle<SharedFunctionInfo> function, BlockingBehavior blocking);
52 55
53 // Aborts all jobs. Blocks if requested. 56 // Aborts all jobs. Blocks if requested.
54 void AbortAll(BlockingBehavior blocking); 57 void AbortAll(BlockingBehavior blocking);
55 58
56 private: 59 private:
57 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime); 60 FRIEND_TEST(CompilerDispatcherTest, IdleTaskSmallIdleTime);
61 FRIEND_TEST(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread);
62 FRIEND_TEST(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask);
58 63
59 typedef std::multimap<std::pair<int, int>, 64 typedef std::multimap<std::pair<int, int>,
60 std::unique_ptr<CompilerDispatcherJob>> 65 std::unique_ptr<CompilerDispatcherJob>>
61 JobMap; 66 JobMap;
67 class BackgroundTask;
62 class IdleTask; 68 class IdleTask;
63 69
70 void EnsureNotOnBackground(CompilerDispatcherJob* job);
64 bool IsEnabled() const; 71 bool IsEnabled() const;
65 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; 72 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
73 void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job);
74 void ScheduleMoreBackgroundTasksIfNeeded();
75 void ScheduleIdleTaskFromAnyThread();
66 void ScheduleIdleTaskIfNeeded(); 76 void ScheduleIdleTaskIfNeeded();
77 void DoBackgroundWork();
67 void DoIdleWork(double deadline_in_seconds); 78 void DoIdleWork(double deadline_in_seconds);
68 79
69 Isolate* isolate_; 80 Isolate* isolate_;
70 Platform* platform_; 81 Platform* platform_;
71 size_t max_stack_size_; 82 size_t max_stack_size_;
72 std::unique_ptr<CompilerDispatcherTracer> tracer_; 83 std::unique_ptr<CompilerDispatcherTracer> tracer_;
73 84
74 bool idle_task_scheduled_;
75
76 // Mapping from (script id, function literal id) to job. We use a multimap, 85 // Mapping from (script id, function literal id) to job. We use a multimap,
77 // as script id is not necessarily unique. 86 // as script id is not necessarily unique.
78 JobMap jobs_; 87 JobMap jobs_;
79 88
89 // The following members can be accessed from any thread. Methods need to hold
90 // the mutex |mutex_| while accessing them.
91 base::Mutex mutex_;
92
93 bool idle_task_scheduled_;
94
95 // Number of currently scheduled BackgroundTask objects.
96 size_t num_scheduled_background_tasks_;
97
98 // The set of CompilerDispatcherJobs that can be advanced on any thread.
99 std::set<CompilerDispatcherJob*> pending_background_jobs_;
marja 2017/01/03 10:42:41 Why a set, why not a FIFO? (Ah, found out the answ
jochen (gone - plz use gerrit) 2017/01/03 12:59:36 changed to unordered_set
100
101 // The set of CompilerDispatcherJobs currently processed on background
102 // threads.
103 std::set<CompilerDispatcherJob*> running_background_jobs_;
marja 2017/01/03 10:42:41 Ditto
104
105 // If not nullptr, then the main thread waits for the task processing
106 // this job, and blocks on the ConditionVariable main_thread_blocking_signal_.
107 CompilerDispatcherJob* main_thread_blocking_on_job_;
108 base::ConditionVariable main_thread_blocking_signal_;
109
80 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); 110 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher);
81 }; 111 };
82 112
83 } // namespace internal 113 } // namespace internal
84 } // namespace v8 114 } // namespace v8
85 115
86 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ 116 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler-dispatcher/compiler-dispatcher.cc » ('j') | src/compiler-dispatcher/compiler-dispatcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698