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

Side by Side Diff: src/compiler.cc

Issue 2648503002: [Compiler] Have renumber recurse into eagerly compiled function literals. (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/ast/ast-numbering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 if (info->parse_info()->literal()->should_be_used_once_hint()) { 448 if (info->parse_info()->literal()->should_be_used_once_hint()) {
449 info->code()->MarkToBeExecutedOnce(info->isolate()); 449 info->code()->MarkToBeExecutedOnce(info->isolate());
450 } 450 }
451 InstallUnoptimizedCode(info); 451 InstallUnoptimizedCode(info);
452 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, info); 452 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, info);
453 job->RecordUnoptimizedCompilationStats(); 453 job->RecordUnoptimizedCompilationStats();
454 } 454 }
455 return status; 455 return status;
456 } 456 }
457 457
458 void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal,
459 Handle<SharedFunctionInfo> shared_info) {
460 shared_info->set_ast_node_count(literal->ast_node_count());
461 if (literal->dont_optimize_reason() != kNoReason) {
462 shared_info->DisableOptimization(literal->dont_optimize_reason());
463 }
464 if (literal->flags() & AstProperties::kMustUseIgnitionTurbo) {
465 shared_info->set_must_use_ignition_turbo(true);
466 }
467 }
468
458 bool Renumber(Isolate* isolate, Zone* zone, FunctionLiteral* literal, 469 bool Renumber(Isolate* isolate, Zone* zone, FunctionLiteral* literal,
459 Handle<SharedFunctionInfo> shared_info, 470 Handle<SharedFunctionInfo> shared_info,
460 Compiler::EagerInnerFunctionLiterals* eager_literals) { 471 Compiler::EagerInnerFunctionLiterals* eager_literals) {
461 RuntimeCallTimerScope runtimeTimer(isolate, 472 RuntimeCallTimerScope runtimeTimer(isolate,
462 &RuntimeCallStats::CompileRenumber); 473 &RuntimeCallStats::CompileRenumber);
463 if (!AstNumbering::Renumber(isolate->stack_guard()->real_climit(), zone, 474 if (!AstNumbering::Renumber(isolate->stack_guard()->real_climit(), zone,
464 literal, eager_literals)) { 475 literal, eager_literals)) {
465 return false; 476 return false;
466 } 477 }
478
467 if (!shared_info.is_null()) { 479 if (!shared_info.is_null()) {
468 shared_info->set_ast_node_count(literal->ast_node_count()); 480 SetSharedFunctionFlagsFromLiteral(literal, shared_info);
469 if (literal->dont_optimize_reason() != kNoReason) {
470 shared_info->DisableOptimization(literal->dont_optimize_reason());
471 }
472 if (literal->flags() & AstProperties::kMustUseIgnitionTurbo) {
473 shared_info->set_must_use_ignition_turbo(true);
474 }
475 } 481 }
476 return true; 482 return true;
477 } 483 }
478 484
479 bool GenerateUnoptimizedCode(CompilationInfo* info) { 485 bool GenerateUnoptimizedCode(CompilationInfo* info) {
480 if (UseAsmWasm(info->scope(), info->shared_info(), info->is_debug())) { 486 if (UseAsmWasm(info->scope(), info->shared_info(), info->is_debug())) {
481 EnsureFeedbackMetadata(info); 487 EnsureFeedbackMetadata(info);
482 MaybeHandle<FixedArray> wasm_data; 488 MaybeHandle<FixedArray> wasm_data;
483 wasm_data = AsmJs::CompileAsmViaWasm(info); 489 wasm_data = AsmJs::CompileAsmViaWasm(info);
484 if (!wasm_data.is_null()) { 490 if (!wasm_data.is_null()) {
485 info->shared_info()->set_asm_wasm_data(*wasm_data.ToHandleChecked()); 491 info->shared_info()->set_asm_wasm_data(*wasm_data.ToHandleChecked());
486 info->SetCode(info->isolate()->builtins()->InstantiateAsmJs()); 492 info->SetCode(info->isolate()->builtins()->InstantiateAsmJs());
487 InstallUnoptimizedCode(info); 493 InstallUnoptimizedCode(info);
488 return true; 494 return true;
489 } 495 }
490 } 496 }
491 497
492 std::unique_ptr<CompilationJob> job(GetUnoptimizedCompilationJob(info)); 498 std::unique_ptr<CompilationJob> job(GetUnoptimizedCompilationJob(info));
493 if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false; 499 if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
494 if (job->ExecuteJob() != CompilationJob::SUCCEEDED) return false; 500 if (job->ExecuteJob() != CompilationJob::SUCCEEDED) return false;
495 if (FinalizeUnoptimizedCompilationJob(job.get()) != 501 if (FinalizeUnoptimizedCompilationJob(job.get()) !=
496 CompilationJob::SUCCEEDED) { 502 CompilationJob::SUCCEEDED) {
497 return false; 503 return false;
498 } 504 }
499 return true; 505 return true;
500 } 506 }
501 507
502 bool CompileUnoptimizedInnerFunctionsRecursively( 508 bool CompileUnoptimizedInnerFunctions(
503 ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* literals, 509 ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* literals,
504 CompilationInfo* outer_info) { 510 CompilationInfo* outer_info) {
505 Isolate* isolate = outer_info->isolate(); 511 Isolate* isolate = outer_info->isolate();
506 Handle<Script> script = outer_info->script(); 512 Handle<Script> script = outer_info->script();
507 bool is_debug = outer_info->is_debug(); 513 bool is_debug = outer_info->is_debug();
508 bool will_serialize = outer_info->will_serialize(); 514 bool will_serialize = outer_info->will_serialize();
509 RuntimeCallTimerScope runtimeTimer(isolate, 515 RuntimeCallTimerScope runtimeTimer(isolate,
510 &RuntimeCallStats::CompileInnerFunction); 516 &RuntimeCallStats::CompileInnerFunction);
511 517
512 for (auto it : *literals) { 518 for (auto it : *literals) {
513 FunctionLiteral* literal = it->value(); 519 FunctionLiteral* literal = it->value();
514 Handle<SharedFunctionInfo> shared = 520 Handle<SharedFunctionInfo> shared =
515 Compiler::GetSharedFunctionInfo(literal, script, outer_info); 521 Compiler::GetSharedFunctionInfo(literal, script, outer_info);
516 if (shared->is_compiled()) continue; 522 if (shared->is_compiled()) continue;
517 Compiler::EagerInnerFunctionLiterals inner_literals; 523
518 if (!Renumber(isolate, outer_info->zone(), literal, shared, 524 SetSharedFunctionFlagsFromLiteral(literal, shared);
Michael Starzinger 2017/01/19 13:29:22 nit: Please add a brief comment here explaining th
rmcilroy 2017/01/19 17:24:49 Done.
519 &inner_literals) ||
520 !CompileUnoptimizedInnerFunctionsRecursively(&inner_literals,
521 outer_info)) {
522 if (!isolate->has_pending_exception()) isolate->StackOverflow();
523 return false;
524 }
525 525
526 // Try to enqueue the eager function on the compiler dispatcher. 526 // Try to enqueue the eager function on the compiler dispatcher.
527 CompilerDispatcher* dispatcher = isolate->compiler_dispatcher(); 527 CompilerDispatcher* dispatcher = isolate->compiler_dispatcher();
528 if (UseCompilerDispatcher(dispatcher, literal->scope(), shared, is_debug, 528 if (UseCompilerDispatcher(dispatcher, literal->scope(), shared, is_debug,
529 will_serialize) && 529 will_serialize) &&
530 dispatcher->EnqueueAndStep(shared, literal)) { 530 dispatcher->EnqueueAndStep(shared, literal)) {
531 // If we have successfully queued up the function for compilation on the 531 // If we have successfully queued up the function for compilation on the
532 // compiler dispatcher then we are done. 532 // compiler dispatcher then we are done.
533 continue; 533 continue;
534 } else { 534 } else {
(...skipping 20 matching lines...) Expand all
555 } 555 }
556 return true; 556 return true;
557 } 557 }
558 558
559 bool CompileUnoptimizedCode(CompilationInfo* info) { 559 bool CompileUnoptimizedCode(CompilationInfo* info) {
560 Isolate* isolate = info->isolate(); 560 Isolate* isolate = info->isolate();
561 DCHECK(AllowCompilation::IsAllowed(isolate)); 561 DCHECK(AllowCompilation::IsAllowed(isolate));
562 562
563 Compiler::EagerInnerFunctionLiterals inner_literals; 563 Compiler::EagerInnerFunctionLiterals inner_literals;
564 if (!Compiler::Analyze(info->parse_info(), &inner_literals) || 564 if (!Compiler::Analyze(info->parse_info(), &inner_literals) ||
565 !CompileUnoptimizedInnerFunctionsRecursively(&inner_literals, info) || 565 !CompileUnoptimizedInnerFunctions(&inner_literals, info) ||
566 !GenerateUnoptimizedCode(info)) { 566 !GenerateUnoptimizedCode(info)) {
567 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 567 if (!isolate->has_pending_exception()) isolate->StackOverflow();
568 return false; 568 return false;
569 } 569 }
570 570
571 // TODO(rmcilroy): Remove this once the enqueued tasks can keep the parsed 571 // TODO(rmcilroy): Remove this once the enqueued tasks can keep the parsed
572 // zone and handles alive and replace with a check in CompileLazy to finish 572 // zone and handles alive and replace with a check in CompileLazy to finish
573 // the task itself. 573 // the task itself.
574 if (isolate->compiler_dispatcher()->IsEnabled() && 574 if (isolate->compiler_dispatcher()->IsEnabled() &&
575 !isolate->compiler_dispatcher()->FinishAllNow()) { 575 !isolate->compiler_dispatcher()->FinishAllNow()) {
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 } 1780 }
1781 1781
1782 if (shared->is_compiled()) { 1782 if (shared->is_compiled()) {
1783 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1783 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1784 JSFunction::EnsureLiterals(function); 1784 JSFunction::EnsureLiterals(function);
1785 } 1785 }
1786 } 1786 }
1787 1787
1788 } // namespace internal 1788 } // namespace internal
1789 } // namespace v8 1789 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698