| 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 first->LinkTo(second); | 1157 first->LinkTo(second); |
| 1158 return second; | 1158 return second; |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 | 1161 |
| 1162 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, | 1162 bool PolymorphicInliner::TryInlineRecognizedMethod(intptr_t receiver_cid, |
| 1163 const Function& target) { | 1163 const Function& target) { |
| 1164 FlowGraphOptimizer optimizer(owner_->caller_graph()); | 1164 FlowGraphOptimizer optimizer(owner_->caller_graph()); |
| 1165 TargetEntryInstr* entry; | 1165 TargetEntryInstr* entry; |
| 1166 Definition* last; | 1166 Definition* last; |
| 1167 // Replace the receiver argument with a redefinition to prevent code from |
| 1168 // the inlined body from being hoisted above the inlined entry. |
| 1169 GrowableArray<Definition*> arguments(call_->ArgumentCount()); |
| 1170 Definition* receiver = call_->ArgumentAt(0); |
| 1171 RedefinitionInstr* redefinition = |
| 1172 new RedefinitionInstr(new Value(receiver)); |
| 1173 redefinition->set_ssa_temp_index( |
| 1174 owner_->caller_graph()->alloc_ssa_temp_index()); |
| 1167 if (optimizer.TryInlineRecognizedMethod(receiver_cid, | 1175 if (optimizer.TryInlineRecognizedMethod(receiver_cid, |
| 1168 target, | 1176 target, |
| 1169 call_, | 1177 call_, |
| 1178 redefinition, |
| 1170 call_->instance_call()->token_pos(), | 1179 call_->instance_call()->token_pos(), |
| 1171 *call_->instance_call()->ic_data(), | 1180 *call_->instance_call()->ic_data(), |
| 1172 &entry, &last)) { | 1181 &entry, &last)) { |
| 1173 // Create a graph fragment. | 1182 // Create a graph fragment. |
| 1183 redefinition->InsertAfter(entry); |
| 1174 InlineExitCollector* exit_collector = | 1184 InlineExitCollector* exit_collector = |
| 1175 new InlineExitCollector(owner_->caller_graph(), call_); | 1185 new InlineExitCollector(owner_->caller_graph(), call_); |
| 1176 | 1186 |
| 1177 ReturnInstr* result = | 1187 ReturnInstr* result = |
| 1178 new ReturnInstr(call_->instance_call()->token_pos(), | 1188 new ReturnInstr(call_->instance_call()->token_pos(), |
| 1179 new Value(last)); | 1189 new Value(last)); |
| 1180 owner_->caller_graph()->AppendTo( | 1190 owner_->caller_graph()->AppendTo( |
| 1181 last, | 1191 last, |
| 1182 result, | 1192 result, |
| 1183 call_->env(), // Return can become deoptimization target. | 1193 call_->env(), // Return can become deoptimization target. |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 OS::Print("After Inlining of %s\n", flow_graph_-> | 1506 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1497 parsed_function().function().ToFullyQualifiedCString()); | 1507 parsed_function().function().ToFullyQualifiedCString()); |
| 1498 FlowGraphPrinter printer(*flow_graph_); | 1508 FlowGraphPrinter printer(*flow_graph_); |
| 1499 printer.PrintBlocks(); | 1509 printer.PrintBlocks(); |
| 1500 } | 1510 } |
| 1501 } | 1511 } |
| 1502 } | 1512 } |
| 1503 } | 1513 } |
| 1504 | 1514 |
| 1505 } // namespace dart | 1515 } // namespace dart |
| OLD | NEW |