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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, | 55 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, |
55 "Inline recursive function calls up to threshold recursion depth."); | 56 "Inline recursive function calls up to threshold recursion depth."); |
56 DEFINE_FLAG(int, max_inlined_per_depth, 500, | 57 DEFINE_FLAG(int, max_inlined_per_depth, 500, |
57 "Max. number of inlined calls per depth"); | 58 "Max. number of inlined calls per depth"); |
58 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); | 59 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); |
59 DEFINE_FLAG(bool, enable_inlining_annotations, false, | 60 DEFINE_FLAG(bool, enable_inlining_annotations, false, |
60 "Enable inlining annotations"); | 61 "Enable inlining annotations"); |
61 | 62 |
62 DECLARE_FLAG(bool, compiler_stats); | 63 DECLARE_FLAG(bool, compiler_stats); |
63 DECLARE_FLAG(int, max_deoptimization_counter_threshold); | 64 DECLARE_FLAG(int, max_deoptimization_counter_threshold); |
64 DECLARE_FLAG(bool, polymorphic_with_deopt); | |
65 DECLARE_FLAG(bool, precompilation); | 65 DECLARE_FLAG(bool, precompilation); |
66 DECLARE_FLAG(bool, print_flow_graph); | 66 DECLARE_FLAG(bool, print_flow_graph); |
67 DECLARE_FLAG(bool, print_flow_graph_optimized); | 67 DECLARE_FLAG(bool, print_flow_graph_optimized); |
68 DECLARE_FLAG(bool, verify_compiler); | 68 DECLARE_FLAG(bool, verify_compiler); |
69 | 69 |
70 // Quick access to the current zone. | 70 // Quick access to the current zone. |
71 #define Z (zone()) | 71 #define Z (zone()) |
72 #define I (isolate()) | 72 #define I (isolate()) |
73 | 73 |
74 #define TRACE_INLINING(statement) \ | 74 #define TRACE_INLINING(statement) \ |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 // Compute SSA on the callee graph, catching bailouts. | 783 // Compute SSA on the callee graph, catching bailouts. |
784 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 784 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
785 param_stubs); | 785 param_stubs); |
786 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 786 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
787 } | 787 } |
788 | 788 |
789 { | 789 { |
790 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); | 790 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); |
791 // TODO(fschneider): Improve suppression of speculative inlining. | 791 // TODO(fschneider): Improve suppression of speculative inlining. |
792 // Deopt-ids overlap between caller and callee. | 792 // 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) { | 793 if (FLAG_precompilation) { |
| 794 AotOptimizer optimizer(callee_graph, |
| 795 inliner_->use_speculative_inlining_, |
| 796 inliner_->inlining_black_list_); |
797 optimizer.PopulateWithICData(); | 797 optimizer.PopulateWithICData(); |
798 | 798 |
799 optimizer.ApplyClassIds(); | 799 optimizer.ApplyClassIds(); |
800 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 800 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
801 | 801 |
802 FlowGraphTypePropagator::Propagate(callee_graph); | 802 FlowGraphTypePropagator::Propagate(callee_graph); |
803 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 803 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 804 |
| 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 } else { |
| 813 FlowGraphOptimizer optimizer(callee_graph, |
| 814 inliner_->use_speculative_inlining_, |
| 815 inliner_->inlining_black_list_); |
| 816 optimizer.ApplyICData(); |
| 817 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 818 |
| 819 // Optimize (a << b) & c patterns, merge instructions. Must occur |
| 820 // before 'SelectRepresentations' which inserts conversion nodes. |
| 821 optimizer.TryOptimizePatterns(); |
| 822 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
804 } | 823 } |
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 } | 824 } |
813 | 825 |
814 if (FLAG_support_il_printer && FLAG_trace_inlining && | 826 if (FLAG_support_il_printer && FLAG_trace_inlining && |
815 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { | 827 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
816 THR_Print("Callee graph for inlining %s\n", | 828 THR_Print("Callee graph for inlining %s\n", |
817 function.ToFullyQualifiedCString()); | 829 function.ToFullyQualifiedCString()); |
818 FlowGraphPrinter printer(*callee_graph); | 830 FlowGraphPrinter printer(*callee_graph); |
819 printer.PrintBlocks(); | 831 printer.PrintBlocks(); |
820 } | 832 } |
821 | 833 |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 Value* input = second->InputAt(i); | 1513 Value* input = second->InputAt(i); |
1502 input->definition()->AddInputUse(input); | 1514 input->definition()->AddInputUse(input); |
1503 } | 1515 } |
1504 first->LinkTo(second); | 1516 first->LinkTo(second); |
1505 return second; | 1517 return second; |
1506 } | 1518 } |
1507 | 1519 |
1508 | 1520 |
1509 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, | 1521 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, |
1510 const Function& target) { | 1522 const Function& target) { |
1511 FlowGraphOptimizer optimizer(owner_->caller_graph(), | |
1512 false, // Speculative inlining not applicable. | |
1513 NULL); | |
1514 TargetEntryInstr* entry; | 1523 TargetEntryInstr* entry; |
1515 Definition* last; | 1524 Definition* last; |
1516 // Replace the receiver argument with a redefinition to prevent code from | 1525 // Replace the receiver argument with a redefinition to prevent code from |
1517 // the inlined body from being hoisted above the inlined entry. | 1526 // the inlined body from being hoisted above the inlined entry. |
1518 GrowableArray<Definition*> arguments(call_->ArgumentCount()); | 1527 GrowableArray<Definition*> arguments(call_->ArgumentCount()); |
1519 Definition* receiver = call_->ArgumentAt(0); | 1528 Definition* receiver = call_->ArgumentAt(0); |
1520 RedefinitionInstr* redefinition = | 1529 RedefinitionInstr* redefinition = |
1521 new(Z) RedefinitionInstr(new(Z) Value(receiver)); | 1530 new(Z) RedefinitionInstr(new(Z) Value(receiver)); |
1522 redefinition->set_ssa_temp_index( | 1531 redefinition->set_ssa_temp_index( |
1523 owner_->caller_graph()->alloc_ssa_temp_index()); | 1532 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); | 3057 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
3049 case MethodRecognizer::kDoubleDiv: | 3058 case MethodRecognizer::kDoubleDiv: |
3050 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3059 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
3051 default: | 3060 default: |
3052 return false; | 3061 return false; |
3053 } | 3062 } |
3054 } | 3063 } |
3055 | 3064 |
3056 | 3065 |
3057 } // namespace dart | 3066 } // namespace dart |
OLD | NEW |