Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: runtime/vm/flow_graph.cc

Issue 10916228: Inline monomorphic calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph.cc
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index 583858919d4a855f43c83d7728ece5a2181f291f..fd46209bbae832ee418ab85bb325ada7aaa10e47 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -756,13 +756,13 @@ static void Link(Instruction* prev, Instruction* next) {
// Inline a flow graph at a call site.
//
-// Assumes the callee graph was computed with BuildGraphForInlining and
-// transformed to SSA with ComputeSSAForInlining, and that the use lists have
-// been correctly computed.
+// Assumes the callee graph was computed by BuildGraph with an inlining context
+// and transformed to SSA with ComputeSSA with a correct virtual register
+// number, and that the use lists have been correctly computed.
//
// After inlining the caller graph will correctly have adjusted the pre/post
// orders, the dominator tree and the use lists.
-void FlowGraph::InlineCall(StaticCallInstr* call, FlowGraph* callee_graph) {
+void FlowGraph::InlineCall(Definition* call, FlowGraph* callee_graph) {
ASSERT(callee_graph->exits() != NULL);
ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
ASSERT(callee_graph->max_virtual_register_number() >
@@ -774,11 +774,16 @@ void FlowGraph::InlineCall(StaticCallInstr* call, FlowGraph* callee_graph) {
// Adjust the SSA temp index by the callee graph's index.
current_ssa_temp_index_ = callee_graph->max_virtual_register_number();
+ BlockEntryInstr* caller_entry = GetBlockEntry(call);
TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry();
ZoneGrowableArray<ReturnInstr*>* callee_exits = callee_graph->exits();
// 1. Insert the callee graph into the caller graph.
- if (callee_exits->length() == 1) {
+ if (callee_exits->length() == 0) {
srdjan 2012/09/11 14:44:07 is_empty()
Kevin Millikin (Google) 2012/09/11 16:29:20 Thank you.
+ // If no normal exits exist, inline and truncate the block after inlining.
+ Link(call->previous(), callee_entry->next());
+ caller_entry->set_last_instruction(callee_entry->last_instruction());
+ } else if (callee_exits->length() == 1) {
ReturnInstr* exit = (*callee_exits)[0];
// TODO(zerny): Support one exit graph containing control flow.
ASSERT(callee_entry == GetBlockEntry(exit));
@@ -793,13 +798,6 @@ void FlowGraph::InlineCall(StaticCallInstr* call, FlowGraph* callee_graph) {
// TODO(zerny): Adjust pre/post orders.
// TODO(zerny): Update dominator tree.
-
- // Remove original arguments to the call.
- for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
- PushArgumentInstr* push = call->ArgumentAt(i);
- push->ReplaceUsesWith(push->value()->definition());
- push->RemoveFromGraph();
- }
}

Powered by Google App Engine
This is Rietveld 408576698