| 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 const intptr_t prev_deopt_id = isolate()->deopt_id(); | 675 const intptr_t prev_deopt_id = isolate()->deopt_id(); |
| 676 isolate()->set_deopt_id(0); | 676 isolate()->set_deopt_id(0); |
| 677 // Install bailout jump. | 677 // Install bailout jump. |
| 678 LongJumpScope jump; | 678 LongJumpScope jump; |
| 679 if (setjmp(*jump.Set()) == 0) { | 679 if (setjmp(*jump.Set()) == 0) { |
| 680 // Parse the callee function. | 680 // Parse the callee function. |
| 681 bool in_cache; | 681 bool in_cache; |
| 682 ParsedFunction* parsed_function; | 682 ParsedFunction* parsed_function; |
| 683 { | 683 { |
| 684 TimerScope timer(FLAG_compiler_stats, | 684 TimerScope timer(FLAG_compiler_stats, |
| 685 &CompilerStats::graphinliner_parse_timer, | 685 &CSTAT_TIMER(graphinliner_parse_timer), |
| 686 isolate()); | 686 isolate()); |
| 687 const Error& error = Error::Handle(Z, | 687 const Error& error = Error::Handle(Z, |
| 688 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); | 688 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); |
| 689 if (!error.IsNull()) { | 689 if (!error.IsNull()) { |
| 690 Exceptions::PropagateError(error); | 690 Exceptions::PropagateError(error); |
| 691 } | 691 } |
| 692 parsed_function = GetParsedFunction(function, &in_cache); | 692 parsed_function = GetParsedFunction(function, &in_cache); |
| 693 } | 693 } |
| 694 | 694 |
| 695 // Load IC data for the callee. | 695 // Load IC data for the callee. |
| 696 ZoneGrowableArray<const ICData*>* ic_data_array = | 696 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 697 new(Z) ZoneGrowableArray<const ICData*>(); | 697 new(Z) ZoneGrowableArray<const ICData*>(); |
| 698 function.RestoreICDataMap(ic_data_array); | 698 function.RestoreICDataMap(ic_data_array); |
| 699 | 699 |
| 700 // Build the callee graph. | 700 // Build the callee graph. |
| 701 InlineExitCollector* exit_collector = | 701 InlineExitCollector* exit_collector = |
| 702 new(Z) InlineExitCollector(caller_graph_, call); | 702 new(Z) InlineExitCollector(caller_graph_, call); |
| 703 FlowGraphBuilder builder(*parsed_function, | 703 FlowGraphBuilder builder(*parsed_function, |
| 704 *ic_data_array, | 704 *ic_data_array, |
| 705 exit_collector, | 705 exit_collector, |
| 706 Isolate::kNoDeoptId); | 706 Isolate::kNoDeoptId); |
| 707 builder.SetInitialBlockId(caller_graph_->max_block_id()); | 707 builder.SetInitialBlockId(caller_graph_->max_block_id()); |
| 708 FlowGraph* callee_graph; | 708 FlowGraph* callee_graph; |
| 709 { | 709 { |
| 710 TimerScope timer(FLAG_compiler_stats, | 710 TimerScope timer(FLAG_compiler_stats, |
| 711 &CompilerStats::graphinliner_build_timer, | 711 &CSTAT_TIMER(graphinliner_build_timer), |
| 712 isolate()); | 712 isolate()); |
| 713 callee_graph = builder.BuildGraph(); | 713 callee_graph = builder.BuildGraph(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 // The parameter stubs are a copy of the actual arguments providing | 716 // The parameter stubs are a copy of the actual arguments providing |
| 717 // concrete information about the values, for example constant values, | 717 // concrete information about the values, for example constant values, |
| 718 // without linking between the caller and callee graphs. | 718 // without linking between the caller and callee graphs. |
| 719 // TODO(zerny): Put more information in the stubs, eg, type information. | 719 // TODO(zerny): Put more information in the stubs, eg, type information. |
| 720 ZoneGrowableArray<Definition*>* param_stubs = | 720 ZoneGrowableArray<Definition*>* param_stubs = |
| 721 new(Z) ZoneGrowableArray<Definition*>( | 721 new(Z) ZoneGrowableArray<Definition*>( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 BlockEntryInstr* block = it.Current(); | 757 BlockEntryInstr* block = it.Current(); |
| 758 block->set_try_index(try_index); | 758 block->set_try_index(try_index); |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 | 761 |
| 762 BlockScheduler block_scheduler(callee_graph); | 762 BlockScheduler block_scheduler(callee_graph); |
| 763 block_scheduler.AssignEdgeWeights(); | 763 block_scheduler.AssignEdgeWeights(); |
| 764 | 764 |
| 765 { | 765 { |
| 766 TimerScope timer(FLAG_compiler_stats, | 766 TimerScope timer(FLAG_compiler_stats, |
| 767 &CompilerStats::graphinliner_ssa_timer, | 767 &CSTAT_TIMER(graphinliner_ssa_timer), |
| 768 isolate()); | 768 isolate()); |
| 769 // Compute SSA on the callee graph, catching bailouts. | 769 // Compute SSA on the callee graph, catching bailouts. |
| 770 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 770 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
| 771 param_stubs); | 771 param_stubs); |
| 772 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 772 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 773 } | 773 } |
| 774 | 774 |
| 775 { | 775 { |
| 776 TimerScope timer(FLAG_compiler_stats, | 776 TimerScope timer(FLAG_compiler_stats, |
| 777 &CompilerStats::graphinliner_opt_timer, | 777 &CSTAT_TIMER(graphinliner_opt_timer), |
| 778 isolate()); | 778 isolate()); |
| 779 // TODO(zerny): Do more optimization passes on the callee graph. | 779 // TODO(zerny): Do more optimization passes on the callee graph. |
| 780 FlowGraphOptimizer optimizer(callee_graph); | 780 FlowGraphOptimizer optimizer(callee_graph); |
| 781 optimizer.ApplyICData(); | 781 optimizer.ApplyICData(); |
| 782 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 782 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 783 | 783 |
| 784 // Optimize (a << b) & c patterns, merge instructions. Must occur before | 784 // Optimize (a << b) & c patterns, merge instructions. Must occur before |
| 785 // 'SelectRepresentations' which inserts conversion nodes. | 785 // 'SelectRepresentations' which inserts conversion nodes. |
| 786 optimizer.TryOptimizePatterns(); | 786 optimizer.TryOptimizePatterns(); |
| 787 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 787 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 info.call_instr->GetDeoptId(), | 947 info.call_instr->GetDeoptId(), |
| 948 info.inlined->ToQualifiedCString(), | 948 info.inlined->ToQualifiedCString(), |
| 949 info.bailout_reason); | 949 info.bailout_reason); |
| 950 call_instructions_printed.Add(info.call_instr->GetDeoptId()); | 950 call_instructions_printed.Add(info.call_instr->GetDeoptId()); |
| 951 } | 951 } |
| 952 } | 952 } |
| 953 } | 953 } |
| 954 | 954 |
| 955 void InlineCall(InlinedCallData* call_data) { | 955 void InlineCall(InlinedCallData* call_data) { |
| 956 TimerScope timer(FLAG_compiler_stats, | 956 TimerScope timer(FLAG_compiler_stats, |
| 957 &CompilerStats::graphinliner_subst_timer, | 957 &CSTAT_TIMER(graphinliner_subst_timer), |
| 958 Isolate::Current()); | 958 Isolate::Current()); |
| 959 FlowGraph* callee_graph = call_data->callee_graph; | 959 FlowGraph* callee_graph = call_data->callee_graph; |
| 960 TargetEntryInstr* callee_entry = | 960 TargetEntryInstr* callee_entry = |
| 961 callee_graph->graph_entry()->normal_entry(); | 961 callee_graph->graph_entry()->normal_entry(); |
| 962 // Plug result in the caller graph. | 962 // Plug result in the caller graph. |
| 963 InlineExitCollector* exit_collector = call_data->exit_collector; | 963 InlineExitCollector* exit_collector = call_data->exit_collector; |
| 964 exit_collector->PrepareGraphs(callee_graph); | 964 exit_collector->PrepareGraphs(callee_graph); |
| 965 exit_collector->ReplaceCall(callee_entry); | 965 exit_collector->ReplaceCall(callee_entry); |
| 966 | 966 |
| 967 // Replace each stub with the actual argument or the caller's constant. | 967 // Replace each stub with the actual argument or the caller's constant. |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1880 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
| 1881 intptr_t parent_id) { | 1881 intptr_t parent_id) { |
| 1882 const intptr_t id = inline_id_to_function_->length(); | 1882 const intptr_t id = inline_id_to_function_->length(); |
| 1883 inline_id_to_function_->Add(&function); | 1883 inline_id_to_function_->Add(&function); |
| 1884 caller_inline_id_->Add(parent_id); | 1884 caller_inline_id_->Add(parent_id); |
| 1885 return id; | 1885 return id; |
| 1886 } | 1886 } |
| 1887 | 1887 |
| 1888 | 1888 |
| 1889 } // namespace dart | 1889 } // namespace dart |
| OLD | NEW |