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

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: 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..f38871405d03813ae69bdd5abb0bbd82f2653a4e 100644
--- a/runtime/vm/flow_graph_allocator.cc
+++ b/runtime/vm/flow_graph_allocator.cc
@@ -80,12 +80,31 @@ 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];
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);
+ }
}
}
}
@@ -138,7 +157,8 @@ void FlowGraphAllocator::ComputeInitialSets() {
if (join->phis() != NULL) {
for (intptr_t j = 0; j < join->phis()->length(); j++) {
PhiInstr* phi = (*join->phis())[j];
- if (phi == NULL) continue;
+ if ((phi == NULL) || !phi->is_alive()) continue;
Kevin Millikin (Google) 2012/08/08 11:07:43 It doesn't work to set (*join->phis())[j] = NULL w
+
kill->Add(phi->ssa_temp_index());
live_in->Remove(phi->ssa_temp_index());
@@ -556,6 +576,11 @@ Instruction* FlowGraphAllocator::ConnectOutgoingPhiMoves(
PhiInstr* phi = (*phis)[phi_idx];
if (phi == NULL) continue;
+ if (!phi->is_alive()) {
+ move_idx++;
+ continue;
+ }
+
Value* val = phi->InputAt(pred_idx);
MoveOperands* move = parallel_move->MoveOperandsAt(move_idx);
if (val->IsUse()) {
@@ -602,6 +627,11 @@ void FlowGraphAllocator::ConnectIncomingPhiMoves(BlockEntryInstr* block) {
PhiInstr* phi = (*phis)[phi_idx];
if (phi == NULL) continue;
+ if (!phi->is_alive()) {
+ move_idx++;
+ continue;
+ }
+
const intptr_t vreg = phi->ssa_temp_index();
ASSERT(vreg != -1);
« 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