Bug 847480 - Remove all DeprecatedAbs uses from range analysis code in SpiderMonkey, fixing a couple bugs and adding tests for those bugs. r=nbp

This commit is contained in:
Jeff Walden 2013-03-06 15:29:26 -08:00
parent b30b4197e6
commit 8608d4bbec
3 changed files with 17 additions and 10 deletions

View File

@ -22,7 +22,7 @@
using namespace js;
using namespace js::ion;
using mozilla::DeprecatedAbs;
using mozilla::Abs;
// This algorithm is based on the paper "Eliminating Range Checks Using
// Static Single Assignment Form" by Gough and Klaren.
@ -672,7 +672,7 @@ MAbs::computeRange()
Range other(getOperand(0));
Range *range = new Range(0,
Max(DeprecatedAbs<int64_t>(other.lower()), DeprecatedAbs<int64_t>(other.upper())),
Max(Abs<int64_t>(other.lower()), Abs<int64_t>(other.upper())),
other.isDecimal(),
other.exponent());
setRange(range);
@ -719,8 +719,8 @@ MMod::computeRange()
return;
Range lhs(getOperand(0));
Range rhs(getOperand(1));
int64_t a = DeprecatedAbs<int64_t>(rhs.lower());
int64_t b = DeprecatedAbs<int64_t>(rhs.upper());
int64_t a = Abs<int64_t>(rhs.lower());
int64_t b = Abs<int64_t>(rhs.upper());
if (a == 0 && b == 0)
return;
int64_t bound = Max(1-a, b-1);

View File

@ -0,0 +1,7 @@
function foo(x) {
for (var i = 0x7ffffff0; i <= x; i++) {
var y = (i % -2147483648);
}
return y + 5;
}
assertEq(foo(0x7fffffff), 0x7fffffff + 5);

View File

@ -19,7 +19,7 @@ using namespace js::mjit;
using namespace js::analyze;
using namespace js::types;
using mozilla::DeprecatedAbs;
using mozilla::Abs;
LoopState::LoopState(JSContext *cx, analyze::CrossScriptSSA *ssa,
mjit::Compiler *cc, FrameState *frame)
@ -2029,9 +2029,9 @@ LoopState::computeInterval(const CrossSSAValue &cv, int32_t *pmin, int32_t *pmax
if (!computeInterval(rhsv, &rhsmin, &rhsmax) || rhsmin != rhsmax)
return false;
int32_t rhs = DeprecatedAbs(rhsmax);
*pmin = -(rhs - 1);
*pmax = rhs - 1;
uint32_t absRHS = Abs(rhsmax);
*pmin = -int32_t(absRHS - 1);
*pmax = int32_t(absRHS - 1);
return true;
}
@ -2063,8 +2063,8 @@ LoopState::computeInterval(const CrossSSAValue &cv, int32_t *pmin, int32_t *pmax
if (lhsmin == INT32_MIN || rhsmin == INT32_MIN)
return false;
int32_t nlhs = Max(DeprecatedAbs(lhsmin), DeprecatedAbs(lhsmax));
int32_t nrhs = Max(DeprecatedAbs(rhsmin), DeprecatedAbs(rhsmax));
int32_t nlhs = int32_t(Max(Abs(lhsmin), Abs(lhsmax)));
int32_t nrhs = int32_t(Max(Abs(rhsmin), Abs(rhsmax)));
if (!SafeMul(nlhs, nrhs, pmax))
return false;