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

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

Issue 2606263002: Use background tasks for the compiler dispatcher (Closed)
Patch Set: 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 29 matching lines...) Expand all
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);
58 61
59 typedef std::multimap<std::pair<int, int>, 62 typedef std::multimap<std::pair<int, int>,
60 std::unique_ptr<CompilerDispatcherJob>> 63 std::unique_ptr<CompilerDispatcherJob>>
61 JobMap; 64 JobMap;
65 class BackgroundTask;
62 class IdleTask; 66 class IdleTask;
63 67
68 void EnsureNotOnBackground(CompilerDispatcherJob* job);
64 bool IsEnabled() const; 69 bool IsEnabled() const;
65 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const; 70 JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
71 void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job);
72 void ScheduleMoreBackgroundTasksIfNeeded();
66 void ScheduleIdleTaskIfNeeded(); 73 void ScheduleIdleTaskIfNeeded();
74 void DoBackgroundWork();
67 void DoIdleWork(double deadline_in_seconds); 75 void DoIdleWork(double deadline_in_seconds);
68 76
69 Isolate* isolate_; 77 Isolate* isolate_;
70 Platform* platform_; 78 Platform* platform_;
71 size_t max_stack_size_; 79 size_t max_stack_size_;
72 std::unique_ptr<CompilerDispatcherTracer> tracer_; 80 std::unique_ptr<CompilerDispatcherTracer> tracer_;
73 81
74 bool idle_task_scheduled_; 82 bool idle_task_scheduled_;
75 83
76 // Mapping from (script id, function literal id) to job. We use a multimap, 84 // Mapping from (script id, function literal id) to job. We use a multimap,
77 // as script id is not necessarily unique. 85 // as script id is not necessarily unique.
78 JobMap jobs_; 86 JobMap jobs_;
79 87
88 // The following members can be accessed from any thread. Methods need to hold
89 // the mutex |mutex_| while accessing them.
90 base::Mutex mutex_;
91
92 // Number of currently scheduled BackgroundTask objects.
93 size_t num_scheduled_background_tasks_;
94
95 // Number of currently available CompilerDispatcherJobs that can be advanced
96 // on any thread.
97 size_t num_available_background_jobs_;
98
99 // The set of CompilerDispatcherJobs that can be advanced on any thread.
100 std::set<CompilerDispatcherJob*> pending_background_jobs_;
101
102 // The set of CompilerDispatcherJobs currently processed on background
103 // threads.
104 std::set<CompilerDispatcherJob*> running_background_jobs_;
105
106 // If not nullptr, then the main thread waits for the task processing
107 // this job, and blocks on the ConditionVariable main_thread_blocking_signal_.
108 CompilerDispatcherJob* main_thread_blocking_on_job_;
109 base::ConditionVariable main_thread_blocking_signal_;
110
80 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher); 111 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher);
81 }; 112 };
82 113
83 } // namespace internal 114 } // namespace internal
84 } // namespace v8 115 } // namespace v8
85 116
86 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_ 117 #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