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

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

Issue 2606233002: Reland "Disable the CompilerDispatcher if we don't have idle time" (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
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher.h ('k') | src/flag-definitions.h » ('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 #include "src/compiler-dispatcher/compiler-dispatcher.h" 5 #include "src/compiler-dispatcher/compiler-dispatcher.h"
6 6
7 #include "include/v8-platform.h" 7 #include "include/v8-platform.h"
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/base/platform/time.h" 9 #include "src/base/platform/time.h"
10 #include "src/cancelable-task.h" 10 #include "src/cancelable-task.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 max_stack_size_(max_stack_size), 103 max_stack_size_(max_stack_size),
104 tracer_(new CompilerDispatcherTracer(isolate_)), 104 tracer_(new CompilerDispatcherTracer(isolate_)),
105 idle_task_scheduled_(false) {} 105 idle_task_scheduled_(false) {}
106 106
107 CompilerDispatcher::~CompilerDispatcher() { 107 CompilerDispatcher::~CompilerDispatcher() {
108 // To avoid crashing in unit tests due to unfished jobs. 108 // To avoid crashing in unit tests due to unfished jobs.
109 AbortAll(BlockingBehavior::kBlock); 109 AbortAll(BlockingBehavior::kBlock);
110 } 110 }
111 111
112 bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) { 112 bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
113 if (!IsEnabled()) return false;
114
113 // We only handle functions (no eval / top-level code / wasm) that are 115 // We only handle functions (no eval / top-level code / wasm) that are
114 // attached to a script. 116 // attached to a script.
115 if (!function->script()->IsScript() || !function->is_function() || 117 if (!function->script()->IsScript() || !function->is_function() ||
116 function->asm_function() || function->native()) { 118 function->asm_function() || function->native()) {
117 return false; 119 return false;
118 } 120 }
119 121
120 if (IsEnqueued(function)) return true; 122 if (IsEnqueued(function)) return true;
121 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( 123 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
122 isolate_, tracer_.get(), function, max_stack_size_)); 124 isolate_, tracer_.get(), function, max_stack_size_));
123 std::pair<int, int> key(Script::cast(function->script())->id(), 125 std::pair<int, int> key(Script::cast(function->script())->id(),
124 function->function_literal_id()); 126 function->function_literal_id());
125 jobs_.insert(std::make_pair(key, std::move(job))); 127 jobs_.insert(std::make_pair(key, std::move(job)));
126 ScheduleIdleTaskIfNeeded(); 128 ScheduleIdleTaskIfNeeded();
127 return true; 129 return true;
128 } 130 }
129 131
132 bool CompilerDispatcher::IsEnabled() const {
133 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
134 return FLAG_compiler_dispatcher && platform_->IdleTasksEnabled(v8_isolate);
135 }
136
130 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const { 137 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const {
131 return GetJobFor(function) != jobs_.end(); 138 return GetJobFor(function) != jobs_.end();
132 } 139 }
133 140
134 bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) { 141 bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
135 JobMap::const_iterator job = GetJobFor(function); 142 JobMap::const_iterator job = GetJobFor(function);
136 CHECK(job != jobs_.end()); 143 CHECK(job != jobs_.end());
137 144
138 // TODO(jochen): Check if there's an in-flight background task working on this 145 // TODO(jochen): Check if there's an in-flight background task working on this
139 // job. 146 // job.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 shared->function_literal_id()); 183 shared->function_literal_id());
177 auto range = jobs_.equal_range(key); 184 auto range = jobs_.equal_range(key);
178 for (auto job = range.first; job != range.second; ++job) { 185 for (auto job = range.first; job != range.second; ++job) {
179 if (job->second->IsAssociatedWith(shared)) return job; 186 if (job->second->IsAssociatedWith(shared)) return job;
180 } 187 }
181 return jobs_.end(); 188 return jobs_.end();
182 } 189 }
183 190
184 void CompilerDispatcher::ScheduleIdleTaskIfNeeded() { 191 void CompilerDispatcher::ScheduleIdleTaskIfNeeded() {
185 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_); 192 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
186 if (!platform_->IdleTasksEnabled(v8_isolate)) return; 193 DCHECK(platform_->IdleTasksEnabled(v8_isolate));
187 if (idle_task_scheduled_) return; 194 if (idle_task_scheduled_) return;
188 if (jobs_.empty()) return; 195 if (jobs_.empty()) return;
189 idle_task_scheduled_ = true; 196 idle_task_scheduled_ = true;
190 platform_->CallIdleOnForegroundThread(v8_isolate, 197 platform_->CallIdleOnForegroundThread(v8_isolate,
191 new IdleTask(isolate_, this)); 198 new IdleTask(isolate_, this));
192 } 199 }
193 200
194 void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) { 201 void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) {
195 idle_task_scheduled_ = false; 202 idle_task_scheduled_ = false;
196 203
(...skipping 28 matching lines...) Expand all
225 // iterator). 232 // iterator).
226 DoNextStepOnMainThread(isolate_, job->second.get(), 233 DoNextStepOnMainThread(isolate_, job->second.get(),
227 ExceptionHandling::kSwallow); 234 ExceptionHandling::kSwallow);
228 } 235 }
229 } 236 }
230 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); 237 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded();
231 } 238 }
232 239
233 } // namespace internal 240 } // namespace internal
234 } // namespace v8 241 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698