Commit 5dafb426 authored by ishell@chromium.org's avatar ishell@chromium.org

Flow engine fixes: unreachable block processing, state merging.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/144013003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18885 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d330d480
......@@ -117,7 +117,7 @@ class HCheckTable : public ZoneObject {
}
// Global analysis: Copy state to successor block.
HCheckTable* Copy(HBasicBlock* succ, Zone* zone) {
HCheckTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, Zone* zone) {
HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_);
for (int i = 0; i < size_; i++) {
HCheckTableEntry* old_entry = &entries_[i];
......@@ -173,7 +173,8 @@ class HCheckTable : public ZoneObject {
}
// Global analysis: Merge this state with the other incoming state.
HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) {
HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that,
HBasicBlock* that_block, Zone* zone) {
if (that->size_ == 0) {
// If the other state is empty, simply reset.
size_ = 0;
......
......@@ -124,17 +124,19 @@ class HFlowEngine {
if (SkipNonDominatedBlock(root, block)) continue;
State* state = StateAt(block);
if (block->IsLoopHeader()) {
// Apply loop effects before analyzing loop body.
ComputeLoopEffects(block)->Apply(state);
} else {
// Must have visited all predecessors before this block.
CheckPredecessorCount(block);
}
if (block->IsReachable()) {
if (block->IsLoopHeader()) {
// Apply loop effects before analyzing loop body.
ComputeLoopEffects(block)->Apply(state);
} else {
// Must have visited all predecessors before this block.
CheckPredecessorCount(block);
}
// Go through all instructions of the current block, updating the state.
for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
state = state->Process(it.Current(), zone_);
// Go through all instructions of the current block, updating the state.
for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
state = state->Process(it.Current(), zone_);
}
}
// Propagate the block state forward to all successor blocks.
......@@ -149,11 +151,11 @@ class HFlowEngine {
SetStateAt(succ, state);
} else {
// Successor needs a copy of the state.
SetStateAt(succ, state->Copy(succ, zone_));
SetStateAt(succ, state->Copy(succ, block, zone_));
}
} else {
// Merge the current state with the state already at the successor.
SetStateAt(succ, state->Merge(succ, StateAt(succ), zone_));
SetStateAt(succ, StateAt(succ)->Merge(succ, state, block, zone_));
}
}
}
......@@ -185,6 +187,7 @@ class HFlowEngine {
i = member->loop_information()->GetLastBackEdge()->block_id();
} else {
// Process all the effects of the block.
if (member->IsUnreachable()) continue;
ASSERT(member->current_loop() == loop);
for (HInstructionIterator it(member); !it.Done(); it.Advance()) {
effects->Process(it.Current(), zone_);
......
......@@ -132,8 +132,10 @@ class HLoadEliminationTable : public ZoneObject {
return this;
}
// Support for global analysis with HFlowEngine: Copy state to sucessor block.
HLoadEliminationTable* Copy(HBasicBlock* succ, Zone* zone) {
// Support for global analysis with HFlowEngine: Copy state to successor
// block.
HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block,
Zone* zone) {
HLoadEliminationTable* copy =
new(zone) HLoadEliminationTable(zone, aliasing_);
copy->EnsureFields(fields_.length());
......@@ -149,8 +151,8 @@ class HLoadEliminationTable : public ZoneObject {
// Support for global analysis with HFlowEngine: Merge this state with
// the other incoming state.
HLoadEliminationTable* Merge(HBasicBlock* succ,
HLoadEliminationTable* that, Zone* zone) {
HLoadEliminationTable* Merge(HBasicBlock* succ, HLoadEliminationTable* that,
HBasicBlock* that_block, Zone* zone) {
if (that->fields_.length() < fields_.length()) {
// Drop fields not in the other table.
fields_.Rewind(that->fields_.length());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment