Bug 1105574 - Range Analysis: Keep folded bitwise instructions alive for bailouts. r=sunfish

This commit is contained in:
Nicolas B. Pierron 2015-03-12 19:01:51 +01:00
parent 69a35609b0
commit 25a8fd36fb
4 changed files with 36 additions and 2 deletions

View File

@ -0,0 +1,11 @@
function f1(x) {
assertEq(Math.tan((((x >>> 0) | 0) >>> 0) | 0, f2()) < -1, !!x);
}
var f2 = function() { };
f1(0);
f2 = function() { };
f1(0);
f1(0);
f1(-1);

View File

@ -615,6 +615,22 @@ MDefinition::optimizeOutAllUses(TempAllocator &alloc)
this->uses_.clear(); this->uses_.clear();
} }
void
MDefinition::replaceAllLiveUsesWith(MDefinition *dom)
{
for (MUseIterator i(usesBegin()), e(usesEnd()); i != e; ) {
MUse *use = *i++;
MNode *consumer = use->consumer();
if (consumer->isResumePoint())
continue;
if (consumer->isDefinition() && consumer->toDefinition()->isRecoveredOnBailout())
continue;
// Update the operand to use the dominating definition.
use->replaceProducer(dom);
}
}
bool bool
MDefinition::emptyResultTypeSet() const MDefinition::emptyResultTypeSet() const
{ {

View File

@ -738,6 +738,11 @@ class MDefinition : public MNode
// be observed, and thus they should not flow in any computation. // be observed, and thus they should not flow in any computation.
void optimizeOutAllUses(TempAllocator &alloc); void optimizeOutAllUses(TempAllocator &alloc);
// Replace the current instruction by a dominating instruction |dom| in all
// instruction, but keep the current instruction for resume point and
// instruction which are recovered on bailouts.
void replaceAllLiveUsesWith(MDefinition *dom);
// Mark this instruction as having replaced all uses of ins, as during GVN, // Mark this instruction as having replaced all uses of ins, as during GVN,
// returning false if the replacement should not be performed. For use when // returning false if the replacement should not be performed. For use when
// GVN eliminates instructions which are not equivalent to one another. // GVN eliminates instructions which are not equivalent to one another.

View File

@ -3038,8 +3038,10 @@ RangeAnalysis::truncate()
for (size_t i = 0; i < bitops.length(); i++) { for (size_t i = 0; i < bitops.length(); i++) {
MBinaryBitwiseInstruction *ins = bitops[i]; MBinaryBitwiseInstruction *ins = bitops[i];
MDefinition *folded = ins->foldUnnecessaryBitop(); MDefinition *folded = ins->foldUnnecessaryBitop();
if (folded != ins) if (folded != ins) {
ins->replaceAllUsesWith(folded); ins->replaceAllLiveUsesWith(folded);
ins->setRecoveredOnBailout();
}
} }
return true; return true;