Commit b446674c authored by ishell@chromium.org's avatar ishell@chromium.org

More check elimination improvements including partial learning on false...

More check elimination improvements including partial learning on false branches of CompareMap and better handling of unreachable blocks.

R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19300 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 36ba6f01
This diff is collapsed.
......@@ -122,9 +122,10 @@ class HFlowEngine {
// Skip blocks not dominated by the root node.
if (SkipNonDominatedBlock(root, block)) continue;
State* state = StateAt(block);
State* state = State::Finish(StateAt(block), block, zone_);
if (block->IsReachable()) {
ASSERT(state != NULL);
if (block->IsLoopHeader()) {
// Apply loop effects before analyzing loop body.
ComputeLoopEffects(block)->Apply(state);
......@@ -144,18 +145,14 @@ class HFlowEngine {
for (int i = 0; i < max; i++) {
HBasicBlock* succ = block->end()->SuccessorAt(i);
IncrementPredecessorCount(succ);
if (StateAt(succ) == NULL) {
// This is the first state to reach the successor.
if (max == 1 && succ->predecessors()->length() == 1) {
// Optimization: successor can inherit this state.
SetStateAt(succ, state);
} else {
// Successor needs a copy of the state.
SetStateAt(succ, state->Copy(succ, block, zone_));
}
if (max == 1 && succ->predecessors()->length() == 1) {
// Optimization: successor can inherit this state.
SetStateAt(succ, state);
} else {
// Merge the current state with the state already at the successor.
SetStateAt(succ, StateAt(succ)->Merge(succ, state, block, zone_));
SetStateAt(succ,
State::Merge(StateAt(succ), succ, state, block, zone_));
}
}
}
......
......@@ -132,8 +132,32 @@ class HLoadEliminationTable : public ZoneObject {
return this;
}
// Support for global analysis with HFlowEngine: Copy state to successor
// block.
// Support for global analysis with HFlowEngine: Merge given state with
// the other incoming state.
static HLoadEliminationTable* Merge(HLoadEliminationTable* succ_state,
HBasicBlock* succ_block,
HLoadEliminationTable* pred_state,
HBasicBlock* pred_block,
Zone* zone) {
ASSERT(pred_state != NULL);
if (succ_state == NULL) {
return pred_state->Copy(succ_block, pred_block, zone);
} else {
return succ_state->Merge(succ_block, pred_state, pred_block, zone);
}
}
// Support for global analysis with HFlowEngine: Given state merged with all
// the other incoming states, prepare it for use.
static HLoadEliminationTable* Finish(HLoadEliminationTable* state,
HBasicBlock* block,
Zone* zone) {
ASSERT(state != NULL);
return state;
}
private:
// Copy state to successor block.
HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block,
Zone* zone) {
HLoadEliminationTable* copy =
......@@ -149,8 +173,7 @@ class HLoadEliminationTable : public ZoneObject {
return copy;
}
// Support for global analysis with HFlowEngine: Merge this state with
// the other incoming state.
// Merge this state with the other incoming state.
HLoadEliminationTable* Merge(HBasicBlock* succ, HLoadEliminationTable* that,
HBasicBlock* that_block, Zone* zone) {
if (that->fields_.length() < fields_.length()) {
......
......@@ -337,6 +337,15 @@ void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
}
void HBasicBlock::MarkSuccEdgeUnreachable(int succ) {
ASSERT(IsFinished());
HBasicBlock* succ_block = end()->SuccessorAt(succ);
ASSERT(succ_block->predecessors()->length() == 1);
succ_block->MarkUnreachable();
}
void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) {
if (HasPredecessor()) {
// Only loop header blocks can have a predecessor added after
......
......@@ -174,6 +174,8 @@ class HBasicBlock V8_FINAL : public ZoneObject {
dominates_loop_successors_ = true;
}
void MarkSuccEdgeUnreachable(int succ);
inline Zone* zone() const;
#ifdef DEBUG
......
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