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

Unified Diff: runtime/vm/flow_graph.cc

Issue 557413002: Merge chains of straight-line blocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
===================================================================
--- runtime/vm/flow_graph.cc (revision 40086)
+++ runtime/vm/flow_graph.cc (working copy)
@@ -175,6 +175,49 @@
}
+void FlowGraph::MergeBlocks() {
+ bool changed = false;
+ BitVector* merged = new(isolate()) BitVector(postorder().length());
zerny-google 2014/11/19 11:32:34 BitVector takes a isolate as first argument after
Florian Schneider 2014/11/19 12:19:35 Done.
+ for (BlockIterator block_it = reverse_postorder_iterator();
+ !block_it.Done();
+ block_it.Advance()) {
+ BlockEntryInstr* block = block_it.Current();
+ if (block->IsGraphEntry()) continue;
+ if (merged->Contains(block->postorder_number())) continue;
+
+ Instruction* last = block->last_instruction();
+ BlockEntryInstr* successor = NULL;
+ while ((last->SuccessorCount() == 1) &&
+ (last->SuccessorAt(0)->PredecessorCount() == 1) &&
+ (block->try_index() == last->SuccessorAt(0)->try_index())) {
+ successor = last->SuccessorAt(0);
+ ASSERT(last->IsGoto());
+
+ // Remove environment uses and unlink goto and block entry.
+ successor->UnuseAllInputs();
+ last->previous()->LinkTo(successor->next());
+ last->UnuseAllInputs();
+
+ last = successor->last_instruction();
+ merged->Add(successor->postorder_number());
+ changed = true;
+ if (FLAG_trace_optimization) {
+ OS::Print("Merged blocks B%" Pd " and B%" Pd "\n",
+ block->block_id(),
+ successor->block_id());
+ }
+ }
+ // The new block inherits the block id of the last successor to maintain
+ // the order of phi inputs at its successors consistent with block ids.
+ if (successor != NULL) {
+ block->set_block_id(successor->block_id());
+ }
+ }
+ // Recompute block order after changes were made.
+ if (changed) DiscoverBlocks();
+}
+
+
// Debugging code to verify the construction of use lists.
static intptr_t MembershipCount(Value* use, Value* list) {
intptr_t count = 0;
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698