| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 !Compiler::EnsureDeoptimizationSupport(&info)) { | 503 !Compiler::EnsureDeoptimizationSupport(&info)) { |
| 504 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 504 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
| 505 shared_info->DebugName()->ToCString().get(), | 505 shared_info->DebugName()->ToCString().get(), |
| 506 info_->shared_info()->DebugName()->ToCString().get()); | 506 info_->shared_info()->DebugName()->ToCString().get()); |
| 507 return NoChange(); | 507 return NoChange(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 // Remember that we inlined this function. This needs to be called right | 510 // Remember that we inlined this function. This needs to be called right |
| 511 // after we ensure deoptimization support so that the code flusher | 511 // after we ensure deoptimization support so that the code flusher |
| 512 // does not remove the code with the deoptimization support. | 512 // does not remove the code with the deoptimization support. |
| 513 info_->AddInlinedFunction(shared_info); | 513 int inlining_id = info_->AddInlinedFunction( |
| 514 shared_info, source_positions_->GetSourcePosition(node)); |
| 514 | 515 |
| 515 // ---------------------------------------------------------------- | 516 // ---------------------------------------------------------------- |
| 516 // After this point, we've made a decision to inline this function. | 517 // After this point, we've made a decision to inline this function. |
| 517 // We shall not bailout from inlining if we got here. | 518 // We shall not bailout from inlining if we got here. |
| 518 | 519 |
| 519 TRACE("Inlining %s into %s\n", | 520 TRACE("Inlining %s into %s\n", |
| 520 shared_info->DebugName()->ToCString().get(), | 521 shared_info->DebugName()->ToCString().get(), |
| 521 info_->shared_info()->DebugName()->ToCString().get()); | 522 info_->shared_info()->DebugName()->ToCString().get()); |
| 522 | 523 |
| 523 // If function was lazily compiled, its literals array may not yet be set up. | 524 // If function was lazily compiled, its literals array may not yet be set up. |
| 524 JSFunction::EnsureLiterals(function); | 525 JSFunction::EnsureLiterals(function); |
| 525 | 526 |
| 526 // Create the subgraph for the inlinee. | 527 // Create the subgraph for the inlinee. |
| 527 Node* start; | 528 Node* start; |
| 528 Node* end; | 529 Node* end; |
| 529 if (info.is_optimizing_from_bytecode()) { | 530 if (info.is_optimizing_from_bytecode()) { |
| 530 // Run the BytecodeGraphBuilder to create the subgraph. | 531 // Run the BytecodeGraphBuilder to create the subgraph. |
| 531 Graph::SubgraphScope scope(graph()); | 532 Graph::SubgraphScope scope(graph()); |
| 532 BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(), | 533 BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(), |
| 533 call.frequency(), nullptr); | 534 call.frequency(), source_positions_, |
| 535 inlining_id); |
| 534 graph_builder.CreateGraph(false); | 536 graph_builder.CreateGraph(false); |
| 535 | 537 |
| 536 // Extract the inlinee start/end nodes. | 538 // Extract the inlinee start/end nodes. |
| 537 start = graph()->start(); | 539 start = graph()->start(); |
| 538 end = graph()->end(); | 540 end = graph()->end(); |
| 539 } else { | 541 } else { |
| 540 // Run the loop assignment analyzer on the inlinee. | 542 // Run the loop assignment analyzer on the inlinee. |
| 541 AstLoopAssignmentAnalyzer loop_assignment_analyzer(&zone, &info); | 543 AstLoopAssignmentAnalyzer loop_assignment_analyzer(&zone, &info); |
| 542 LoopAssignmentAnalysis* loop_assignment = | 544 LoopAssignmentAnalysis* loop_assignment = |
| 543 loop_assignment_analyzer.Analyze(); | 545 loop_assignment_analyzer.Analyze(); |
| 544 | 546 |
| 545 // Run the type hint analyzer on the inlinee. | 547 // Run the type hint analyzer on the inlinee. |
| 546 TypeHintAnalyzer type_hint_analyzer(&zone); | 548 TypeHintAnalyzer type_hint_analyzer(&zone); |
| 547 TypeHintAnalysis* type_hint_analysis = | 549 TypeHintAnalysis* type_hint_analysis = |
| 548 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); | 550 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); |
| 549 | 551 |
| 550 // Run the AstGraphBuilder to create the subgraph. | 552 // Run the AstGraphBuilder to create the subgraph. |
| 551 Graph::SubgraphScope scope(graph()); | 553 Graph::SubgraphScope scope(graph()); |
| 552 AstGraphBuilder graph_builder(&zone, &info, jsgraph(), call.frequency(), | 554 AstGraphBuilderWithPositions graph_builder( |
| 553 loop_assignment, type_hint_analysis); | 555 &zone, &info, jsgraph(), call.frequency(), loop_assignment, |
| 556 type_hint_analysis, source_positions_, inlining_id); |
| 554 graph_builder.CreateGraph(false); | 557 graph_builder.CreateGraph(false); |
| 555 | 558 |
| 556 // Extract the inlinee start/end nodes. | 559 // Extract the inlinee start/end nodes. |
| 557 start = graph()->start(); | 560 start = graph()->start(); |
| 558 end = graph()->end(); | 561 end = graph()->end(); |
| 559 } | 562 } |
| 560 | 563 |
| 561 if (exception_target != nullptr) { | 564 if (exception_target != nullptr) { |
| 562 // Find all uncaught 'calls' in the inlinee. | 565 // Find all uncaught 'calls' in the inlinee. |
| 563 AllNodes inlined_nodes(local_zone_, end, graph()); | 566 AllNodes inlined_nodes(local_zone_, end, graph()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 694 |
| 692 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 695 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
| 693 | 696 |
| 694 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 697 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
| 695 return jsgraph()->simplified(); | 698 return jsgraph()->simplified(); |
| 696 } | 699 } |
| 697 | 700 |
| 698 } // namespace compiler | 701 } // namespace compiler |
| 699 } // namespace internal | 702 } // namespace internal |
| 700 } // namespace v8 | 703 } // namespace v8 |
| OLD | NEW |