diff --git a/js/public/Value.h b/js/public/Value.h index f08f5c245d8..d2cdb30f538 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -859,7 +859,7 @@ static inline JS_VALUE_CONSTEXPR JS::Value UndefinedValue(); static MOZ_ALWAYS_INLINE double GenericNaN() { - return mozilla::SpecificNaN(0, 0x8000000000000ULL); + return mozilla::SpecificNaN(0, 0x8000000000000ULL); } static inline double @@ -979,7 +979,7 @@ class Value bool setNumber(double d) { int32_t i; - if (mozilla::DoubleIsInt32(d, &i)) { + if (mozilla::NumberIsInt32(d, &i)) { setInt32(i); return true; } @@ -1632,7 +1632,7 @@ class HeapBase : public ValueOperations > bool setNumber(double d) { int32_t i; - if (mozilla::DoubleIsInt32(d, &i)) { + if (mozilla::NumberIsInt32(d, &i)) { setInt32(i); return true; } diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index 023e0887809..77f749fe966 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -21,7 +21,7 @@ using namespace js; -using mozilla::DoubleEqualsInt32; +using mozilla::NumberEqualsInt32; using mozilla::Forward; using mozilla::IsNaN; using mozilla::Move; @@ -784,7 +784,7 @@ HashableValue::setValue(JSContext *cx, HandleValue v) } else if (v.isDouble()) { double d = v.toDouble(); int32_t i; - if (DoubleEqualsInt32(d, &i)) { + if (NumberEqualsInt32(d, &i)) { // Normalize int32_t-valued doubles to int32_t for faster hashing and testing. value = Int32Value(i); } else if (IsNaN(d)) { diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 2bb9373136b..8cffc0b5a41 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -44,7 +44,7 @@ using namespace js::gc; using namespace js::frontend; using mozilla::DebugOnly; -using mozilla::DoubleIsInt32; +using mozilla::NumberIsInt32; using mozilla::PodCopy; static bool @@ -2383,7 +2383,7 @@ EmitNumberOp(ExclusiveContext *cx, double dval, BytecodeEmitter *bce) ptrdiff_t off; jsbytecode *pc; - if (DoubleIsInt32(dval, &ival)) { + if (NumberIsInt32(dval, &ival)) { if (ival == 0) return Emit1(cx, bce, JSOP_ZERO) >= 0; if (ival == 1) @@ -2563,7 +2563,7 @@ EmitSwitch(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn) } int32_t i; - if (!DoubleIsInt32(pn4->pn_dval, &i)) { + if (!NumberIsInt32(pn4->pn_dval, &i)) { switchOp = JSOP_CONDSWITCH; continue; } diff --git a/js/src/frontend/FoldConstants.cpp b/js/src/frontend/FoldConstants.cpp index 956505420bd..bf4b034ed6e 100644 --- a/js/src/frontend/FoldConstants.cpp +++ b/js/src/frontend/FoldConstants.cpp @@ -159,9 +159,9 @@ FoldBinaryNumeric(ExclusiveContext *cx, JSOp op, ParseNode *pn1, ParseNode *pn2, if (d == 0 || IsNaN(d)) d = GenericNaN(); else if (IsNegative(d) != IsNegative(d2)) - d = NegativeInfinity(); + d = NegativeInfinity(); else - d = PositiveInfinity(); + d = PositiveInfinity(); } else { d /= d2; } diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index f25ca790934..1942301cce8 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -3173,7 +3173,7 @@ CheckGlobalDotImport(ModuleCompiler &m, PropertyName *varName, ParseNode *initNo if (field == m.cx()->names().NaN) return m.addGlobalConstant(varName, GenericNaN(), field); if (field == m.cx()->names().Infinity) - return m.addGlobalConstant(varName, PositiveInfinity(), field); + return m.addGlobalConstant(varName, PositiveInfinity(), field); return m.failName(initNode, "'%s' is not a standard global constant", field); } diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index f13c4d58dc0..2c88bd80a56 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -40,7 +40,7 @@ using namespace js; using namespace js::jit; using mozilla::DebugOnly; -using mozilla::DoubleExponentBias; +using mozilla::FloatingPoint; using mozilla::Maybe; using mozilla::NegativeInfinity; using mozilla::PositiveInfinity; @@ -8152,7 +8152,9 @@ CodeGenerator::emitAssertRangeD(const Range *r, FloatRegister input, FloatRegist // This code does not yet check r->canHaveFractionalPart(). This would require new // assembler interfaces to make rounding instructions available. - if (!r->hasInt32Bounds() && !r->canBeInfiniteOrNaN() && r->exponent() < DoubleExponentBias) { + if (!r->hasInt32Bounds() && !r->canBeInfiniteOrNaN() && + r->exponent() < FloatingPoint::ExponentBias) + { // Check the bounds implied by the maximum exponent. Label exponentLoOk; masm.loadConstantDouble(pow(2.0, r->exponent() + 1), temp); @@ -8177,13 +8179,13 @@ CodeGenerator::emitAssertRangeD(const Range *r, FloatRegister input, FloatRegist // If we think the value also can't be an infinity, check that it isn't. if (!r->canBeInfiniteOrNaN()) { Label notposinf; - masm.loadConstantDouble(PositiveInfinity(), temp); + masm.loadConstantDouble(PositiveInfinity(), temp); masm.branchDouble(Assembler::DoubleLessThan, input, temp, ¬posinf); masm.assumeUnreachable("Input shouldn't be +Inf."); masm.bind(¬posinf); Label notneginf; - masm.loadConstantDouble(NegativeInfinity(), temp); + masm.loadConstantDouble(NegativeInfinity(), temp); masm.branchDouble(Assembler::DoubleGreaterThan, input, temp, ¬neginf); masm.assumeUnreachable("Input shouldn't be -Inf."); masm.bind(¬neginf); diff --git a/js/src/jit/IonMacroAssembler.cpp b/js/src/jit/IonMacroAssembler.cpp index b539e49f09b..5af13d07405 100644 --- a/js/src/jit/IonMacroAssembler.cpp +++ b/js/src/jit/IonMacroAssembler.cpp @@ -1676,7 +1676,7 @@ MacroAssembler::convertValueToInt(JSContext *cx, const Value &v, Register output case IntConversion_NegativeZeroCheck: { // -0 is checked anyways if we have a constant value. int i; - if (mozilla::DoubleIsInt32(d, &i)) + if (mozilla::NumberIsInt32(d, &i)) move32(Imm32(i), output); else jump(fail); diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 7aa215310aa..2b423374954 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -26,7 +26,7 @@ using namespace js; using namespace js::jit; -using mozilla::DoublesAreIdentical; +using mozilla::NumbersAreIdentical; using mozilla::IsFloat32Representable; using mozilla::Maybe; @@ -1155,7 +1155,7 @@ IsConstant(MDefinition *def, double v) if (!def->isConstant()) return false; - return DoublesAreIdentical(def->toConstant()->value().toNumber(), v); + return NumbersAreIdentical(def->toConstant()->value().toNumber(), v); } MDefinition * diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index e6a365fca9e..c377fa10bfa 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -25,7 +25,7 @@ using namespace js::jit; using mozilla::Abs; using mozilla::CountLeadingZeroes32; -using mozilla::DoubleEqualsInt32; +using mozilla::NumberEqualsInt32; using mozilla::ExponentComponent; using mozilla::FloorLog2; using mozilla::IsInfinite; @@ -162,8 +162,8 @@ RangeAnalysis::addBetaNodes() MDefinition *left = compare->getOperand(0); MDefinition *right = compare->getOperand(1); double bound; - double conservativeLower = NegativeInfinity(); - double conservativeUpper = PositiveInfinity(); + double conservativeLower = NegativeInfinity(); + double conservativeUpper = PositiveInfinity(); MDefinition *val = nullptr; JSOp jsop = compare->jsop(); @@ -222,7 +222,7 @@ RangeAnalysis::addBetaNodes() // For integers, if x < c, the upper bound of x is c-1. if (val->type() == MIRType_Int32) { int32_t intbound; - if (DoubleEqualsInt32(bound, &intbound) && SafeSub(intbound, 1, &intbound)) + if (NumberEqualsInt32(bound, &intbound) && SafeSub(intbound, 1, &intbound)) bound = intbound; } comp.setDouble(conservativeLower, bound); @@ -234,7 +234,7 @@ RangeAnalysis::addBetaNodes() // For integers, if x > c, the lower bound of x is c+1. if (val->type() == MIRType_Int32) { int32_t intbound; - if (DoubleEqualsInt32(bound, &intbound) && SafeAdd(intbound, 1, &intbound)) + if (NumberEqualsInt32(bound, &intbound) && SafeAdd(intbound, 1, &intbound)) bound = intbound; } comp.setDouble(bound, conservativeUpper); diff --git a/js/src/jit/RangeAnalysis.h b/js/src/jit/RangeAnalysis.h index 2709f368b9f..584902859e6 100644 --- a/js/src/jit/RangeAnalysis.h +++ b/js/src/jit/RangeAnalysis.h @@ -121,10 +121,10 @@ class Range : public TempObject { // Maximal exponenent under which we have no precission loss on double // operations. Double has 52 bits of mantissa, so 2^52+1 cannot be // represented without loss. - static const uint16_t MaxTruncatableExponent = mozilla::DoubleExponentShift; + static const uint16_t MaxTruncatableExponent = mozilla::FloatingPoint::ExponentShift; // Maximum exponent for finite values. - static const uint16_t MaxFiniteExponent = mozilla::DoubleExponentBias; + static const uint16_t MaxFiniteExponent = mozilla::FloatingPoint::ExponentBias; // An special exponent value representing all non-NaN values. This // includes finite values and the infinities. diff --git a/js/src/jit/arm/CodeGenerator-arm.cpp b/js/src/jit/arm/CodeGenerator-arm.cpp index 2ae03452a3c..a2588920487 100644 --- a/js/src/jit/arm/CodeGenerator-arm.cpp +++ b/js/src/jit/arm/CodeGenerator-arm.cpp @@ -1016,7 +1016,7 @@ CodeGeneratorARM::visitPowHalfD(LPowHalfD *ins) Label done; // Masm.pow(-Infinity, 0.5) == Infinity. - masm.ma_vimm(NegativeInfinity(), ScratchFloatReg); + masm.ma_vimm(NegativeInfinity(), ScratchFloatReg); masm.compareDouble(input, ScratchFloatReg); masm.ma_vneg(ScratchFloatReg, output, Assembler::Equal); masm.ma_b(&done, Assembler::Equal); diff --git a/js/src/jit/shared/CodeGenerator-x86-shared.cpp b/js/src/jit/shared/CodeGenerator-x86-shared.cpp index 317121f7741..a98ba585ab4 100644 --- a/js/src/jit/shared/CodeGenerator-x86-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-x86-shared.cpp @@ -21,12 +21,10 @@ using namespace js; using namespace js::jit; -using mozilla::DoubleSignificandBits; -using mozilla::FloatSignificandBits; +using mozilla::FloatingPoint; using mozilla::FloorLog2; using mozilla::NegativeInfinity; using mozilla::SpecificNaN; -using mozilla::SpecificFloatNaN; namespace js { namespace jit { @@ -512,7 +510,8 @@ CodeGeneratorX86Shared::visitAbsD(LAbsD *ins) FloatRegister input = ToFloatRegister(ins->input()); JS_ASSERT(input == ToFloatRegister(ins->output())); // Load a value which is all ones except for the sign bit. - masm.loadConstantDouble(SpecificNaN(0, DoubleSignificandBits), ScratchFloatReg); + masm.loadConstantDouble(SpecificNaN(0, FloatingPoint::SignificandBits), + ScratchFloatReg); masm.andpd(ScratchFloatReg, input); return true; } @@ -523,7 +522,8 @@ CodeGeneratorX86Shared::visitAbsF(LAbsF *ins) FloatRegister input = ToFloatRegister(ins->input()); JS_ASSERT(input == ToFloatRegister(ins->output())); // Same trick as visitAbsD above. - masm.loadConstantFloat32(SpecificFloatNaN(0, FloatSignificandBits), ScratchFloatReg); + masm.loadConstantFloat32(SpecificNaN(0, FloatingPoint::SignificandBits), + ScratchFloatReg); masm.andps(ScratchFloatReg, input); return true; } @@ -556,7 +556,7 @@ CodeGeneratorX86Shared::visitPowHalfD(LPowHalfD *ins) if (!ins->mir()->operandIsNeverNegativeInfinity()) { // Branch if not -Infinity. - masm.loadConstantDouble(NegativeInfinity(), ScratchFloatReg); + masm.loadConstantDouble(NegativeInfinity(), ScratchFloatReg); Assembler::DoubleCondition cond = Assembler::DoubleNotEqualOrUnordered; if (ins->mir()->operandIsNeverNaN()) diff --git a/js/src/jit/x86/CodeGenerator-x86.cpp b/js/src/jit/x86/CodeGenerator-x86.cpp index c7610afca1a..4fd4bea5232 100644 --- a/js/src/jit/x86/CodeGenerator-x86.cpp +++ b/js/src/jit/x86/CodeGenerator-x86.cpp @@ -24,11 +24,7 @@ using namespace js; using namespace js::jit; using mozilla::DebugOnly; -using mozilla::DoubleExponentBias; -using mozilla::DoubleExponentShift; -using mozilla::FloatExponentBias; -using mozilla::FloatExponentShift; -using mozilla::FloatExponentBits; +using mozilla::FloatingPoint; using JS::GenericNaN; CodeGeneratorX86::CodeGeneratorX86(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm) @@ -841,8 +837,9 @@ CodeGeneratorX86::visitOutOfLineTruncate(OutOfLineTruncate *ool) masm.storeDouble(input, Operand(esp, 0)); static const uint32_t EXPONENT_MASK = 0x7ff00000; - static const uint32_t EXPONENT_SHIFT = DoubleExponentShift - 32; - static const uint32_t TOO_BIG_EXPONENT = (DoubleExponentBias + 63) << EXPONENT_SHIFT; + static const uint32_t EXPONENT_SHIFT = FloatingPoint::ExponentShift - 32; + static const uint32_t TOO_BIG_EXPONENT = (FloatingPoint::ExponentBias + 63) + << EXPONENT_SHIFT; // Check exponent to avoid fp exceptions. Label failPopDouble; @@ -928,10 +925,11 @@ CodeGeneratorX86::visitOutOfLineTruncateFloat32(OutOfLineTruncateFloat32 *ool) masm.subl(Imm32(sizeof(uint64_t)), esp); masm.storeFloat32(input, Operand(esp, 0)); - static const uint32_t EXPONENT_MASK = FloatExponentBits; - static const uint32_t EXPONENT_SHIFT = FloatExponentShift; + static const uint32_t EXPONENT_MASK = FloatingPoint::ExponentBits; + static const uint32_t EXPONENT_SHIFT = FloatingPoint::ExponentShift; // Integers are still 64 bits long, so we can still test for an exponent > 63. - static const uint32_t TOO_BIG_EXPONENT = (FloatExponentBias + 63) << EXPONENT_SHIFT; + static const uint32_t TOO_BIG_EXPONENT = (FloatingPoint::ExponentBias + 63) + << EXPONENT_SHIFT; // Check exponent to avoid fp exceptions. Label failPopFloat; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index a23527c36de..ea1e2719138 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -421,7 +421,7 @@ JS_ValueToSource(JSContext *cx, HandleValue value) JS_PUBLIC_API(bool) JS_DoubleIsInt32(double d, int32_t *ip) { - return mozilla::DoubleIsInt32(d, ip); + return mozilla::NumberIsInt32(d, ip); } JS_PUBLIC_API(int32_t) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index bdc4d07e77e..f89a43bf975 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -852,7 +852,7 @@ JS_NumberValue(double d) { int32_t i; d = JS::CanonicalizeNaN(d); - if (mozilla::DoubleIsInt32(d, &i)) + if (mozilla::NumberIsInt32(d, &i)) return INT_TO_JSVAL(i); return DOUBLE_TO_JSVAL(d); } diff --git a/js/src/jslibmath.h b/js/src/jslibmath.h index 348dce28f9d..bc33e97ae4c 100644 --- a/js/src/jslibmath.h +++ b/js/src/jslibmath.h @@ -57,8 +57,8 @@ NumberDiv(double a, double b) return JS::GenericNaN(); if (mozilla::IsNegative(a) != mozilla::IsNegative(b)) - return mozilla::NegativeInfinity(); - return mozilla::PositiveInfinity(); + return mozilla::NegativeInfinity(); + return mozilla::PositiveInfinity(); } return a / b; @@ -66,7 +66,7 @@ NumberDiv(double a, double b) inline double NumberMod(double a, double b) { - if (b == 0) + if (b == 0) return JS::GenericNaN(); return js_fmod(a, b); } diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 4c694b84b2e..629fa5a5822 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -35,8 +35,8 @@ using namespace js; using mozilla::Abs; -using mozilla::DoubleEqualsInt32; -using mozilla::DoubleIsInt32; +using mozilla::NumberEqualsInt32; +using mozilla::NumberIsInt32; using mozilla::ExponentComponent; using mozilla::IsFinite; using mozilla::IsInfinite; @@ -347,9 +347,9 @@ js::math_cos(JSContext *cx, unsigned argc, Value *vp) #ifdef _WIN32 #define EXP_IF_OUT_OF_RANGE(x) \ if (!IsNaN(x)) { \ - if (x == PositiveInfinity()) \ - return PositiveInfinity(); \ - if (x == NegativeInfinity()) \ + if (x == PositiveInfinity()) \ + return PositiveInfinity(); \ + if (x == NegativeInfinity()) \ return 0.0; \ } #else @@ -516,7 +516,7 @@ js_math_max(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - double maxval = NegativeInfinity(); + double maxval = NegativeInfinity(); for (unsigned i = 0; i < args.length(); i++) { double x; if (!ToNumber(cx, args[i], &x)) @@ -534,7 +534,7 @@ js_math_min(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - double minval = PositiveInfinity(); + double minval = PositiveInfinity(); for (unsigned i = 0; i < args.length(); i++) { double x; if (!ToNumber(cx, args[i], &x)) @@ -594,7 +594,7 @@ js::ecmaPow(double x, double y) * check for NaN since a comparison with NaN is always false. */ int32_t yi; - if (DoubleEqualsInt32(y, &yi)) + if (NumberEqualsInt32(y, &yi)) return powi(x, yi); /* @@ -746,7 +746,7 @@ double js::math_round_impl(double x) { int32_t i; - if (DoubleIsInt32(x, &i)) + if (NumberIsInt32(x, &i)) return double(i); /* Some numbers are so big that adding 0.5 would give the wrong number. */ @@ -1255,7 +1255,7 @@ js::ecmaHypot(double x, double y) * is NaN, not Infinity. */ if (mozilla::IsInfinite(x) || mozilla::IsInfinite(y)) { - return mozilla::PositiveInfinity(); + return mozilla::PositiveInfinity(); } #endif return hypot(x, y); @@ -1304,7 +1304,7 @@ js::math_hypot(JSContext *cx, unsigned argc, Value *vp) } } - double result = isInfinite ? PositiveInfinity() : + double result = isInfinite ? PositiveInfinity() : isNaN ? GenericNaN() : scale * sqrt(sumsq); args.rval().setNumber(result); diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 75d22a3ebe1..33cc9bd2b97 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -41,7 +41,7 @@ using namespace js; using namespace js::types; using mozilla::Abs; -using mozilla::MinDoubleValue; +using mozilla::MinNumberValue; using mozilla::NegativeInfinity; using mozilla::PodCopy; using mozilla::PositiveInfinity; @@ -1132,10 +1132,10 @@ js::InitRuntimeNumberState(JSRuntime *rt) */ number_constants[NC_NaN].dval = GenericNaN(); - number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity(); - number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity(); + number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity(); + number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity(); - number_constants[NC_MIN_VALUE].dval = MinDoubleValue(); + number_constants[NC_MIN_VALUE].dval = MinNumberValue(); // XXX If EXPOSE_INTL_API becomes true all the time at some point, // js::InitRuntimeNumberState is no longer fallible, and we should @@ -1263,7 +1263,7 @@ FracNumberToCString(ThreadSafeContext *cx, ToCStringBuf *cbuf, double d, int bas #ifdef DEBUG { int32_t _; - JS_ASSERT(!mozilla::DoubleIsInt32(d, &_)); + JS_ASSERT(!mozilla::NumberIsInt32(d, &_)); } #endif @@ -1292,7 +1292,7 @@ js::NumberToCString(JSContext *cx, ToCStringBuf *cbuf, double d, int base/* = 10 { int32_t i; size_t len; - return mozilla::DoubleIsInt32(d, &i) + return mozilla::NumberIsInt32(d, &i) ? Int32ToCString(cbuf, i, &len, base) : FracNumberToCString(cx, cbuf, d, base); } @@ -1317,7 +1317,7 @@ js_NumberToStringWithBase(ThreadSafeContext *cx, double d, int base) : nullptr; int32_t i; - if (mozilla::DoubleIsInt32(d, &i)) { + if (mozilla::NumberIsInt32(d, &i)) { if (base == 10 && StaticStrings::hasInt(i)) return cx->staticStrings().getInt(i); if (unsigned(i) < unsigned(base)) { @@ -1378,7 +1378,7 @@ JSAtom * js::NumberToAtom(ExclusiveContext *cx, double d) { int32_t si; - if (mozilla::DoubleIsInt32(d, &si)) + if (mozilla::NumberIsInt32(d, &si)) return Int32ToAtom(cx, si); if (JSFlatString *str = LookupDtoaCache(cx, d)) @@ -1782,7 +1782,7 @@ js_strtod(ThreadSafeContext *cx, const jschar *s, const jschar *send, if ((negative = (*istr == '-')) != 0 || *istr == '+') istr++; if (*istr == 'I' && !strncmp(istr, "Infinity", 8)) { - d = negative ? NegativeInfinity() : PositiveInfinity(); + d = negative ? NegativeInfinity() : PositiveInfinity(); estr = istr + 8; } else { int err; diff --git a/js/src/jsnum.h b/js/src/jsnum.h index 6d8967b7d40..87b88b53724 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -200,7 +200,7 @@ ValueFitsInInt32(const Value &v, int32_t *pi) *pi = v.toInt32(); return true; } - return v.isDouble() && mozilla::DoubleIsInt32(v.toDouble(), pi); + return v.isDouble() && mozilla::NumberIsInt32(v.toDouble(), pi); } /* @@ -221,7 +221,7 @@ IsDefinitelyIndex(const Value &v, uint32_t *indexp) } int32_t i; - if (v.isDouble() && mozilla::DoubleIsInt32(v.toDouble(), &i) && i >= 0) { + if (v.isDouble() && mozilla::NumberIsInt32(v.toDouble(), &i) && i >= 0) { *indexp = uint32_t(i); return true; } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 4394886f10e..b632f348a7f 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -86,7 +86,7 @@ using namespace js; using namespace js::cli; using mozilla::ArrayLength; -using mozilla::DoubleEqualsInt32; +using mozilla::NumberEqualsInt32; using mozilla::Maybe; using mozilla::PodCopy; @@ -563,7 +563,7 @@ Version(JSContext *cx, unsigned argc, jsval *vp) } else if (args[0].isDouble()) { double fv = args[0].toDouble(); int32_t fvi; - if (DoubleEqualsInt32(fv, &fvi)) + if (NumberEqualsInt32(fv, &fvi)) v = fvi; } if (v < 0 || v > JSVERSION_LATEST) { diff --git a/js/src/vm/DateTime.cpp b/js/src/vm/DateTime.cpp index 104ffe42914..8344bdf5399 100644 --- a/js/src/vm/DateTime.cpp +++ b/js/src/vm/DateTime.cpp @@ -164,7 +164,7 @@ js::DateTimeInfo::DateTimeInfo() { // Set to a totally impossible TZA so that the comparison above will fail // and all fields will be properly initialized. - localTZA_ = UnspecifiedNaN(); + localTZA_ = UnspecifiedNaN(); updateTimeZoneAdjustment(); } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 0eef6e802ad..13ca941dd76 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -57,7 +57,7 @@ using namespace js::gc; using namespace js::types; using mozilla::DebugOnly; -using mozilla::DoubleEqualsInt32; +using mozilla::NumberEqualsInt32; using mozilla::PodCopy; using JS::ForOfIterator; @@ -2840,8 +2840,8 @@ CASE(JSOP_TABLESWITCH) if (rref.isInt32()) { i = rref.toInt32(); } else { - /* Use mozilla::DoubleEqualsInt32 to treat -0 (double) as 0. */ - if (!rref.isDouble() || !DoubleEqualsInt32(rref.toDouble(), &i)) + /* Use mozilla::NumberEqualsInt32 to treat -0 (double) as 0. */ + if (!rref.isDouble() || !NumberEqualsInt32(rref.toDouble(), &i)) ADVANCE_AND_DISPATCH(len); } diff --git a/js/src/vm/NumericConversions.h b/js/src/vm/NumericConversions.h index 2ac7d1d2141..03f0e2b8214 100644 --- a/js/src/vm/NumericConversions.h +++ b/js/src/vm/NumericConversions.h @@ -39,12 +39,13 @@ ToUintWidth(double d) "ResultType must be an unsigned type"); uint64_t bits = mozilla::BitwiseCast(d); + unsigned DoubleExponentShift = mozilla::FloatingPoint::ExponentShift; // Extract the exponent component. (Be careful here! It's not technically // the exponent in NaN, infinities, and subnormals.) int_fast16_t exp = - int_fast16_t((bits & mozilla::DoubleExponentBits) >> mozilla::DoubleExponentShift) - - int_fast16_t(mozilla::DoubleExponentBias); + int_fast16_t((bits & mozilla::FloatingPoint::ExponentBits) >> DoubleExponentShift) - + int_fast16_t(mozilla::FloatingPoint::ExponentBias); // If the exponent's less than zero, abs(d) < 1, so the result is 0. (This // also handles subnormals.) @@ -60,7 +61,7 @@ ToUintWidth(double d) // 2**84 + 2**32. Thus if ResultType is int32_t, an exponent >= 84 implies // floor(abs(d)) == 0 mod 2**32.) Return 0 in all these cases. const size_t ResultWidth = CHAR_BIT * sizeof(ResultType); - if (exponent >= mozilla::DoubleExponentShift + ResultWidth) + if (exponent >= DoubleExponentShift + ResultWidth) return 0; // The significand contains the bits that will determine the final result. @@ -68,9 +69,9 @@ ToUintWidth(double d) // locations in the unsigned binary representation of floor(abs(d)). static_assert(sizeof(ResultType) <= sizeof(uint64_t), "Left-shifting below would lose upper bits"); - ResultType result = (exponent > mozilla::DoubleExponentShift) - ? ResultType(bits << (exponent - mozilla::DoubleExponentShift)) - : ResultType(bits >> (mozilla::DoubleExponentShift - exponent)); + ResultType result = (exponent > DoubleExponentShift) + ? ResultType(bits << (exponent - DoubleExponentShift)) + : ResultType(bits >> (DoubleExponentShift - exponent)); // Two further complications remain. First, |result| may contain bogus // sign/exponent bits. Second, IEEE-754 numbers' significands (excluding @@ -103,7 +104,7 @@ ToUintWidth(double d) } // Compute the congruent value in the signed range. - return (bits & mozilla::DoubleSignBit) ? ~result + 1 : result; + return (bits & mozilla::FloatingPoint::SignBit) ? ~result + 1 : result; } template diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index c3c62d74e63..22724d81731 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -245,8 +245,8 @@ JSRuntime::JSRuntime(JSRuntime *parentRuntime, JSUseHelperThreads useHelperThrea #endif scriptAndCountsVector(nullptr), NaNValue(DoubleNaNValue()), - negativeInfinityValue(DoubleValue(NegativeInfinity())), - positiveInfinityValue(DoubleValue(PositiveInfinity())), + negativeInfinityValue(DoubleValue(NegativeInfinity())), + positiveInfinityValue(DoubleValue(PositiveInfinity())), emptyString(nullptr), debugMode(false), spsProfiler(thisFromCtor()),