Bug 915846 - IonMonkey: Rename isInt32() to hasInt32Bounds() and introduce a new isInt32() which actually checks for an int32 range. r=nbp

This commit is contained in:
Dan Gohman 2013-09-19 18:31:32 -07:00
Родитель 6e024eb500
Коммит 22fa9b099e
3 изменённых файлов: 36 добавлений и 16 удалений

Просмотреть файл

@ -1246,7 +1246,7 @@ MBinaryArithInstruction::trySpecializeFloat32()
bool
MAbs::fallible() const
{
return !implicitTruncate_ && (!range() || !range()->isInt32());
return !implicitTruncate_ && (!range() || !range()->hasInt32Bounds());
}
MDefinition *
@ -1353,7 +1353,7 @@ MAdd::fallible()
// either the truncation analysis shows that there are non-truncated uses.
if (isTruncated())
return false;
if (range() && range()->isInt32())
if (range() && range()->hasInt32Bounds())
return false;
return true;
}
@ -1364,7 +1364,7 @@ MSub::fallible()
// see comment in MAdd::fallible()
if (isTruncated())
return false;
if (range() && range()->isInt32())
if (range() && range()->hasInt32Bounds())
return false;
return true;
}
@ -1432,7 +1432,7 @@ MMul::canOverflow()
{
if (isTruncated())
return false;
return !range() || !range()->isInt32();
return !range() || !range()->hasInt32Bounds();
}
bool
@ -1440,7 +1440,7 @@ MUrsh::canOverflow()
{
if (!canOverflow_)
return false;
return !range() || !range()->isInt32();
return !range() || !range()->hasInt32Bounds();
}
static inline bool

Просмотреть файл

@ -693,7 +693,7 @@ Range *
Range::min(const Range *lhs, const Range *rhs)
{
// If either operand is NaN, the result is NaN.
if (!lhs->isInt32() || !rhs->isInt32())
if (!lhs->hasInt32Bounds() || !rhs->hasInt32Bounds())
return new Range();
return new Range(Min(lhs->lower(), rhs->lower()),
@ -706,7 +706,7 @@ Range *
Range::max(const Range *lhs, const Range *rhs)
{
// If either operand is NaN, the result is NaN.
if (!lhs->isInt32() || !rhs->isInt32())
if (!lhs->hasInt32Bounds() || !rhs->hasInt32Bounds())
return new Range();
return new Range(Max(lhs->lower(), rhs->lower()),
@ -1056,7 +1056,7 @@ MMod::computeRange()
// If either operand is a NaN, the result is NaN. This also conservatively
// handles Infinity cases.
if (!lhs.isInt32() || !rhs.isInt32())
if (!lhs.hasInt32Bounds() || !rhs.hasInt32Bounds())
return;
// If RHS can be zero, the result can be NaN.
@ -1737,8 +1737,10 @@ Range::clampToInt32()
void
Range::wrapAroundToInt32()
{
if (!isInt32())
if (!hasInt32Bounds())
set(JSVAL_INT_MIN, JSVAL_INT_MAX);
else if (canHaveFractionalPart())
set(lower(), upper(), false, exponent());
}
void
@ -1835,13 +1837,22 @@ MDiv::truncate()
// Remember analysis, needed to remove negative zero checks.
setTruncated(true);
// Divisions where the lhs and rhs are unsigned and the result is
// truncated can be lowered more efficiently.
if (specialization() == MIRType_Int32 && tryUseUnsignedOperands()) {
unsigned_ = true;
if (type() == MIRType_Double || type() == MIRType_Int32) {
specialization_ = MIRType_Int32;
setResultType(MIRType_Int32);
if (range())
range()->wrapAroundToInt32();
// Divisions where the lhs and rhs are unsigned and the result is
// truncated can be lowered more efficiently.
if (tryUseUnsignedOperands())
unsigned_ = true;
return true;
}
JS_ASSERT(specialization() != MIRType_Int32); // fixme
// No modifications.
return false;
}

Просмотреть файл

@ -259,11 +259,20 @@ class Range : public TempObject {
return hasInt32UpperBound_;
}
bool isInt32() const {
// Test whether the value is known to be within [INT32_MIN,INT32_MAX].
// Note that this does not necessarily mean the value is an integer.
bool hasInt32Bounds() const {
return hasInt32LowerBound() && hasInt32UpperBound();
}
// Test whether the value is known to be representable as an int32.
bool isInt32() const {
return hasInt32Bounds() && !canHaveFractionalPart();
}
// Test whether the given value is known to be either 0 or 1.
bool isBoolean() const {
return lower() >= 0 && upper() <= 1;
return lower() >= 0 && upper() <= 1 && !canHaveFractionalPart();
}
bool hasRoundingErrors() const {
@ -376,7 +385,7 @@ class Range : public TempObject {
// exponent of JSVAL_INT_MIN == 32
// exponent of JSVAL_INT_MAX == 31
void rectifyExponent() {
if (!isInt32()) {
if (!hasInt32Bounds()) {
JS_ASSERT(max_exponent_ >= MaxInt32Exponent);
return;
}