| 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/block_scheduler.h" | 7 #include "vm/block_scheduler.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 BlockScheduler block_scheduler(callee_graph); | 701 BlockScheduler block_scheduler(callee_graph); |
| 702 block_scheduler.AssignEdgeWeights(); | 702 block_scheduler.AssignEdgeWeights(); |
| 703 | 703 |
| 704 { | 704 { |
| 705 TimerScope timer(FLAG_compiler_stats, | 705 TimerScope timer(FLAG_compiler_stats, |
| 706 &CompilerStats::graphinliner_ssa_timer, | 706 &CompilerStats::graphinliner_ssa_timer, |
| 707 isolate()); | 707 isolate()); |
| 708 // Compute SSA on the callee graph, catching bailouts. | 708 // Compute SSA on the callee graph, catching bailouts. |
| 709 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 709 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
| 710 param_stubs); | 710 param_stubs); |
| 711 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 711 ASSERT(callee_graph->VerifyUseLists()); |
| 712 } | 712 } |
| 713 | 713 |
| 714 { | 714 { |
| 715 TimerScope timer(FLAG_compiler_stats, | 715 TimerScope timer(FLAG_compiler_stats, |
| 716 &CompilerStats::graphinliner_opt_timer, | 716 &CompilerStats::graphinliner_opt_timer, |
| 717 isolate()); | 717 isolate()); |
| 718 // TODO(zerny): Do more optimization passes on the callee graph. | 718 // TODO(zerny): Do more optimization passes on the callee graph. |
| 719 FlowGraphOptimizer optimizer(callee_graph); | 719 FlowGraphOptimizer optimizer(callee_graph); |
| 720 optimizer.ApplyICData(); | 720 optimizer.ApplyICData(); |
| 721 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 721 ASSERT(callee_graph->VerifyUseLists()); |
| 722 | 722 |
| 723 // Optimize (a << b) & c patterns, merge instructions. Must occur before | 723 // Optimize (a << b) & c patterns, merge instructions. Must occur before |
| 724 // 'SelectRepresentations' which inserts conversion nodes. | 724 // 'SelectRepresentations' which inserts conversion nodes. |
| 725 optimizer.TryOptimizePatterns(); | 725 optimizer.TryOptimizePatterns(); |
| 726 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 726 ASSERT(callee_graph->VerifyUseLists()); |
| 727 } | 727 } |
| 728 | 728 |
| 729 if (FLAG_trace_inlining && | 729 if (FLAG_trace_inlining && |
| 730 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { | 730 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 731 OS::Print("Callee graph for inlining %s\n", | 731 OS::Print("Callee graph for inlining %s\n", |
| 732 function.ToFullyQualifiedCString()); | 732 function.ToFullyQualifiedCString()); |
| 733 FlowGraphPrinter printer(*callee_graph); | 733 FlowGraphPrinter printer(*callee_graph); |
| 734 printer.PrintBlocks(); | 734 printer.PrintBlocks(); |
| 735 } | 735 } |
| 736 | 736 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 callee_graph->graph_entry()->initial_definitions(); | 926 callee_graph->graph_entry()->initial_definitions(); |
| 927 for (intptr_t i = 0; i < defns->length(); ++i) { | 927 for (intptr_t i = 0; i < defns->length(); ++i) { |
| 928 ConstantInstr* constant = (*defns)[i]->AsConstant(); | 928 ConstantInstr* constant = (*defns)[i]->AsConstant(); |
| 929 if ((constant != NULL) && constant->HasUses()) { | 929 if ((constant != NULL) && constant->HasUses()) { |
| 930 constant->ReplaceUsesWith( | 930 constant->ReplaceUsesWith( |
| 931 caller_graph_->GetConstant(constant->value())); | 931 caller_graph_->GetConstant(constant->value())); |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 | 934 |
| 935 // Check that inlining maintains use lists. | 935 // Check that inlining maintains use lists. |
| 936 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists()); | 936 ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists()); |
| 937 } | 937 } |
| 938 | 938 |
| 939 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) { | 939 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) { |
| 940 intptr_t count = 0; | 940 intptr_t count = 0; |
| 941 for (intptr_t i = 0; i < arguments.length(); i++) { | 941 for (intptr_t i = 0; i < arguments.length(); i++) { |
| 942 if (arguments[i]->BindsToConstant()) count++; | 942 if (arguments[i]->BindsToConstant()) count++; |
| 943 } | 943 } |
| 944 return count; | 944 return count; |
| 945 } | 945 } |
| 946 | 946 |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 OS::Print("After Inlining of %s\n", flow_graph_-> | 1721 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1722 parsed_function().function().ToFullyQualifiedCString()); | 1722 parsed_function().function().ToFullyQualifiedCString()); |
| 1723 FlowGraphPrinter printer(*flow_graph_); | 1723 FlowGraphPrinter printer(*flow_graph_); |
| 1724 printer.PrintBlocks(); | 1724 printer.PrintBlocks(); |
| 1725 } | 1725 } |
| 1726 } | 1726 } |
| 1727 } | 1727 } |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 } // namespace dart | 1730 } // namespace dart |
| OLD | NEW |