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

Unified Diff: runtime/vm/flow_graph.cc

Issue 11262008: Remove push arguments and replace constants in FlowGraph::InlineCall. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Srdjan's DBCs from previous CL Created 8 years, 2 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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index 95961cb8dffc46024e77ba0c31b5faeadf032ced..5132665fb69d781556199834bc0cd4032bb3b631 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -784,22 +784,28 @@ void FlowGraph::ReplacePredecessor(BlockEntryInstr* old_block,
JoinEntryInstr* join = last->SuccessorAt(sidx)->AsJoinEntry();
ASSERT(join != NULL);
// Find the old predecessor index.
- intptr_t old_index = join->IndexOfPredecessor(old_block);
- intptr_t pred_count = join->PredecessorCount();
+ const intptr_t old_index = join->IndexOfPredecessor(old_block);
+ const intptr_t pred_count = join->PredecessorCount();
ASSERT(old_index >= 0);
ASSERT(old_index < pred_count);
// Find the new predecessor index while reordering the predecessors.
- intptr_t new_id = new_block->block_id();
+ const intptr_t new_id = new_block->block_id();
intptr_t new_index = old_index;
+ // The predecessors are sorted by block id in ascending order. This is done
+ // in JoinEntryInstr::AddPredecessor and in InlineCall.
if (old_block->block_id() < new_id) {
// Search upwards, bubbling down intermediate predecessors.
for (; new_index < pred_count - 1; ++new_index) {
+ ASSERT(join->predecessors_[new_index]->block_id() <
+ join->predecessors_[new_index + 1]->block_id());
Kevin Millikin (Google) 2012/11/02 11:35:23 The continuation line should be indented 4 spaces.
zerny-google 2012/11/02 12:37:31 Done.
if (join->predecessors_[new_index + 1]->block_id() > new_id) break;
join->predecessors_[new_index] = join->predecessors_[new_index + 1];
}
} else {
// Search downwards, bubbling up intermediate predecessors.
for (; new_index > 0; --new_index) {
+ ASSERT(join->predecessors_[new_index - 1]->block_id() <
Kevin Millikin (Google) 2012/11/02 11:35:23 Same.
zerny-google 2012/11/02 12:37:31 Done.
+ join->predecessors_[new_index]->block_id());
if (join->predecessors_[new_index - 1]->block_id() < new_id) break;
join->predecessors_[new_index] = join->predecessors_[new_index - 1];
}
@@ -988,6 +994,28 @@ void FlowGraph::InlineCall(Definition* call, FlowGraph* callee_graph) {
// TODO(zerny): Compute the dominator frontier locally.
invalid_dominator_tree_ = true;
}
+
+ // Remove push arguments of the call.
+ for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
+ PushArgumentInstr* push = call->ArgumentAt(i);
+ push->ReplaceUsesWith(push->value()->definition());
+ push->RemoveFromGraph();
+ }
+
+ // Replace remaining constants with uses by constants in the caller's
+ // initial definitions.
+ GrowableArray<Definition*>* defns =
+ callee_graph->graph_entry()->initial_definitions();
+ for (intptr_t i = 0; i < defns->length(); ++i) {
+ ConstantInstr* constant = (*defns)[i]->AsConstant();
+ if (constant == NULL ||
Kevin Millikin (Google) 2012/11/02 11:35:23 I wouldn't use continue to skip a single statement
zerny-google 2012/11/02 12:37:31 That is simpler. Thanks for pointing that out.
+ ((constant->input_use_list() == NULL) &&
+ (constant->env_use_list() == NULL))) {
+ continue;
+ }
+ constant->ReplaceUsesWith(
+ AddConstantToInitialDefinitions(constant->value()));
+ }
}
« no previous file with comments | « no previous file | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698