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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10871040: Revert my last change r11227. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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_optimizer.h ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 11228)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -955,45 +955,29 @@
}
-void DominatorBasedCSE::Optimize(BlockEntryInstr* graph_entry) {
- ASSERT(graph_entry->IsGraphEntry());
- DirectChainedHashMap<BindInstr*> map;
- OptimizeRecursive(graph_entry, &map);
-}
-
-
-void DominatorBasedCSE::OptimizeRecursive(
- BlockEntryInstr* block,
- DirectChainedHashMap<BindInstr*>* map) {
- for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
- BindInstr* instr = it.Current()->AsBind();
- if (instr == NULL || instr->computation()->HasSideEffect()) continue;
- BindInstr* result = map->Lookup(instr);
- if (result == NULL) {
- map->Insert(instr);
- continue;
+void LocalCSE::Optimize() {
+ for (intptr_t i = 0; i < blocks_.length(); ++i) {
+ BlockEntryInstr* entry = blocks_[i];
+ DirectChainedHashMap<BindInstr*> map;
+ ASSERT(map.IsEmpty());
+ for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
+ BindInstr* instr = it.Current()->AsBind();
+ if (instr == NULL || instr->computation()->HasSideEffect()) continue;
+ BindInstr* result = map.Lookup(instr);
+ if (result == NULL) {
+ map.Insert(instr);
+ continue;
+ }
+ // Replace current with lookup result.
+ instr->ReplaceUsesWith(result);
+ it.RemoveCurrentFromGraph();
+ if (FLAG_trace_optimization) {
+ OS::Print("Replacing v%d with v%d\n",
+ instr->ssa_temp_index(),
+ result->ssa_temp_index());
+ }
}
- // Replace current with lookup result.
- instr->ReplaceUsesWith(result);
- it.RemoveCurrentFromGraph();
- if (FLAG_trace_optimization) {
- OS::Print("Replacing v%d with v%d\n",
- instr->ssa_temp_index(),
- result->ssa_temp_index());
- }
}
-
- // Process children in the dominator tree recursively.
- intptr_t num_children = block->dominated_blocks().length();
- for (intptr_t i = 0; i < num_children; ++i) {
- BlockEntryInstr* child = block->dominated_blocks()[i];
- if (i < num_children - 1) {
- DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map.
- OptimizeRecursive(child, &child_map);
- } else {
- OptimizeRecursive(child, map); // Reuse map for the last child.
- }
- }
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698