diff --git a/js/src/ion/RangeAnalysis.cpp b/js/src/ion/RangeAnalysis.cpp index 05a6a529f7e5..1817ac2de8bb 100644 --- a/js/src/ion/RangeAnalysis.cpp +++ b/js/src/ion/RangeAnalysis.cpp @@ -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(other.lower()), DeprecatedAbs(other.upper())), + Max(Abs(other.lower()), Abs(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(rhs.lower()); - int64_t b = DeprecatedAbs(rhs.upper()); + int64_t a = Abs(rhs.lower()); + int64_t b = Abs(rhs.upper()); if (a == 0 && b == 0) return; int64_t bound = Max(1-a, b-1); diff --git a/js/src/jit-test/tests/jaeger/loops/integer-3.js b/js/src/jit-test/tests/jaeger/loops/integer-3.js new file mode 100644 index 000000000000..26c7b76a8f99 --- /dev/null +++ b/js/src/jit-test/tests/jaeger/loops/integer-3.js @@ -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); diff --git a/js/src/methodjit/LoopState.cpp b/js/src/methodjit/LoopState.cpp index 8c8e57282ab6..21e65fd40865 100644 --- a/js/src/methodjit/LoopState.cpp +++ b/js/src/methodjit/LoopState.cpp @@ -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;