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

Unified Diff: src/compiler-dispatcher/compiler-dispatcher.h

Issue 2606263002: Use background tasks for the compiler dispatcher (Closed)
Patch Set: Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler-dispatcher/compiler-dispatcher.h
diff --git a/src/compiler-dispatcher/compiler-dispatcher.h b/src/compiler-dispatcher/compiler-dispatcher.h
index fea141e22f970ff9112290707539ca5d4c574015..d99c259a6783641923d52f41b5df27a9f366c811 100644
--- a/src/compiler-dispatcher/compiler-dispatcher.h
+++ b/src/compiler-dispatcher/compiler-dispatcher.h
@@ -7,9 +7,12 @@
#include <map>
#include <memory>
+#include <set>
#include <utility>
#include "src/base/macros.h"
+#include "src/base/platform/condition-variable.h"
+#include "src/base/platform/mutex.h"
#include "src/globals.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -59,11 +62,16 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
typedef std::multimap<std::pair<int, int>,
std::unique_ptr<CompilerDispatcherJob>>
JobMap;
+ class BackgroundTask;
class IdleTask;
+ void EnsureNotOnBackground(CompilerDispatcherJob* job);
bool IsEnabled() const;
JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
+ void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job);
+ void ScheduleMoreBackgroundTasksIfNeeded();
void ScheduleIdleTaskIfNeeded();
+ void DoBackgroundWork();
void DoIdleWork(double deadline_in_seconds);
Isolate* isolate_;
@@ -77,6 +85,29 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
// as script id is not necessarily unique.
JobMap jobs_;
+ // The following members can be accessed from any thread. Methods need to hold
+ // the mutex |mutex_| while accessing them.
+ base::Mutex mutex_;
+
+ // Number of currently scheduled BackgroundTask objects.
+ size_t num_scheduled_background_tasks_;
+
+ // Number of currently available CompilerDispatcherJobs that can be advanced
+ // on any thread.
+ size_t num_available_background_jobs_;
+
+ // The set of CompilerDispatcherJobs that can be advanced on any thread.
+ std::set<CompilerDispatcherJob*> pending_background_jobs_;
+
+ // The set of CompilerDispatcherJobs currently processed on background
+ // threads.
+ std::set<CompilerDispatcherJob*> running_background_jobs_;
+
+ // If not nullptr, then the main thread waits for the task processing
+ // this job, and blocks on the ConditionVariable main_thread_blocking_signal_.
+ CompilerDispatcherJob* main_thread_blocking_on_job_;
+ base::ConditionVariable main_thread_blocking_signal_;
+
DISALLOW_COPY_AND_ASSIGN(CompilerDispatcher);
};
« 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