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

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

Issue 2600773002: Revert of Disable the CompilerDispatcher if we don't have idle time (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 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
115 // We only handle functions (no eval / top-level code / wasm) that are 113 // We only handle functions (no eval / top-level code / wasm) that are
116 // attached to a script. 114 // attached to a script.
117 if (!function->script()->IsScript() || !function->is_function() || 115 if (!function->script()->IsScript() || !function->is_function() ||
118 function->asm_function() || function->native()) { 116 function->asm_function() || function->native()) {
119 return false; 117 return false;
120 } 118 }
121 119
122 if (IsEnqueued(function)) return true; 120 if (IsEnqueued(function)) return true;
123 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( 121 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
124 isolate_, tracer_.get(), function, max_stack_size_)); 122 isolate_, tracer_.get(), function, max_stack_size_));
125 std::pair<int, int> key(Script::cast(function->script())->id(), 123 std::pair<int, int> key(Script::cast(function->script())->id(),
126 function->function_literal_id()); 124 function->function_literal_id());
127 jobs_.insert(std::make_pair(key, std::move(job))); 125 jobs_.insert(std::make_pair(key, std::move(job)));
128 ScheduleIdleTaskIfNeeded(); 126 ScheduleIdleTaskIfNeeded();
129 return true; 127 return true;
130 } 128 }
131 129
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
137 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const { 130 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const {
138 return GetJobFor(function) != jobs_.end(); 131 return GetJobFor(function) != jobs_.end();
139 } 132 }
140 133
141 bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) { 134 bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
142 JobMap::const_iterator job = GetJobFor(function); 135 JobMap::const_iterator job = GetJobFor(function);
143 CHECK(job != jobs_.end()); 136 CHECK(job != jobs_.end());
144 137
145 // TODO(jochen): Check if there's an in-flight background task working on this 138 // TODO(jochen): Check if there's an in-flight background task working on this
146 // job. 139 // job.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 shared->function_literal_id()); 176 shared->function_literal_id());
184 auto range = jobs_.equal_range(key); 177 auto range = jobs_.equal_range(key);
185 for (auto job = range.first; job != range.second; ++job) { 178 for (auto job = range.first; job != range.second; ++job) {
186 if (job->second->IsAssociatedWith(shared)) return job; 179 if (job->second->IsAssociatedWith(shared)) return job;
187 } 180 }
188 return jobs_.end(); 181 return jobs_.end();
189 } 182 }
190 183
191 void CompilerDispatcher::ScheduleIdleTaskIfNeeded() { 184 void CompilerDispatcher::ScheduleIdleTaskIfNeeded() {
192 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_); 185 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
193 DCHECK(platform_->IdleTasksEnabled(v8_isolate)); 186 if (!platform_->IdleTasksEnabled(v8_isolate)) return;
194 if (idle_task_scheduled_) return; 187 if (idle_task_scheduled_) return;
195 if (jobs_.empty()) return; 188 if (jobs_.empty()) return;
196 idle_task_scheduled_ = true; 189 idle_task_scheduled_ = true;
197 platform_->CallIdleOnForegroundThread(v8_isolate, 190 platform_->CallIdleOnForegroundThread(v8_isolate,
198 new IdleTask(isolate_, this)); 191 new IdleTask(isolate_, this));
199 } 192 }
200 193
201 void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) { 194 void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) {
202 idle_task_scheduled_ = false; 195 idle_task_scheduled_ = false;
203 196
(...skipping 28 matching lines...) Expand all
232 // iterator). 225 // iterator).
233 DoNextStepOnMainThread(isolate_, job->second.get(), 226 DoNextStepOnMainThread(isolate_, job->second.get(),
234 ExceptionHandling::kSwallow); 227 ExceptionHandling::kSwallow);
235 } 228 }
236 } 229 }
237 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); 230 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded();
238 } 231 }
239 232
240 } // namespace internal 233 } // namespace internal
241 } // namespace v8 234 } // 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