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

Unified Diff: runtime/vm/flow_graph.cc

Issue 1679853002: VM: Move redundancy elimination phases into a separate file. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed indentation Created 4 years, 10 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.h » ('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 4097af5e293044f5866f627dd744c2bc86c20322..49f81ff7e9600407efe656bb014dd8c8c48759b6 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -52,6 +52,43 @@ FlowGraph::FlowGraph(const ParsedFunction& parsed_function,
}
+void FlowGraph::EnsureSSATempIndex(Definition* defn,
+ Definition* replacement) {
+ if ((replacement->ssa_temp_index() == -1) &&
+ (defn->ssa_temp_index() != -1)) {
+ AllocateSSAIndexes(replacement);
+ }
+}
+
+
+void FlowGraph::ReplaceCurrentInstruction(ForwardInstructionIterator* iterator,
+ Instruction* current,
+ Instruction* replacement) {
+ Definition* current_defn = current->AsDefinition();
+ if ((replacement != NULL) && (current_defn != NULL)) {
+ Definition* replacement_defn = replacement->AsDefinition();
+ ASSERT(replacement_defn != NULL);
+ current_defn->ReplaceUsesWith(replacement_defn);
+ EnsureSSATempIndex(current_defn, replacement_defn);
+
+ if (FLAG_trace_optimization) {
+ THR_Print("Replacing v%" Pd " with v%" Pd "\n",
+ current_defn->ssa_temp_index(),
+ replacement_defn->ssa_temp_index());
+ }
+ } else if (FLAG_trace_optimization) {
+ if (current_defn == NULL) {
+ THR_Print("Removing %s\n", current->DebugName());
+ } else {
+ ASSERT(!current_defn->HasUses());
+ THR_Print("Removing v%" Pd ".\n", current_defn->ssa_temp_index());
+ }
+ }
+ iterator->RemoveCurrentFromGraph();
+}
+
+
+
void FlowGraph::AddToGuardedFields(
ZoneGrowableArray<const Field*>* array,
const Field* field) {
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698