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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return NodeProperties::GetFrameStateInput(call_); | 62 return NodeProperties::GetFrameStateInput(call_); |
63 } | 63 } |
64 | 64 |
65 int formal_arguments() { | 65 int formal_arguments() { |
66 // Both, {JSCallFunction} and {JSCallConstruct}, have two extra inputs: | 66 // Both, {JSCallFunction} and {JSCallConstruct}, have two extra inputs: |
67 // - JSCallConstruct: Includes target function and new target. | 67 // - JSCallConstruct: Includes target function and new target. |
68 // - JSCallFunction: Includes target function and receiver. | 68 // - JSCallFunction: Includes target function and receiver. |
69 return call_->op()->ValueInputCount() - 2; | 69 return call_->op()->ValueInputCount() - 2; |
70 } | 70 } |
71 | 71 |
| 72 float frequency() const { |
| 73 return (call_->opcode() == IrOpcode::kJSCallFunction) |
| 74 ? CallFunctionParametersOf(call_->op()).frequency() |
| 75 : CallConstructParametersOf(call_->op()).frequency(); |
| 76 } |
| 77 |
72 private: | 78 private: |
73 Node* call_; | 79 Node* call_; |
74 }; | 80 }; |
75 | 81 |
76 Reduction JSInliner::InlineCall(Node* call, Node* new_target, Node* context, | 82 Reduction JSInliner::InlineCall(Node* call, Node* new_target, Node* context, |
77 Node* frame_state, Node* start, Node* end, | 83 Node* frame_state, Node* start, Node* end, |
78 Node* exception_target, | 84 Node* exception_target, |
79 const NodeVector& uncaught_subcalls) { | 85 const NodeVector& uncaught_subcalls) { |
80 // The scheduler is smart enough to place our code; we just ensure {control} | 86 // The scheduler is smart enough to place our code; we just ensure {control} |
81 // becomes the control input of the start of the inlinee, and {effect} becomes | 87 // becomes the control input of the start of the inlinee, and {effect} becomes |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 LoopAssignmentAnalysis* loop_assignment = | 518 LoopAssignmentAnalysis* loop_assignment = |
513 loop_assignment_analyzer.Analyze(); | 519 loop_assignment_analyzer.Analyze(); |
514 | 520 |
515 // Run the type hint analyzer on the inlinee. | 521 // Run the type hint analyzer on the inlinee. |
516 TypeHintAnalyzer type_hint_analyzer(&zone); | 522 TypeHintAnalyzer type_hint_analyzer(&zone); |
517 TypeHintAnalysis* type_hint_analysis = | 523 TypeHintAnalysis* type_hint_analysis = |
518 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); | 524 type_hint_analyzer.Analyze(handle(shared_info->code(), info.isolate())); |
519 | 525 |
520 // Run the AstGraphBuilder to create the subgraph. | 526 // Run the AstGraphBuilder to create the subgraph. |
521 Graph::SubgraphScope scope(graph()); | 527 Graph::SubgraphScope scope(graph()); |
522 AstGraphBuilder graph_builder(&zone, &info, jsgraph(), loop_assignment, | 528 AstGraphBuilder graph_builder(&zone, &info, jsgraph(), call.frequency(), |
523 type_hint_analysis); | 529 loop_assignment, type_hint_analysis); |
524 graph_builder.CreateGraph(false); | 530 graph_builder.CreateGraph(false); |
525 | 531 |
526 // Extract the inlinee start/end nodes. | 532 // Extract the inlinee start/end nodes. |
527 start = graph()->start(); | 533 start = graph()->start(); |
528 end = graph()->end(); | 534 end = graph()->end(); |
529 } | 535 } |
530 | 536 |
531 if (exception_target != nullptr) { | 537 if (exception_target != nullptr) { |
532 // Find all uncaught 'calls' in the inlinee. | 538 // Find all uncaught 'calls' in the inlinee. |
533 AllNodes inlined_nodes(local_zone_, end, graph()); | 539 AllNodes inlined_nodes(local_zone_, end, graph()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 667 |
662 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 668 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
663 | 669 |
664 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 670 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
665 return jsgraph()->simplified(); | 671 return jsgraph()->simplified(); |
666 } | 672 } |
667 | 673 |
668 } // namespace compiler | 674 } // namespace compiler |
669 } // namespace internal | 675 } // namespace internal |
670 } // namespace v8 | 676 } // namespace v8 |
OLD | NEW |