| 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/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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 return false; | 661 return false; |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 | 664 |
| 665 private: | 665 private: |
| 666 void InlineCall(InlinedCallData* call_data) { | 666 void InlineCall(InlinedCallData* call_data) { |
| 667 TimerScope timer(FLAG_compiler_stats, | 667 TimerScope timer(FLAG_compiler_stats, |
| 668 &CompilerStats::graphinliner_subst_timer, | 668 &CompilerStats::graphinliner_subst_timer, |
| 669 Isolate::Current()); | 669 Isolate::Current()); |
| 670 | 670 |
| 671 // For closure calls: Store context value. |
| 672 FlowGraph* callee_graph = call_data->callee_graph; |
| 673 TargetEntryInstr* callee_entry = |
| 674 callee_graph->graph_entry()->normal_entry(); |
| 675 ClosureCallInstr* closure_call = call_data->call->AsClosureCall(); |
| 676 if (closure_call != NULL) { |
| 677 // TODO(fschneider): Avoid setting the context, if not needed. |
| 678 Definition* closure = |
| 679 closure_call->PushArgumentAt(0)->value()->definition(); |
| 680 LoadFieldInstr* context = |
| 681 new LoadFieldInstr(new Value(closure), |
| 682 Closure::context_offset(), |
| 683 Type::ZoneHandle()); |
| 684 context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index()); |
| 685 context->InsertAfter(callee_entry); |
| 686 StoreContextInstr* set_context = |
| 687 new StoreContextInstr(new Value(context)); |
| 688 set_context->InsertAfter(context); |
| 689 } |
| 690 |
| 671 // Plug result in the caller graph. | 691 // Plug result in the caller graph. |
| 672 FlowGraph* callee_graph = call_data->callee_graph; | |
| 673 InlineExitCollector* exit_collector = call_data->exit_collector; | 692 InlineExitCollector* exit_collector = call_data->exit_collector; |
| 674 exit_collector->PrepareGraphs(callee_graph); | 693 exit_collector->PrepareGraphs(callee_graph); |
| 675 exit_collector->ReplaceCall(callee_graph->graph_entry()->normal_entry()); | 694 exit_collector->ReplaceCall(callee_entry); |
| 676 | 695 |
| 677 // Replace each stub with the actual argument or the caller's constant. | 696 // Replace each stub with the actual argument or the caller's constant. |
| 678 // Nulls denote optional parameters for which no actual was given. | 697 // Nulls denote optional parameters for which no actual was given. |
| 679 GrowableArray<Value*>* arguments = call_data->arguments; | 698 GrowableArray<Value*>* arguments = call_data->arguments; |
| 680 for (intptr_t i = 0; i < arguments->length(); ++i) { | 699 for (intptr_t i = 0; i < arguments->length(); ++i) { |
| 681 Definition* stub = (*call_data->parameter_stubs)[i]; | 700 Definition* stub = (*call_data->parameter_stubs)[i]; |
| 682 Value* actual = (*arguments)[i]; | 701 Value* actual = (*arguments)[i]; |
| 683 if (actual != NULL) stub->ReplaceUsesWith(actual->definition()); | 702 if (actual != NULL) stub->ReplaceUsesWith(actual->definition()); |
| 684 } | 703 } |
| 685 | 704 |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 OS::Print("After Inlining of %s\n", flow_graph_-> | 1401 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1383 parsed_function().function().ToFullyQualifiedCString()); | 1402 parsed_function().function().ToFullyQualifiedCString()); |
| 1384 FlowGraphPrinter printer(*flow_graph_); | 1403 FlowGraphPrinter printer(*flow_graph_); |
| 1385 printer.PrintBlocks(); | 1404 printer.PrintBlocks(); |
| 1386 } | 1405 } |
| 1387 } | 1406 } |
| 1388 } | 1407 } |
| 1389 } | 1408 } |
| 1390 | 1409 |
| 1391 } // namespace dart | 1410 } // namespace dart |
| OLD | NEW |