| 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 GrowthFactor(), | 810 GrowthFactor(), |
| 811 initial_size_, | 811 initial_size_, |
| 812 inlined_size_); | 812 inlined_size_); |
| 813 PrintInlinedInfoFor(top, 1); | 813 PrintInlinedInfoFor(top, 1); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 private: | 817 private: |
| 818 friend class PolymorphicInliner; | 818 friend class PolymorphicInliner; |
| 819 | 819 |
| 820 |
| 821 static bool Contains(const GrowableArray<intptr_t>& a, intptr_t deopt_id) { |
| 822 for (intptr_t i = 0; i < a.length(); i++) { |
| 823 if (a[i] == deopt_id) return true; |
| 824 } |
| 825 return false; |
| 826 } |
| 827 |
| 820 void PrintInlinedInfoFor(const Function& caller, intptr_t depth) { | 828 void PrintInlinedInfoFor(const Function& caller, intptr_t depth) { |
| 829 // Prevent duplicate printing as inlined_info aggregates all inlinining. |
| 830 GrowableArray<intptr_t> call_instructions_printed; |
| 821 // Print those that were inlined. | 831 // Print those that were inlined. |
| 822 for (intptr_t i = 0; i < inlined_info_.length(); i++) { | 832 for (intptr_t i = 0; i < inlined_info_.length(); i++) { |
| 823 const InlinedInfo& info = inlined_info_[i]; | 833 const InlinedInfo& info = inlined_info_[i]; |
| 824 if (info.bailout_reason != NULL) { | 834 if (info.bailout_reason != NULL) { |
| 825 continue; | 835 continue; |
| 826 } | 836 } |
| 827 if ((info.inlined_depth == depth) && | 837 if ((info.inlined_depth == depth) && |
| 828 (info.caller->raw() == caller.raw())) { | 838 (info.caller->raw() == caller.raw()) && |
| 839 !Contains(call_instructions_printed, info.call_instr->GetDeoptId())) { |
| 829 for (int t = 0; t < depth; t++) { | 840 for (int t = 0; t < depth; t++) { |
| 830 OS::Print(" "); | 841 OS::Print(" "); |
| 831 } | 842 } |
| 832 OS::Print("%" Pd " %s\n", | 843 OS::Print("%" Pd " %s\n", |
| 833 info.call_instr->GetDeoptId(), | 844 info.call_instr->GetDeoptId(), |
| 834 info.inlined->ToQualifiedCString()); | 845 info.inlined->ToQualifiedCString()); |
| 835 PrintInlinedInfoFor(*info.inlined, depth + 1); | 846 PrintInlinedInfoFor(*info.inlined, depth + 1); |
| 847 call_instructions_printed.Add(info.call_instr->GetDeoptId()); |
| 836 } | 848 } |
| 837 } | 849 } |
| 850 call_instructions_printed.Clear(); |
| 838 // Print those that were not inlined. | 851 // Print those that were not inlined. |
| 839 for (intptr_t i = 0; i < inlined_info_.length(); i++) { | 852 for (intptr_t i = 0; i < inlined_info_.length(); i++) { |
| 840 const InlinedInfo& info = inlined_info_[i]; | 853 const InlinedInfo& info = inlined_info_[i]; |
| 841 if (info.bailout_reason == NULL) { | 854 if (info.bailout_reason == NULL) { |
| 842 continue; | 855 continue; |
| 843 } | 856 } |
| 844 if ((info.inlined_depth == depth) && | 857 if ((info.inlined_depth == depth) && |
| 845 (info.caller->raw() == caller.raw())) { | 858 (info.caller->raw() == caller.raw()) && |
| 859 !Contains(call_instructions_printed, info.call_instr->GetDeoptId())) { |
| 846 for (int t = 0; t < depth; t++) { | 860 for (int t = 0; t < depth; t++) { |
| 847 OS::Print(" "); | 861 OS::Print(" "); |
| 848 } | 862 } |
| 849 OS::Print("NO %" Pd " %s - %s\n", | 863 OS::Print("NO %" Pd " %s - %s\n", |
| 850 info.call_instr->GetDeoptId(), | 864 info.call_instr->GetDeoptId(), |
| 851 info.inlined->ToQualifiedCString(), | 865 info.inlined->ToQualifiedCString(), |
| 852 info.bailout_reason); | 866 info.bailout_reason); |
| 867 call_instructions_printed.Add(info.call_instr->GetDeoptId()); |
| 853 } | 868 } |
| 854 } | 869 } |
| 855 } | 870 } |
| 856 | 871 |
| 857 void InlineCall(InlinedCallData* call_data) { | 872 void InlineCall(InlinedCallData* call_data) { |
| 858 TimerScope timer(FLAG_compiler_stats, | 873 TimerScope timer(FLAG_compiler_stats, |
| 859 &CompilerStats::graphinliner_subst_timer, | 874 &CompilerStats::graphinliner_subst_timer, |
| 860 Isolate::Current()); | 875 Isolate::Current()); |
| 861 FlowGraph* callee_graph = call_data->callee_graph; | 876 FlowGraph* callee_graph = call_data->callee_graph; |
| 862 TargetEntryInstr* callee_entry = | 877 TargetEntryInstr* callee_entry = |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 OS::Print("After Inlining of %s\n", flow_graph_-> | 1690 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1676 parsed_function().function().ToFullyQualifiedCString()); | 1691 parsed_function().function().ToFullyQualifiedCString()); |
| 1677 FlowGraphPrinter printer(*flow_graph_); | 1692 FlowGraphPrinter printer(*flow_graph_); |
| 1678 printer.PrintBlocks(); | 1693 printer.PrintBlocks(); |
| 1679 } | 1694 } |
| 1680 } | 1695 } |
| 1681 } | 1696 } |
| 1682 } | 1697 } |
| 1683 | 1698 |
| 1684 } // namespace dart | 1699 } // namespace dart |
| OLD | NEW |