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

Unified Diff: runtime/vm/flow_graph_allocator.cc

Issue 10832180: Eliminate phis that do not reach any non-environment uses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Kevin's comment 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 | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_allocator.cc
diff --git a/runtime/vm/flow_graph_allocator.cc b/runtime/vm/flow_graph_allocator.cc
index ae1a3c255c01344014468583cb60856bf4a17519..110ed56a413d771357f88cf73f355099fac7e492 100644
--- a/runtime/vm/flow_graph_allocator.cc
+++ b/runtime/vm/flow_graph_allocator.cc
@@ -80,12 +80,34 @@ FlowGraphAllocator::FlowGraphAllocator(
}
+// Remove environments from the instructions which can't deoptimize.
+// Replace dead phis uses with null values in environments.
void FlowGraphAllocator::EliminateEnvironmentUses() {
+ ConstantVal* null_value = new ConstantVal(Object::ZoneHandle());
+
for (intptr_t i = 0; i < block_order_.length(); ++i) {
BlockEntryInstr* block = block_order_[i];
+
+ if (block->IsJoinEntry()) block->AsJoinEntry()->RemoveDeadPhis();
+
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
Instruction* current = it.Current();
- if (!current->CanDeoptimize()) current->set_env(NULL);
+ if (current->CanDeoptimize()) {
+ ASSERT(current->env() != NULL);
+ GrowableArray<Value*>* values = current->env()->values_ptr();
+
+ for (intptr_t i = 0; i < values->length(); i++) {
+ UseVal* use = (*values)[i]->AsUse();
+ if (use == NULL) continue;
+
+ PhiInstr* phi = use->definition()->AsPhi();
+ if (phi == NULL) continue;
+
+ if (!phi->is_alive()) (*values)[i] = null_value;
+ }
+ } else {
+ current->set_env(NULL);
+ }
}
}
}
@@ -139,6 +161,7 @@ void FlowGraphAllocator::ComputeInitialSets() {
for (intptr_t j = 0; j < join->phis()->length(); j++) {
PhiInstr* phi = (*join->phis())[j];
if (phi == NULL) continue;
+
kill->Add(phi->ssa_temp_index());
live_in->Remove(phi->ssa_temp_index());
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698