| 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/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 803 } |
| 804 optimizer.ApplyICData(); | 804 optimizer.ApplyICData(); |
| 805 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 805 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 806 | 806 |
| 807 // Optimize (a << b) & c patterns, merge instructions. Must occur | 807 // Optimize (a << b) & c patterns, merge instructions. Must occur |
| 808 // before 'SelectRepresentations' which inserts conversion nodes. | 808 // before 'SelectRepresentations' which inserts conversion nodes. |
| 809 optimizer.TryOptimizePatterns(); | 809 optimizer.TryOptimizePatterns(); |
| 810 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 810 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 811 } | 811 } |
| 812 | 812 |
| 813 if (FLAG_trace_inlining && | 813 if (FLAG_support_il_printer && FLAG_trace_inlining && |
| 814 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { | 814 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 815 THR_Print("Callee graph for inlining %s\n", | 815 THR_Print("Callee graph for inlining %s\n", |
| 816 function.ToFullyQualifiedCString()); | 816 function.ToFullyQualifiedCString()); |
| 817 FlowGraphPrinter printer(*callee_graph); | 817 FlowGraphPrinter printer(*callee_graph); |
| 818 printer.PrintBlocks(); | 818 printer.PrintBlocks(); |
| 819 } | 819 } |
| 820 | 820 |
| 821 // Collect information about the call site and caller graph. | 821 // Collect information about the call site and caller graph. |
| 822 // TODO(zerny): Do this after CP and dead code elimination. | 822 // TODO(zerny): Do this after CP and dead code elimination. |
| 823 intptr_t constants_count = 0; | 823 intptr_t constants_count = 0; |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 CollectGraphInfo(flow_graph_); | 1901 CollectGraphInfo(flow_graph_); |
| 1902 | 1902 |
| 1903 const Function& top = flow_graph_->function(); | 1903 const Function& top = flow_graph_->function(); |
| 1904 if ((FLAG_inlining_filter != NULL) && | 1904 if ((FLAG_inlining_filter != NULL) && |
| 1905 (strstr(top.ToFullyQualifiedCString(), FLAG_inlining_filter) == NULL)) { | 1905 (strstr(top.ToFullyQualifiedCString(), FLAG_inlining_filter) == NULL)) { |
| 1906 return; | 1906 return; |
| 1907 } | 1907 } |
| 1908 | 1908 |
| 1909 TRACE_INLINING(THR_Print("Inlining calls in %s\n", top.ToCString())); | 1909 TRACE_INLINING(THR_Print("Inlining calls in %s\n", top.ToCString())); |
| 1910 | 1910 |
| 1911 if (trace_inlining() && | 1911 if (FLAG_support_il_printer && |
| 1912 trace_inlining() && |
| 1912 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { | 1913 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 1913 THR_Print("Before Inlining of %s\n", flow_graph_-> | 1914 THR_Print("Before Inlining of %s\n", flow_graph_-> |
| 1914 function().ToFullyQualifiedCString()); | 1915 function().ToFullyQualifiedCString()); |
| 1915 FlowGraphPrinter printer(*flow_graph_); | 1916 FlowGraphPrinter printer(*flow_graph_); |
| 1916 printer.PrintBlocks(); | 1917 printer.PrintBlocks(); |
| 1917 } | 1918 } |
| 1918 | 1919 |
| 1919 CallSiteInliner inliner(this); | 1920 CallSiteInliner inliner(this); |
| 1920 inliner.InlineCalls(); | 1921 inliner.InlineCalls(); |
| 1921 if (FLAG_print_inlining_tree) { | 1922 if (FLAG_print_inlining_tree) { |
| 1922 inliner.PrintInlinedInfo(top); | 1923 inliner.PrintInlinedInfo(top); |
| 1923 } | 1924 } |
| 1924 | 1925 |
| 1925 if (inliner.inlined()) { | 1926 if (inliner.inlined()) { |
| 1926 flow_graph_->DiscoverBlocks(); | 1927 flow_graph_->DiscoverBlocks(); |
| 1927 if (trace_inlining()) { | 1928 if (trace_inlining()) { |
| 1928 THR_Print("Inlining growth factor: %f\n", inliner.GrowthFactor()); | 1929 THR_Print("Inlining growth factor: %f\n", inliner.GrowthFactor()); |
| 1929 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 1930 if (FLAG_support_il_printer && |
| 1931 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 1930 THR_Print("After Inlining of %s\n", flow_graph_-> | 1932 THR_Print("After Inlining of %s\n", flow_graph_-> |
| 1931 function().ToFullyQualifiedCString()); | 1933 function().ToFullyQualifiedCString()); |
| 1932 FlowGraphPrinter printer(*flow_graph_); | 1934 FlowGraphPrinter printer(*flow_graph_); |
| 1933 printer.PrintBlocks(); | 1935 printer.PrintBlocks(); |
| 1934 } | 1936 } |
| 1935 } | 1937 } |
| 1936 } | 1938 } |
| 1937 } | 1939 } |
| 1938 | 1940 |
| 1939 | 1941 |
| 1940 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1942 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
| 1941 intptr_t parent_id) { | 1943 intptr_t parent_id) { |
| 1942 const intptr_t id = inline_id_to_function_->length(); | 1944 const intptr_t id = inline_id_to_function_->length(); |
| 1943 inline_id_to_function_->Add(&function); | 1945 inline_id_to_function_->Add(&function); |
| 1944 caller_inline_id_->Add(parent_id); | 1946 caller_inline_id_->Add(parent_id); |
| 1945 return id; | 1947 return id; |
| 1946 } | 1948 } |
| 1947 | 1949 |
| 1948 | 1950 |
| 1949 } // namespace dart | 1951 } // namespace dart |
| OLD | NEW |