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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 function->ShortPrint(); | 280 function->ShortPrint(); |
281 PrintF("\n"); | 281 PrintF("\n"); |
282 } | 282 } |
283 JobMap::const_iterator job = GetJobFor(function); | 283 JobMap::const_iterator job = GetJobFor(function); |
284 DoNextStepOnMainThread(isolate_, job->second.get(), | 284 DoNextStepOnMainThread(isolate_, job->second.get(), |
285 ExceptionHandling::kSwallow); | 285 ExceptionHandling::kSwallow); |
286 ConsiderJobForBackgroundProcessing(job->second.get()); | 286 ConsiderJobForBackgroundProcessing(job->second.get()); |
287 return true; | 287 return true; |
288 } | 288 } |
289 | 289 |
290 bool CompilerDispatcher::Enqueue( | 290 bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function, |
291 Handle<SharedFunctionInfo> function, FunctionLiteral* literal, | 291 FunctionLiteral* literal) { |
292 std::shared_ptr<Zone> parse_zone, | |
293 std::shared_ptr<DeferredHandles> parse_handles, | |
294 std::shared_ptr<DeferredHandles> compile_handles) { | |
295 if (!CanEnqueue(function)) return false; | 292 if (!CanEnqueue(function)) return false; |
296 if (IsEnqueued(function)) return true; | 293 if (IsEnqueued(function)) return true; |
297 | 294 |
298 if (trace_compiler_dispatcher_) { | 295 if (trace_compiler_dispatcher_) { |
299 PrintF("CompilerDispatcher: enqueuing "); | 296 PrintF("CompilerDispatcher: enqueuing "); |
300 function->ShortPrint(); | 297 function->ShortPrint(); |
301 PrintF(" for compile\n"); | 298 PrintF(" for compile\n"); |
302 } | 299 } |
303 | 300 |
304 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 301 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
305 isolate_, tracer_.get(), function, literal, parse_zone, parse_handles, | 302 isolate_, tracer_.get(), function, literal, max_stack_size_)); |
306 compile_handles, max_stack_size_)); | |
307 std::pair<int, int> key(Script::cast(function->script())->id(), | 303 std::pair<int, int> key(Script::cast(function->script())->id(), |
308 function->function_literal_id()); | 304 function->function_literal_id()); |
309 jobs_.insert(std::make_pair(key, std::move(job))); | 305 jobs_.insert(std::make_pair(key, std::move(job))); |
310 ScheduleIdleTaskIfNeeded(); | 306 ScheduleIdleTaskIfNeeded(); |
311 return true; | 307 return true; |
312 } | 308 } |
313 | 309 |
314 bool CompilerDispatcher::EnqueueAndStep( | 310 bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function, |
315 Handle<SharedFunctionInfo> function, FunctionLiteral* literal, | 311 FunctionLiteral* literal) { |
316 std::shared_ptr<Zone> parse_zone, | 312 if (!Enqueue(function, literal)) return false; |
317 std::shared_ptr<DeferredHandles> parse_handles, | |
318 std::shared_ptr<DeferredHandles> compile_handles) { | |
319 if (!Enqueue(function, literal, parse_zone, parse_handles, compile_handles)) { | |
320 return false; | |
321 } | |
322 | 313 |
323 if (trace_compiler_dispatcher_) { | 314 if (trace_compiler_dispatcher_) { |
324 PrintF("CompilerDispatcher: stepping "); | 315 PrintF("CompilerDispatcher: stepping "); |
325 function->ShortPrint(); | 316 function->ShortPrint(); |
326 PrintF("\n"); | 317 PrintF("\n"); |
327 } | 318 } |
328 JobMap::const_iterator job = GetJobFor(function); | 319 JobMap::const_iterator job = GetJobFor(function); |
329 DoNextStepOnMainThread(isolate_, job->second.get(), | 320 DoNextStepOnMainThread(isolate_, job->second.get(), |
330 ExceptionHandling::kSwallow); | 321 ExceptionHandling::kSwallow); |
331 ConsiderJobForBackgroundProcessing(job->second.get()); | 322 ConsiderJobForBackgroundProcessing(job->second.get()); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 lock.reset(); | 693 lock.reset(); |
703 DoNextStepOnMainThread(isolate_, job->second.get(), | 694 DoNextStepOnMainThread(isolate_, job->second.get(), |
704 ExceptionHandling::kSwallow); | 695 ExceptionHandling::kSwallow); |
705 } | 696 } |
706 } | 697 } |
707 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); | 698 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); |
708 } | 699 } |
709 | 700 |
710 } // namespace internal | 701 } // namespace internal |
711 } // namespace v8 | 702 } // namespace v8 |
OLD | NEW |