| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 info.inlined->ToQualifiedCString(), | 851 info.inlined->ToQualifiedCString(), |
| 852 info.bailout_reason); | 852 info.bailout_reason); |
| 853 } | 853 } |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 | 856 |
| 857 void InlineCall(InlinedCallData* call_data) { | 857 void InlineCall(InlinedCallData* call_data) { |
| 858 TimerScope timer(FLAG_compiler_stats, | 858 TimerScope timer(FLAG_compiler_stats, |
| 859 &CompilerStats::graphinliner_subst_timer, | 859 &CompilerStats::graphinliner_subst_timer, |
| 860 Isolate::Current()); | 860 Isolate::Current()); |
| 861 | |
| 862 // For closure calls: Store context value. | |
| 863 FlowGraph* callee_graph = call_data->callee_graph; | 861 FlowGraph* callee_graph = call_data->callee_graph; |
| 864 TargetEntryInstr* callee_entry = | 862 TargetEntryInstr* callee_entry = |
| 865 callee_graph->graph_entry()->normal_entry(); | 863 callee_graph->graph_entry()->normal_entry(); |
| 866 ClosureCallInstr* closure_call = call_data->call->AsClosureCall(); | |
| 867 if (closure_call != NULL) { | |
| 868 // TODO(fschneider): Avoid setting the context, if not needed. | |
| 869 Definition* closure = | |
| 870 closure_call->PushArgumentAt(0)->value()->definition(); | |
| 871 Definition* context = new LoadFieldInstr(new Value(closure), | |
| 872 Closure::context_offset(), | |
| 873 Type::ZoneHandle()); | |
| 874 context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index()); | |
| 875 context->InsertAfter(callee_entry); | |
| 876 StoreContextInstr* set_context = | |
| 877 new StoreContextInstr(new Value(context)); | |
| 878 set_context->InsertAfter(context); | |
| 879 } | |
| 880 | |
| 881 // Plug result in the caller graph. | 864 // Plug result in the caller graph. |
| 882 InlineExitCollector* exit_collector = call_data->exit_collector; | 865 InlineExitCollector* exit_collector = call_data->exit_collector; |
| 883 exit_collector->PrepareGraphs(callee_graph); | 866 exit_collector->PrepareGraphs(callee_graph); |
| 884 exit_collector->ReplaceCall(callee_entry); | 867 exit_collector->ReplaceCall(callee_entry); |
| 885 | 868 |
| 886 // Replace each stub with the actual argument or the caller's constant. | 869 // Replace each stub with the actual argument or the caller's constant. |
| 887 // Nulls denote optional parameters for which no actual was given. | 870 // Nulls denote optional parameters for which no actual was given. |
| 888 GrowableArray<Value*>* arguments = call_data->arguments; | 871 GrowableArray<Value*>* arguments = call_data->arguments; |
| 889 for (intptr_t i = 0; i < arguments->length(); ++i) { | 872 for (intptr_t i = 0; i < arguments->length(); ++i) { |
| 890 Definition* stub = (*call_data->parameter_stubs)[i]; | 873 Definition* stub = (*call_data->parameter_stubs)[i]; |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 OS::Print("After Inlining of %s\n", flow_graph_-> | 1672 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1690 parsed_function().function().ToFullyQualifiedCString()); | 1673 parsed_function().function().ToFullyQualifiedCString()); |
| 1691 FlowGraphPrinter printer(*flow_graph_); | 1674 FlowGraphPrinter printer(*flow_graph_); |
| 1692 printer.PrintBlocks(); | 1675 printer.PrintBlocks(); |
| 1693 } | 1676 } |
| 1694 } | 1677 } |
| 1695 } | 1678 } |
| 1696 } | 1679 } |
| 1697 | 1680 |
| 1698 } // namespace dart | 1681 } // namespace dart |
| OLD | NEW |