| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 DEBUG_ASSERT(caller_graph_->ValidateUseLists()); | 123 DEBUG_ASSERT(caller_graph_->ValidateUseLists()); |
| 124 | 124 |
| 125 // Remove push arguments of the call. | 125 // Remove push arguments of the call. |
| 126 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { | 126 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { |
| 127 PushArgumentInstr* push = call->ArgumentAt(i); | 127 PushArgumentInstr* push = call->ArgumentAt(i); |
| 128 push->ReplaceUsesWith(push->value()->definition()); | 128 push->ReplaceUsesWith(push->value()->definition()); |
| 129 push->RemoveFromGraph(); | 129 push->RemoveFromGraph(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Replace formal parameters with actuals. | 132 // Replace formal parameters with actuals. |
| 133 for (intptr_t i = 0; i < arguments->length(); ++i) { | 133 intptr_t arg_index = 0; |
| 134 Value* val = callee_graph->graph_entry()->start_env()->ValueAt(i); | 134 GrowableArray<Definition*>* defns = |
| 135 ParameterInstr* param = val->definition()->AsParameter(); | 135 callee_graph->graph_entry()->initial_definitions(); |
| 136 ASSERT(param != NULL); | 136 for (intptr_t i = 0; i < defns->length(); ++i) { |
| 137 param->ReplaceUsesWith((*arguments)[i]->definition()); | 137 ParameterInstr* param = (*defns)[i]->AsParameter(); |
| 138 if (param != NULL) { |
| 139 param->ReplaceUsesWith((*arguments)[arg_index++]->definition()); |
| 140 } |
| 138 } | 141 } |
| 142 ASSERT(arg_index == arguments->length()); |
| 139 | 143 |
| 140 // Replace callee's null constant with caller's null constant. | 144 // Replace callee's null constant with caller's null constant. |
| 141 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith( | 145 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith( |
| 142 caller_graph_->graph_entry()->constant_null()); | 146 caller_graph_->graph_entry()->constant_null()); |
| 143 | 147 |
| 144 TRACE_INLINING(OS::Print(" Success\n")); | 148 TRACE_INLINING(OS::Print(" Success\n")); |
| 145 | 149 |
| 146 // Build succeeded so we restore the bailout jump. | 150 // Build succeeded so we restore the bailout jump. |
| 147 inlined_ = true; | 151 inlined_ = true; |
| 148 isolate->set_long_jump_base(base); | 152 isolate->set_long_jump_base(base); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (FLAG_trace_inlining && FLAG_print_flow_graph) { | 243 if (FLAG_trace_inlining && FLAG_print_flow_graph) { |
| 240 OS::Print("After Inlining of %s\n", flow_graph_-> | 244 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 241 parsed_function().function().ToFullyQualifiedCString()); | 245 parsed_function().function().ToFullyQualifiedCString()); |
| 242 FlowGraphPrinter printer(*flow_graph_); | 246 FlowGraphPrinter printer(*flow_graph_); |
| 243 printer.PrintBlocks(); | 247 printer.PrintBlocks(); |
| 244 } | 248 } |
| 245 } | 249 } |
| 246 } | 250 } |
| 247 | 251 |
| 248 } // namespace dart | 252 } // namespace dart |
| OLD | NEW |