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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 parsed_function->AllocateVariables(); | 786 parsed_function->AllocateVariables(); |
787 return parsed_function; | 787 return parsed_function; |
788 } | 788 } |
789 | 789 |
790 // Include special handling for List. factory: inlining it is not helpful | 790 // Include special handling for List. factory: inlining it is not helpful |
791 // if the incoming argument is a non-constant value. | 791 // if the incoming argument is a non-constant value. |
792 // TODO(srdjan): Fix inlining of List. factory. | 792 // TODO(srdjan): Fix inlining of List. factory. |
793 void InlineStaticCalls() { | 793 void InlineStaticCalls() { |
794 const GrowableArray<CallSites::StaticCallInfo>& call_info = | 794 const GrowableArray<CallSites::StaticCallInfo>& call_info = |
795 inlining_call_sites_->static_calls(); | 795 inlining_call_sites_->static_calls(); |
796 TRACE_INLINING(OS::Print(" Static Calls (%d)\n", call_info.length())); | 796 TRACE_INLINING(OS::Print(" Static Calls (%" Pd ")\n", call_info.length())); |
797 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { | 797 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { |
798 StaticCallInstr* call = call_info[call_idx].call; | 798 StaticCallInstr* call = call_info[call_idx].call; |
799 if (call->function().name() == Symbols::ListFactory().raw()) { | 799 if (call->function().name() == Symbols::ListFactory().raw()) { |
800 // Inline only if no arguments or a constant was passed. | 800 // Inline only if no arguments or a constant was passed. |
801 ASSERT(call->function().NumImplicitParameters() == 1); | 801 ASSERT(call->function().NumImplicitParameters() == 1); |
802 ASSERT(call->ArgumentCount() <= 2); | 802 ASSERT(call->ArgumentCount() <= 2); |
803 // Arg 0: Instantiator type arguments. | 803 // Arg 0: Instantiator type arguments. |
804 // Arg 1: Length (optional). | 804 // Arg 1: Length (optional). |
805 if ((call->ArgumentCount() == 2) && | 805 if ((call->ArgumentCount() == 2) && |
806 (!call->PushArgumentAt(1)->value()->BindsToConstant())) { | 806 (!call->PushArgumentAt(1)->value()->BindsToConstant())) { |
(...skipping 18 matching lines...) Expand all Loading... |
825 InlinedCallData call_data(call, &arguments); | 825 InlinedCallData call_data(call, &arguments); |
826 if (TryInlining(call->function(), call->argument_names(), &call_data)) { | 826 if (TryInlining(call->function(), call->argument_names(), &call_data)) { |
827 InlineCall(&call_data); | 827 InlineCall(&call_data); |
828 } | 828 } |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 void InlineClosureCalls() { | 832 void InlineClosureCalls() { |
833 const GrowableArray<ClosureCallInstr*>& calls = | 833 const GrowableArray<ClosureCallInstr*>& calls = |
834 inlining_call_sites_->closure_calls(); | 834 inlining_call_sites_->closure_calls(); |
835 TRACE_INLINING(OS::Print(" Closure Calls (%d)\n", calls.length())); | 835 TRACE_INLINING(OS::Print(" Closure Calls (%" Pd ")\n", calls.length())); |
836 for (intptr_t i = 0; i < calls.length(); ++i) { | 836 for (intptr_t i = 0; i < calls.length(); ++i) { |
837 ClosureCallInstr* call = calls[i]; | 837 ClosureCallInstr* call = calls[i]; |
838 // Find the closure of the callee. | 838 // Find the closure of the callee. |
839 ASSERT(call->ArgumentCount() > 0); | 839 ASSERT(call->ArgumentCount() > 0); |
840 Function& target = Function::ZoneHandle(); | 840 Function& target = Function::ZoneHandle(); |
841 CreateClosureInstr* closure = | 841 CreateClosureInstr* closure = |
842 call->ArgumentAt(0)->AsCreateClosure(); | 842 call->ArgumentAt(0)->AsCreateClosure(); |
843 if (closure != NULL) { | 843 if (closure != NULL) { |
844 target ^= closure->function().raw(); | 844 target ^= closure->function().raw(); |
845 } | 845 } |
(...skipping 16 matching lines...) Expand all Loading... |
862 call->argument_names(), | 862 call->argument_names(), |
863 &call_data)) { | 863 &call_data)) { |
864 InlineCall(&call_data); | 864 InlineCall(&call_data); |
865 } | 865 } |
866 } | 866 } |
867 } | 867 } |
868 | 868 |
869 void InlineInstanceCalls() { | 869 void InlineInstanceCalls() { |
870 const GrowableArray<CallSites::InstanceCallInfo>& call_info = | 870 const GrowableArray<CallSites::InstanceCallInfo>& call_info = |
871 inlining_call_sites_->instance_calls(); | 871 inlining_call_sites_->instance_calls(); |
872 TRACE_INLINING(OS::Print(" Polymorphic Instance Calls (%d)\n", | 872 TRACE_INLINING(OS::Print(" Polymorphic Instance Calls (%" Pd ")\n", |
873 call_info.length())); | 873 call_info.length())); |
874 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { | 874 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { |
875 PolymorphicInstanceCallInstr* call = call_info[call_idx].call; | 875 PolymorphicInstanceCallInstr* call = call_info[call_idx].call; |
876 if (call->with_checks()) { | 876 if (call->with_checks()) { |
877 PolymorphicInliner inliner(this, call); | 877 PolymorphicInliner inliner(this, call); |
878 inliner.Inline(); | 878 inliner.Inline(); |
879 continue; | 879 continue; |
880 } | 880 } |
881 | 881 |
882 const ICData& ic_data = call->ic_data(); | 882 const ICData& ic_data = call->ic_data(); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 OS::Print("After Inlining of %s\n", flow_graph_-> | 1491 OS::Print("After Inlining of %s\n", flow_graph_-> |
1492 parsed_function().function().ToFullyQualifiedCString()); | 1492 parsed_function().function().ToFullyQualifiedCString()); |
1493 FlowGraphPrinter printer(*flow_graph_); | 1493 FlowGraphPrinter printer(*flow_graph_); |
1494 printer.PrintBlocks(); | 1494 printer.PrintBlocks(); |
1495 } | 1495 } |
1496 } | 1496 } |
1497 } | 1497 } |
1498 } | 1498 } |
1499 | 1499 |
1500 } // namespace dart | 1500 } // namespace dart |
OLD | NEW |