| 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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 FlowGraph* callee_graph = call_data->callee_graph; | 863 FlowGraph* callee_graph = call_data->callee_graph; |
| 864 TargetEntryInstr* callee_entry = | 864 TargetEntryInstr* callee_entry = |
| 865 callee_graph->graph_entry()->normal_entry(); | 865 callee_graph->graph_entry()->normal_entry(); |
| 866 ClosureCallInstr* closure_call = call_data->call->AsClosureCall(); | 866 ClosureCallInstr* closure_call = call_data->call->AsClosureCall(); |
| 867 if (closure_call != NULL) { | 867 if (closure_call != NULL) { |
| 868 // TODO(fschneider): Avoid setting the context, if not needed. | 868 // TODO(fschneider): Avoid setting the context, if not needed. |
| 869 Definition* closure = | 869 Definition* closure = |
| 870 closure_call->PushArgumentAt(0)->value()->definition(); | 870 closure_call->PushArgumentAt(0)->value()->definition(); |
| 871 Definition* context = new LoadFieldInstr(new Value(closure), | 871 Definition* context = new LoadFieldInstr(new Value(closure), |
| 872 Closure::context_offset(), | 872 Closure::context_offset(), |
| 873 Type::ZoneHandle()); | 873 Type::ZoneHandle(), |
| 874 closure_call->token_pos()); |
| 874 context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index()); | 875 context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index()); |
| 875 context->InsertAfter(callee_entry); | 876 context->InsertAfter(callee_entry); |
| 876 StoreContextInstr* set_context = | 877 StoreContextInstr* set_context = |
| 877 new StoreContextInstr(new Value(context)); | 878 new StoreContextInstr(new Value(context)); |
| 878 set_context->InsertAfter(context); | 879 set_context->InsertAfter(context); |
| 879 } | 880 } |
| 880 | 881 |
| 881 // Plug result in the caller graph. | 882 // Plug result in the caller graph. |
| 882 InlineExitCollector* exit_collector = call_data->exit_collector; | 883 InlineExitCollector* exit_collector = call_data->exit_collector; |
| 883 exit_collector->PrepareGraphs(callee_graph); | 884 exit_collector->PrepareGraphs(callee_graph); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 // instruction which can deoptimize, followed unconditionally by the | 1404 // instruction which can deoptimize, followed unconditionally by the |
| 1404 // body. Check a redefinition of the receiver, to prevent the check | 1405 // body. Check a redefinition of the receiver, to prevent the check |
| 1405 // from being hoisted. | 1406 // from being hoisted. |
| 1406 RedefinitionInstr* redefinition = | 1407 RedefinitionInstr* redefinition = |
| 1407 new RedefinitionInstr(new Value(receiver)); | 1408 new RedefinitionInstr(new Value(receiver)); |
| 1408 redefinition->set_ssa_temp_index( | 1409 redefinition->set_ssa_temp_index( |
| 1409 owner_->caller_graph()->alloc_ssa_temp_index()); | 1410 owner_->caller_graph()->alloc_ssa_temp_index()); |
| 1410 cursor = AppendInstruction(cursor, redefinition); | 1411 cursor = AppendInstruction(cursor, redefinition); |
| 1411 if (inlined_variants_[i].cid == kSmiCid) { | 1412 if (inlined_variants_[i].cid == kSmiCid) { |
| 1412 CheckSmiInstr* check_smi = | 1413 CheckSmiInstr* check_smi = |
| 1413 new CheckSmiInstr(new Value(redefinition), call_->deopt_id()); | 1414 new CheckSmiInstr(new Value(redefinition), |
| 1415 call_->deopt_id(), |
| 1416 call_->token_pos()); |
| 1414 check_smi->InheritDeoptTarget(call_); | 1417 check_smi->InheritDeoptTarget(call_); |
| 1415 cursor = AppendInstruction(cursor, check_smi); | 1418 cursor = AppendInstruction(cursor, check_smi); |
| 1416 } else { | 1419 } else { |
| 1417 const ICData& old_checks = call_->ic_data(); | 1420 const ICData& old_checks = call_->ic_data(); |
| 1418 const ICData& new_checks = ICData::ZoneHandle( | 1421 const ICData& new_checks = ICData::ZoneHandle( |
| 1419 ICData::New(Function::Handle(old_checks.owner()), | 1422 ICData::New(Function::Handle(old_checks.owner()), |
| 1420 String::Handle(old_checks.target_name()), | 1423 String::Handle(old_checks.target_name()), |
| 1421 Array::Handle(old_checks.arguments_descriptor()), | 1424 Array::Handle(old_checks.arguments_descriptor()), |
| 1422 old_checks.deopt_id(), | 1425 old_checks.deopt_id(), |
| 1423 1)); // Number of args tested. | 1426 1)); // Number of args tested. |
| 1424 new_checks.AddReceiverCheck(inlined_variants_[i].cid, | 1427 new_checks.AddReceiverCheck(inlined_variants_[i].cid, |
| 1425 *inlined_variants_[i].target); | 1428 *inlined_variants_[i].target); |
| 1426 CheckClassInstr* check_class = | 1429 CheckClassInstr* check_class = |
| 1427 new CheckClassInstr(new Value(redefinition), | 1430 new CheckClassInstr(new Value(redefinition), |
| 1428 call_->deopt_id(), | 1431 call_->deopt_id(), |
| 1429 new_checks); | 1432 new_checks, |
| 1433 call_->token_pos()); |
| 1430 check_class->InheritDeoptTarget(call_); | 1434 check_class->InheritDeoptTarget(call_); |
| 1431 cursor = AppendInstruction(cursor, check_class); | 1435 cursor = AppendInstruction(cursor, check_class); |
| 1432 } | 1436 } |
| 1433 // The next instruction is the first instruction of the inlined body. | 1437 // The next instruction is the first instruction of the inlined body. |
| 1434 // Handle the two possible cases (unshared and shared subsequent | 1438 // Handle the two possible cases (unshared and shared subsequent |
| 1435 // predecessors) separately. | 1439 // predecessors) separately. |
| 1436 BlockEntryInstr* callee_entry = inlined_entries_[i]; | 1440 BlockEntryInstr* callee_entry = inlined_entries_[i]; |
| 1437 if (callee_entry->IsGraphEntry()) { | 1441 if (callee_entry->IsGraphEntry()) { |
| 1438 // Unshared. Graft the normal entry on after the check class | 1442 // Unshared. Graft the normal entry on after the check class |
| 1439 // instruction. | 1443 // instruction. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 OS::Print("After Inlining of %s\n", flow_graph_-> | 1693 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1690 parsed_function().function().ToFullyQualifiedCString()); | 1694 parsed_function().function().ToFullyQualifiedCString()); |
| 1691 FlowGraphPrinter printer(*flow_graph_); | 1695 FlowGraphPrinter printer(*flow_graph_); |
| 1692 printer.PrintBlocks(); | 1696 printer.PrintBlocks(); |
| 1693 } | 1697 } |
| 1694 } | 1698 } |
| 1695 } | 1699 } |
| 1696 } | 1700 } |
| 1697 | 1701 |
| 1698 } // namespace dart | 1702 } // namespace dart |
| OLD | NEW |