Bug 1090037 - Ensure that dominators are defined enough before moving instructions. r=sunfish,h4writer

This commit is contained in:
Nicolas B. Pierron 2014-10-30 15:22:57 +01:00
parent c5e7977757
commit 69285f9208
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,7 @@
function f(x) {
Math.sin([] | 0 && x)
}
for (var j = 0; j < 1; j++) {
f(1 && 0)
}

View File

@ -1301,6 +1301,23 @@ MPhi::foldsTernary()
if (testArg != test->input())
return nullptr;
// This check should be a tautology, except that the constant might be the
// result of the removal of a branch. In such case the domination scope of
// the block which is holding the constant might be incomplete. This
// condition is used to prevent doing this optimization based on incomplete
// information.
//
// As GVN removed a branch, it will update the dominations rules before
// trying to fold this MPhi again. Thus, this condition does not inhibit
// this optimization.
MBasicBlock *truePred = block()->getPredecessor(firstIsTrueBranch ? 0 : 1);
MBasicBlock *falsePred = block()->getPredecessor(firstIsTrueBranch ? 1 : 0);
if (!trueDef->block()->dominates(truePred) ||
!falseDef->block()->dominates(falsePred))
{
return nullptr;
}
// If testArg is an int32 type we can:
// - fold testArg ? testArg : 0 to testArg
// - fold testArg ? 0 : testArg to 0

View File

@ -654,6 +654,10 @@ ValueNumberer::leader(MDefinition *def)
if (!values_.add(p, def))
return nullptr;
}
#ifdef DEBUG
JitSpew(JitSpew_GVN, " Recording %s%u", def->opName(), def->id());
#endif
}
return def;