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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // Save and clear deopt id. | 680 // Save and clear deopt id. |
681 const intptr_t prev_deopt_id = isolate()->deopt_id(); | 681 const intptr_t prev_deopt_id = isolate()->deopt_id(); |
682 isolate()->set_deopt_id(0); | 682 isolate()->set_deopt_id(0); |
683 // Install bailout jump. | 683 // Install bailout jump. |
684 LongJumpScope jump; | 684 LongJumpScope jump; |
685 if (setjmp(*jump.Set()) == 0) { | 685 if (setjmp(*jump.Set()) == 0) { |
686 // Parse the callee function. | 686 // Parse the callee function. |
687 bool in_cache; | 687 bool in_cache; |
688 ParsedFunction* parsed_function; | 688 ParsedFunction* parsed_function; |
689 { | 689 { |
690 CSTAT_TIMER_SCOPE(isolate(), graphinliner_parse_timer); | 690 CSTAT_TIMER_SCOPE(thread(), graphinliner_parse_timer); |
691 if (!Compiler::always_optimize()) { | 691 if (!Compiler::always_optimize()) { |
692 const Error& error = Error::Handle(Z, | 692 const Error& error = Error::Handle(Z, |
693 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); | 693 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); |
694 if (!error.IsNull()) { | 694 if (!error.IsNull()) { |
695 Exceptions::PropagateError(error); | 695 Exceptions::PropagateError(error); |
696 } | 696 } |
697 } | 697 } |
698 parsed_function = GetParsedFunction(function, &in_cache); | 698 parsed_function = GetParsedFunction(function, &in_cache); |
699 } | 699 } |
700 | 700 |
701 // Load IC data for the callee. | 701 // Load IC data for the callee. |
702 ZoneGrowableArray<const ICData*>* ic_data_array = | 702 ZoneGrowableArray<const ICData*>* ic_data_array = |
703 new(Z) ZoneGrowableArray<const ICData*>(); | 703 new(Z) ZoneGrowableArray<const ICData*>(); |
704 function.RestoreICDataMap(ic_data_array); | 704 function.RestoreICDataMap(ic_data_array); |
705 | 705 |
706 // Build the callee graph. | 706 // Build the callee graph. |
707 InlineExitCollector* exit_collector = | 707 InlineExitCollector* exit_collector = |
708 new(Z) InlineExitCollector(caller_graph_, call); | 708 new(Z) InlineExitCollector(caller_graph_, call); |
709 FlowGraphBuilder builder(*parsed_function, | 709 FlowGraphBuilder builder(*parsed_function, |
710 *ic_data_array, | 710 *ic_data_array, |
711 exit_collector, | 711 exit_collector, |
712 Isolate::kNoDeoptId); | 712 Isolate::kNoDeoptId); |
713 builder.SetInitialBlockId(caller_graph_->max_block_id()); | 713 builder.SetInitialBlockId(caller_graph_->max_block_id()); |
714 FlowGraph* callee_graph; | 714 FlowGraph* callee_graph; |
715 { | 715 { |
716 CSTAT_TIMER_SCOPE(isolate(), graphinliner_build_timer); | 716 CSTAT_TIMER_SCOPE(thread(), graphinliner_build_timer); |
717 callee_graph = builder.BuildGraph(); | 717 callee_graph = builder.BuildGraph(); |
718 } | 718 } |
719 | 719 |
720 // The parameter stubs are a copy of the actual arguments providing | 720 // The parameter stubs are a copy of the actual arguments providing |
721 // concrete information about the values, for example constant values, | 721 // concrete information about the values, for example constant values, |
722 // without linking between the caller and callee graphs. | 722 // without linking between the caller and callee graphs. |
723 // TODO(zerny): Put more information in the stubs, eg, type information. | 723 // TODO(zerny): Put more information in the stubs, eg, type information. |
724 ZoneGrowableArray<Definition*>* param_stubs = | 724 ZoneGrowableArray<Definition*>* param_stubs = |
725 new(Z) ZoneGrowableArray<Definition*>( | 725 new(Z) ZoneGrowableArray<Definition*>( |
726 function.NumParameters()); | 726 function.NumParameters()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 !it.Done(); it.Advance()) { | 760 !it.Done(); it.Advance()) { |
761 BlockEntryInstr* block = it.Current(); | 761 BlockEntryInstr* block = it.Current(); |
762 block->set_try_index(try_index); | 762 block->set_try_index(try_index); |
763 } | 763 } |
764 } | 764 } |
765 | 765 |
766 BlockScheduler block_scheduler(callee_graph); | 766 BlockScheduler block_scheduler(callee_graph); |
767 block_scheduler.AssignEdgeWeights(); | 767 block_scheduler.AssignEdgeWeights(); |
768 | 768 |
769 { | 769 { |
770 CSTAT_TIMER_SCOPE(isolate(), graphinliner_ssa_timer); | 770 CSTAT_TIMER_SCOPE(thread(), graphinliner_ssa_timer); |
771 // Compute SSA on the callee graph, catching bailouts. | 771 // Compute SSA on the callee graph, catching bailouts. |
772 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 772 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
773 param_stubs); | 773 param_stubs); |
774 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 774 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
775 } | 775 } |
776 | 776 |
777 { | 777 { |
778 CSTAT_TIMER_SCOPE(isolate(), graphinliner_opt_timer); | 778 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); |
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 if (Compiler::always_optimize()) { | 781 if (Compiler::always_optimize()) { |
782 optimizer.PopulateWithICData(); | 782 optimizer.PopulateWithICData(); |
783 } | 783 } |
784 optimizer.ApplyICData(); | 784 optimizer.ApplyICData(); |
785 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 785 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
786 | 786 |
787 // Optimize (a << b) & c patterns, merge instructions. Must occur before | 787 // Optimize (a << b) & c patterns, merge instructions. Must occur before |
788 // 'SelectRepresentations' which inserts conversion nodes. | 788 // 'SelectRepresentations' which inserts conversion nodes. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 ISL_Print("NO %" Pd " %s - %s\n", | 949 ISL_Print("NO %" Pd " %s - %s\n", |
950 info.call_instr->GetDeoptId(), | 950 info.call_instr->GetDeoptId(), |
951 info.inlined->ToQualifiedCString(), | 951 info.inlined->ToQualifiedCString(), |
952 info.bailout_reason); | 952 info.bailout_reason); |
953 call_instructions_printed.Add(info.call_instr->GetDeoptId()); | 953 call_instructions_printed.Add(info.call_instr->GetDeoptId()); |
954 } | 954 } |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 void InlineCall(InlinedCallData* call_data) { | 958 void InlineCall(InlinedCallData* call_data) { |
959 CSTAT_TIMER_SCOPE(Isolate::Current(), graphinliner_subst_timer); | 959 CSTAT_TIMER_SCOPE(Thread::Current(), graphinliner_subst_timer); |
960 FlowGraph* callee_graph = call_data->callee_graph; | 960 FlowGraph* callee_graph = call_data->callee_graph; |
961 TargetEntryInstr* callee_entry = | 961 TargetEntryInstr* callee_entry = |
962 callee_graph->graph_entry()->normal_entry(); | 962 callee_graph->graph_entry()->normal_entry(); |
963 // Plug result in the caller graph. | 963 // Plug result in the caller graph. |
964 InlineExitCollector* exit_collector = call_data->exit_collector; | 964 InlineExitCollector* exit_collector = call_data->exit_collector; |
965 exit_collector->PrepareGraphs(callee_graph); | 965 exit_collector->PrepareGraphs(callee_graph); |
966 exit_collector->ReplaceCall(callee_entry); | 966 exit_collector->ReplaceCall(callee_entry); |
967 | 967 |
968 // Replace each stub with the actual argument or the caller's constant. | 968 // Replace each stub with the actual argument or the caller's constant. |
969 // Nulls denote optional parameters for which no actual was given. | 969 // Nulls denote optional parameters for which no actual was given. |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1894 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
1895 intptr_t parent_id) { | 1895 intptr_t parent_id) { |
1896 const intptr_t id = inline_id_to_function_->length(); | 1896 const intptr_t id = inline_id_to_function_->length(); |
1897 inline_id_to_function_->Add(&function); | 1897 inline_id_to_function_->Add(&function); |
1898 caller_inline_id_->Add(parent_id); | 1898 caller_inline_id_->Add(parent_id); |
1899 return id; | 1899 return id; |
1900 } | 1900 } |
1901 | 1901 |
1902 | 1902 |
1903 } // namespace dart | 1903 } // namespace dart |
OLD | NEW |