OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 !Compiler::EnsureDeoptimizationSupport(&info)) { | 516 !Compiler::EnsureDeoptimizationSupport(&info)) { |
517 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 517 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
518 shared_info->DebugName()->ToCString().get(), | 518 shared_info->DebugName()->ToCString().get(), |
519 info_->shared_info()->DebugName()->ToCString().get()); | 519 info_->shared_info()->DebugName()->ToCString().get()); |
520 return NoChange(); | 520 return NoChange(); |
521 } | 521 } |
522 | 522 |
523 // Remember that we inlined this function. This needs to be called right | 523 // Remember that we inlined this function. This needs to be called right |
524 // after we ensure deoptimization support so that the code flusher | 524 // after we ensure deoptimization support so that the code flusher |
525 // does not remove the code with the deoptimization support. | 525 // does not remove the code with the deoptimization support. |
526 info_->AddInlinedFunction(shared_info); | 526 int inlining_id = info_->AddInlinedFunction( |
| 527 shared_info, source_positions_->GetSourcePosition(node)); |
527 | 528 |
528 // ---------------------------------------------------------------- | 529 // ---------------------------------------------------------------- |
529 // After this point, we've made a decision to inline this function. | 530 // After this point, we've made a decision to inline this function. |
530 // We shall not bailout from inlining if we got here. | 531 // We shall not bailout from inlining if we got here. |
531 | 532 |
532 TRACE("Inlining %s into %s\n", | 533 TRACE("Inlining %s into %s\n", |
533 shared_info->DebugName()->ToCString().get(), | 534 shared_info->DebugName()->ToCString().get(), |
534 info_->shared_info()->DebugName()->ToCString().get()); | 535 info_->shared_info()->DebugName()->ToCString().get()); |
535 | 536 |
536 // If function was lazily compiled, its literals array may not yet be set up. | 537 // If function was lazily compiled, its literals array may not yet be set up. |
537 JSFunction::EnsureLiterals(function); | 538 JSFunction::EnsureLiterals(function); |
538 | 539 |
539 // Create the subgraph for the inlinee. | 540 // Create the subgraph for the inlinee. |
540 Node* start; | 541 Node* start; |
541 Node* end; | 542 Node* end; |
542 if (info.is_optimizing_from_bytecode()) { | 543 if (info.is_optimizing_from_bytecode()) { |
543 // Run the BytecodeGraphBuilder to create the subgraph. | 544 // Run the BytecodeGraphBuilder to create the subgraph. |
544 Graph::SubgraphScope scope(graph()); | 545 Graph::SubgraphScope scope(graph()); |
545 BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(), | 546 BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(), |
546 call.frequency(), nullptr); | 547 call.frequency(), source_positions_, |
| 548 inlining_id); |
547 graph_builder.CreateGraph(false); | 549 graph_builder.CreateGraph(false); |
548 | 550 |
549 // Extract the inlinee start/end nodes. | 551 // Extract the inlinee start/end nodes. |
550 start = graph()->start(); | 552 start = graph()->start(); |
551 end = graph()->end(); | 553 end = graph()->end(); |
552 } else { | 554 } else { |
553 // Run the loop assignment analyzer on the inlinee. | 555 // Run the loop assignment analyzer on the inlinee. |
554 AstLoopAssignmentAnalyzer loop_assignment_analyzer(&zone, &info); | 556 AstLoopAssignmentAnalyzer loop_assignment_analyzer(&zone, &info); |
555 LoopAssignmentAnalysis* loop_assignment = | 557 LoopAssignmentAnalysis* loop_assignment = |
556 loop_assignment_analyzer.Analyze(); | 558 loop_assignment_analyzer.Analyze(); |
557 | 559 |
558 // Run the type hint analyzer on the inlinee. | 560 // Run the type hint analyzer on the inlinee. |
559 TypeHintAnalyzer type_hint_analyzer(&zone); | 561 TypeHintAnalyzer type_hint_analyzer(&zone); |
560 TypeHintAnalysis* type_hint_analysis = | 562 TypeHintAnalysis* type_hint_analysis = |
561 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); | 563 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); |
562 | 564 |
563 // Run the AstGraphBuilder to create the subgraph. | 565 // Run the AstGraphBuilder to create the subgraph. |
564 Graph::SubgraphScope scope(graph()); | 566 Graph::SubgraphScope scope(graph()); |
565 AstGraphBuilder graph_builder(&zone, &info, jsgraph(), call.frequency(), | 567 AstGraphBuilderWithPositions graph_builder( |
566 loop_assignment, type_hint_analysis); | 568 &zone, &info, jsgraph(), call.frequency(), loop_assignment, |
| 569 type_hint_analysis, source_positions_, inlining_id); |
567 graph_builder.CreateGraph(false); | 570 graph_builder.CreateGraph(false); |
568 | 571 |
569 // Extract the inlinee start/end nodes. | 572 // Extract the inlinee start/end nodes. |
570 start = graph()->start(); | 573 start = graph()->start(); |
571 end = graph()->end(); | 574 end = graph()->end(); |
572 } | 575 } |
573 | 576 |
574 if (exception_target != nullptr) { | 577 if (exception_target != nullptr) { |
575 // Find all uncaught 'calls' in the inlinee. | 578 // Find all uncaught 'calls' in the inlinee. |
576 AllNodes inlined_nodes(local_zone_, end, graph()); | 579 AllNodes inlined_nodes(local_zone_, end, graph()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 | 707 |
705 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 708 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
706 | 709 |
707 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 710 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
708 return jsgraph()->simplified(); | 711 return jsgraph()->simplified(); |
709 } | 712 } |
710 | 713 |
711 } // namespace compiler | 714 } // namespace compiler |
712 } // namespace internal | 715 } // namespace internal |
713 } // namespace v8 | 716 } // namespace v8 |
OLD | NEW |