Backout changeset c01dea53dd60, r=faulty

This commit is contained in:
Hannes Verschore 2014-08-15 14:29:47 +02:00
parent bc4a8d8b4e
commit 8c1cd0bd8e
5 changed files with 23 additions and 127 deletions

View File

@ -153,7 +153,7 @@ function ToLength(v) {
return 0;
// Math.pow(2, 53) - 1 = 0x1fffffffffffff
return std_Math_min(v, 0x1fffffffffffff);
return v < 0x1fffffffffffff ? v : 0x1fffffffffffff;
}
/********** Testing code **********/

View File

@ -0,0 +1,12 @@
function f(y) {
return 2147483648 < y >>> 0
}
assertEq(f(0), false);
assertEq(f(-8), true);
function g(y) {
var t = Math.floor(y);
return 2147483648 < t+2;
}
assertEq(g(0), false)
assertEq(g(2147483647), true)

View File

@ -1093,64 +1093,31 @@ IonBuilder::inlineMathFRound(CallInfo &callInfo)
IonBuilder::InliningStatus
IonBuilder::inlineMathMinMax(CallInfo &callInfo, bool max)
{
if (callInfo.argc() < 1 || callInfo.constructing())
if (callInfo.argc() < 2 || callInfo.constructing())
return InliningStatus_NotInlined;
MIRType returnType = getInlineReturnType();
if (!IsNumberType(returnType))
return InliningStatus_NotInlined;
MDefinitionVector int32Cases(alloc());
for (unsigned i = 0; i < callInfo.argc(); i++) {
MDefinition *arg = callInfo.getArg(i);
switch (arg->type()) {
case MIRType_Int32:
if (!int32Cases.append(arg))
return InliningStatus_Error;
break;
case MIRType_Double:
case MIRType_Float32:
// Don't force a double MMinMax for arguments that would be a NOP
// when doing an integer MMinMax.
// If the argument is NaN, the conditions below will be false and
// a double comparison is forced.
if (arg->isConstant()) {
double d = arg->toConstant()->value().toDouble();
// min(int32, d >= INT32_MAX) = int32
if (d >= INT32_MAX && !max)
break;
// max(int32, d <= INT32_MIN) = int32
if (d <= INT32_MIN && max)
break;
}
// Force double MMinMax if result would be different.
returnType = MIRType_Double;
break;
default:
MIRType argType = callInfo.getArg(i)->type();
if (!IsNumberType(argType))
return InliningStatus_NotInlined;
}
}
if (int32Cases.length() == 0)
returnType = MIRType_Double;
// When one of the arguments is double, do a double MMinMax.
if (returnType == MIRType_Int32 && IsFloatingPointType(argType))
returnType = MIRType_Double;
}
callInfo.setImplicitlyUsedUnchecked();
MDefinitionVector &cases = (returnType == MIRType_Int32) ? int32Cases : callInfo.argv();
if (cases.length() == 1) {
current->push(cases[0]);
return InliningStatus_Inlined;
}
// Chain N-1 MMinMax instructions to compute the MinMax.
MMinMax *last = MMinMax::New(alloc(), cases[0], cases[1], returnType, max);
MMinMax *last = MMinMax::New(alloc(), callInfo.getArg(0), callInfo.getArg(1), returnType, max);
current->add(last);
for (unsigned i = 2; i < cases.length(); i++) {
MMinMax *ins = MMinMax::New(alloc(), last, cases[2], returnType, max);
for (unsigned i = 2; i < callInfo.argc(); i++) {
MMinMax *ins = MMinMax::New(alloc(), last, callInfo.getArg(i), returnType, max);
current->add(ins);
last = ins;
}

View File

@ -1559,29 +1559,6 @@ MBinaryArithInstruction::trySpecializeFloat32(TempAllocator &alloc)
setResultType(MIRType_Float32);
}
MDefinition *
MMinMax::foldsTo(TempAllocator &alloc)
{
if (!lhs()->isConstant() && !rhs()->isConstant())
return this;
MDefinition *operand = lhs()->isConstant() ? rhs() : lhs();
MConstant *constant = lhs()->isConstant() ? lhs()->toConstant() : rhs()->toConstant();
if (operand->isToDouble() && operand->getOperand(0)->type() == MIRType_Int32) {
const js::Value &val = constant->value();
// min(int32, d >= INT32_MAX) = int32
if (val.isDouble() && val.toDouble() >= INT32_MAX && !isMax())
return operand;
// max(int32, d <= INT32_MIN) = int32
if (val.isDouble() && val.toDouble() <= INT32_MIN && isMax())
return operand;
}
return this;
}
bool
MAbs::fallible() const
{
@ -2675,65 +2652,6 @@ MCompare::evaluateConstantOperands(bool *result)
MDefinition *left = getOperand(0);
MDefinition *right = getOperand(1);
if (compareType() == Compare_Double) {
// Optimize "MCompare MConstant (MToDouble SomethingInInt32Range).
// In most cases the MToDouble was added, because the constant is
// a double. e.g. v < 9007199254740991,
// where v is an int32 so the result is always true.
if (!lhs()->isConstant() && !rhs()->isConstant())
return false;
MDefinition *operand = left->isConstant() ? right : left;
MConstant *constant = left->isConstant() ? left->toConstant() : right->toConstant();
JS_ASSERT(constant->value().isDouble());
double d = constant->value().toDouble();
if (operand->isToDouble() && operand->getOperand(0)->type() == MIRType_Int32) {
switch (jsop_) {
case JSOP_LT:
if (d > INT32_MAX || d < INT32_MIN) {
*result = !((constant == lhs()) ^ (d < INT32_MIN));
return true;
}
break;
case JSOP_LE:
if (d >= INT32_MAX || d <= INT32_MIN) {
*result = !((constant == lhs()) ^ (d <= INT32_MIN));
return true;
}
break;
case JSOP_GT:
if (d > INT32_MAX || d < INT32_MIN) {
*result = !((constant == rhs()) ^ (d < INT32_MIN));
return true;
}
break;
case JSOP_GE:
if (d >= INT32_MAX || d <= INT32_MIN) {
*result = !((constant == rhs()) ^ (d <= INT32_MIN));
return true;
}
break;
case JSOP_STRICTEQ: // Fall through.
case JSOP_EQ:
if (d > INT32_MAX || d < INT32_MIN) {
*result = false;
return true;
}
break;
case JSOP_STRICTNE: // Fall through.
case JSOP_NE:
if (d > INT32_MAX || d < INT32_MIN) {
*result = true;
return true;
}
break;
default:
MOZ_ASSUME_UNREACHABLE("Unexpected op.");
}
}
}
if (!left->isConstant() || !right->isConstant())
return false;

View File

@ -4410,7 +4410,6 @@ class MMinMax
AliasSet getAliasSet() const {
return AliasSet::None();
}
MDefinition *foldsTo(TempAllocator &alloc);
void computeRange(TempAllocator &alloc);
bool writeRecoverData(CompactBufferWriter &writer) const;
bool canRecoverOnBailout() const {