Bug 891070 - IonMonkey: Implement range analysis for nodes with Boolean return types. r=nbp

This commit is contained in:
Dan Gohman 2013-07-10 11:48:28 -07:00
parent eb9a2230f8
commit 6227ba59c5
2 changed files with 16 additions and 0 deletions

View File

@ -387,6 +387,8 @@ Range::Range(const MDefinition *def)
if (def->type() == MIRType_Int32)
truncate();
else if (def->type() == MIRType_Boolean)
truncateToBoolean();
}
const int64_t RANGE_INF_MAX = (int64_t) JSVAL_INT_MAX + 1;
@ -1491,6 +1493,14 @@ Range::truncate()
set(l, h, false, 32);
}
void
Range::truncateToBoolean()
{
if (isBoolean())
return;
set(0, 1, false, 1);
}
bool
MDefinition::truncate()
{

View File

@ -258,6 +258,9 @@ class Range : public TempObject {
inline bool isInt32() const {
return !isLowerInfinite() && !isUpperInfinite();
}
inline bool isBoolean() const {
return lower() >= 0 && upper() <= 1;
}
inline bool hasRoundingErrors() const {
return isDecimal() || exponent() >= MaxTruncatableExponent;
@ -340,6 +343,9 @@ class Range : public TempObject {
// Truncate the range to an Int32 range.
void truncate();
// Truncate the range to a Boolean range.
void truncateToBoolean();
// Set the exponent by using the precise range analysis on the full
// range of Int32 values. This might shrink the exponent after some
// operations.