OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
6 | 6 |
7 #include "vm/aot_optimizer.h" | |
7 #include "vm/block_scheduler.h" | 8 #include "vm/block_scheduler.h" |
8 #include "vm/branch_optimizer.h" | 9 #include "vm/branch_optimizer.h" |
9 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
10 #include "vm/flags.h" | 11 #include "vm/flags.h" |
11 #include "vm/flow_graph.h" | 12 #include "vm/flow_graph.h" |
12 #include "vm/flow_graph_builder.h" | 13 #include "vm/flow_graph_builder.h" |
13 #include "vm/flow_graph_compiler.h" | 14 #include "vm/flow_graph_compiler.h" |
14 #include "vm/flow_graph_optimizer.h" | 15 #include "vm/flow_graph_optimizer.h" |
15 #include "vm/flow_graph_type_propagator.h" | 16 #include "vm/flow_graph_type_propagator.h" |
16 #include "vm/il_printer.h" | 17 #include "vm/il_printer.h" |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 // Compute SSA on the callee graph, catching bailouts. | 784 // Compute SSA on the callee graph, catching bailouts. |
784 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 785 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
785 param_stubs); | 786 param_stubs); |
786 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 787 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
787 } | 788 } |
788 | 789 |
789 { | 790 { |
790 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); | 791 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); |
791 // TODO(fschneider): Improve suppression of speculative inlining. | 792 // TODO(fschneider): Improve suppression of speculative inlining. |
792 // Deopt-ids overlap between caller and callee. | 793 // Deopt-ids overlap between caller and callee. |
793 FlowGraphOptimizer optimizer(callee_graph, | |
794 inliner_->use_speculative_inlining_, | |
795 inliner_->inlining_black_list_); | |
796 if (FLAG_precompilation) { | 794 if (FLAG_precompilation) { |
795 AotOptimizer optimizer(callee_graph, | |
796 inliner_->use_speculative_inlining_, | |
797 inliner_->inlining_black_list_); | |
797 optimizer.PopulateWithICData(); | 798 optimizer.PopulateWithICData(); |
798 | 799 |
799 optimizer.ApplyClassIds(); | 800 optimizer.ApplyClassIds(); |
800 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 801 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
801 | 802 |
802 FlowGraphTypePropagator::Propagate(callee_graph); | 803 FlowGraphTypePropagator::Propagate(callee_graph); |
803 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 804 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
805 | |
806 optimizer.ApplyICData(); | |
807 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
808 | |
809 // Optimize (a << b) & c patterns, merge instructions. Must occur | |
810 // before 'SelectRepresentations' which inserts conversion nodes. | |
811 optimizer.TryOptimizePatterns(); | |
812 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
813 } else { | |
814 FlowGraphOptimizer optimizer(callee_graph, | |
rmacnak
2016/02/19 00:54:32
Maybe this should be JitOptimizer for clarity.
Florian Schneider
2016/02/19 17:42:29
Ack. Will do this in a separate CL to not blow thi
| |
815 inliner_->use_speculative_inlining_, | |
816 inliner_->inlining_black_list_); | |
817 optimizer.ApplyICData(); | |
818 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
819 | |
820 // Optimize (a << b) & c patterns, merge instructions. Must occur | |
821 // before 'SelectRepresentations' which inserts conversion nodes. | |
822 optimizer.TryOptimizePatterns(); | |
823 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
804 } | 824 } |
805 optimizer.ApplyICData(); | |
806 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
807 | |
808 // Optimize (a << b) & c patterns, merge instructions. Must occur | |
809 // before 'SelectRepresentations' which inserts conversion nodes. | |
810 optimizer.TryOptimizePatterns(); | |
811 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | |
812 } | 825 } |
813 | 826 |
814 if (FLAG_support_il_printer && FLAG_trace_inlining && | 827 if (FLAG_support_il_printer && FLAG_trace_inlining && |
815 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { | 828 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
816 THR_Print("Callee graph for inlining %s\n", | 829 THR_Print("Callee graph for inlining %s\n", |
817 function.ToFullyQualifiedCString()); | 830 function.ToFullyQualifiedCString()); |
818 FlowGraphPrinter printer(*callee_graph); | 831 FlowGraphPrinter printer(*callee_graph); |
819 printer.PrintBlocks(); | 832 printer.PrintBlocks(); |
820 } | 833 } |
821 | 834 |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 Value* input = second->InputAt(i); | 1514 Value* input = second->InputAt(i); |
1502 input->definition()->AddInputUse(input); | 1515 input->definition()->AddInputUse(input); |
1503 } | 1516 } |
1504 first->LinkTo(second); | 1517 first->LinkTo(second); |
1505 return second; | 1518 return second; |
1506 } | 1519 } |
1507 | 1520 |
1508 | 1521 |
1509 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, | 1522 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, |
1510 const Function& target) { | 1523 const Function& target) { |
1511 FlowGraphOptimizer optimizer(owner_->caller_graph(), | |
1512 false, // Speculative inlining not applicable. | |
1513 NULL); | |
1514 TargetEntryInstr* entry; | 1524 TargetEntryInstr* entry; |
1515 Definition* last; | 1525 Definition* last; |
1516 // Replace the receiver argument with a redefinition to prevent code from | 1526 // Replace the receiver argument with a redefinition to prevent code from |
1517 // the inlined body from being hoisted above the inlined entry. | 1527 // the inlined body from being hoisted above the inlined entry. |
1518 GrowableArray<Definition*> arguments(call_->ArgumentCount()); | 1528 GrowableArray<Definition*> arguments(call_->ArgumentCount()); |
1519 Definition* receiver = call_->ArgumentAt(0); | 1529 Definition* receiver = call_->ArgumentAt(0); |
1520 RedefinitionInstr* redefinition = | 1530 RedefinitionInstr* redefinition = |
1521 new(Z) RedefinitionInstr(new(Z) Value(receiver)); | 1531 new(Z) RedefinitionInstr(new(Z) Value(receiver)); |
1522 redefinition->set_ssa_temp_index( | 1532 redefinition->set_ssa_temp_index( |
1523 owner_->caller_graph()->alloc_ssa_temp_index()); | 1533 owner_->caller_graph()->alloc_ssa_temp_index()); |
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3048 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); | 3058 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
3049 case MethodRecognizer::kDoubleDiv: | 3059 case MethodRecognizer::kDoubleDiv: |
3050 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3060 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
3051 default: | 3061 default: |
3052 return false; | 3062 return false; |
3053 } | 3063 } |
3054 } | 3064 } |
3055 | 3065 |
3056 | 3066 |
3057 } // namespace dart | 3067 } // namespace dart |
OLD | NEW |