| OLD | NEW |
| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 256 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
| 257 isolate_, tracer_.get(), function, max_stack_size_)); | 257 isolate_, tracer_.get(), function, max_stack_size_)); |
| 258 std::pair<int, int> key(Script::cast(function->script())->id(), | 258 std::pair<int, int> key(Script::cast(function->script())->id(), |
| 259 function->function_literal_id()); | 259 function->function_literal_id()); |
| 260 jobs_.insert(std::make_pair(key, std::move(job))); | 260 jobs_.insert(std::make_pair(key, std::move(job))); |
| 261 ScheduleIdleTaskIfNeeded(); | 261 ScheduleIdleTaskIfNeeded(); |
| 262 return true; | 262 return true; |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function) { |
| 266 if (!Enqueue(function)) return false; |
| 267 |
| 268 if (trace_compiler_dispatcher_) { |
| 269 PrintF("CompilerDispatcher: stepping "); |
| 270 function->ShortPrint(); |
| 271 PrintF("\n"); |
| 272 } |
| 273 JobMap::const_iterator job = GetJobFor(function); |
| 274 DoNextStepOnMainThread(isolate_, job->second.get(), |
| 275 ExceptionHandling::kSwallow); |
| 276 ConsiderJobForBackgroundProcessing(job->second.get()); |
| 277 return true; |
| 278 } |
| 279 |
| 265 bool CompilerDispatcher::IsEnabled() const { | 280 bool CompilerDispatcher::IsEnabled() const { |
| 266 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_); | 281 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_); |
| 267 return FLAG_compiler_dispatcher && platform_->IdleTasksEnabled(v8_isolate); | 282 return FLAG_compiler_dispatcher && platform_->IdleTasksEnabled(v8_isolate); |
| 268 } | 283 } |
| 269 | 284 |
| 270 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const { | 285 bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const { |
| 271 return GetJobFor(function) != jobs_.end(); | 286 return GetJobFor(function) != jobs_.end(); |
| 272 } | 287 } |
| 273 | 288 |
| 274 void CompilerDispatcher::WaitForJobIfRunningOnBackground( | 289 void CompilerDispatcher::WaitForJobIfRunningOnBackground( |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 lock.reset(); | 622 lock.reset(); |
| 608 DoNextStepOnMainThread(isolate_, job->second.get(), | 623 DoNextStepOnMainThread(isolate_, job->second.get(), |
| 609 ExceptionHandling::kSwallow); | 624 ExceptionHandling::kSwallow); |
| 610 } | 625 } |
| 611 } | 626 } |
| 612 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); | 627 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); |
| 613 } | 628 } |
| 614 | 629 |
| 615 } // namespace internal | 630 } // namespace internal |
| 616 } // namespace v8 | 631 } // namespace v8 |
| OLD | NEW |