mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 939843: Required changes in Spidermonkey; r=mjrosenb
--HG-- extra : rebase_source : e629b045dfe460348c339ef0e7d301b67c6799fd
This commit is contained in:
parent
f0e3f0c215
commit
ce02acd7c5
@ -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<double>(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<JS::Value> : public ValueOperations<JS::Heap<JS::Value> >
|
||||
|
||||
bool setNumber(double d) {
|
||||
int32_t i;
|
||||
if (mozilla::DoubleIsInt32(d, &i)) {
|
||||
if (mozilla::NumberIsInt32(d, &i)) {
|
||||
setInt32(i);
|
||||
return true;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<double>();
|
||||
else
|
||||
d = PositiveInfinity();
|
||||
d = PositiveInfinity<double>();
|
||||
} else {
|
||||
d /= d2;
|
||||
}
|
||||
|
@ -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<double>(), field);
|
||||
return m.failName(initNode, "'%s' is not a standard global constant", field);
|
||||
}
|
||||
|
||||
|
@ -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<double>::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<double>(), 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<double>(), temp);
|
||||
masm.branchDouble(Assembler::DoubleGreaterThan, input, temp, ¬neginf);
|
||||
masm.assumeUnreachable("Input shouldn't be -Inf.");
|
||||
masm.bind(¬neginf);
|
||||
|
@ -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);
|
||||
|
@ -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 *
|
||||
|
@ -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>();
|
||||
double conservativeUpper = PositiveInfinity<double>();
|
||||
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);
|
||||
|
@ -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<double>::ExponentShift;
|
||||
|
||||
// Maximum exponent for finite values.
|
||||
static const uint16_t MaxFiniteExponent = mozilla::DoubleExponentBias;
|
||||
static const uint16_t MaxFiniteExponent = mozilla::FloatingPoint<double>::ExponentBias;
|
||||
|
||||
// An special exponent value representing all non-NaN values. This
|
||||
// includes finite values and the infinities.
|
||||
|
@ -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<double>(), ScratchFloatReg);
|
||||
masm.compareDouble(input, ScratchFloatReg);
|
||||
masm.ma_vneg(ScratchFloatReg, output, Assembler::Equal);
|
||||
masm.ma_b(&done, Assembler::Equal);
|
||||
|
@ -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<double>(0, FloatingPoint<double>::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<float>(0, FloatingPoint<float>::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<double>(), ScratchFloatReg);
|
||||
|
||||
Assembler::DoubleCondition cond = Assembler::DoubleNotEqualOrUnordered;
|
||||
if (ins->mir()->operandIsNeverNaN())
|
||||
|
@ -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<double>::ExponentShift - 32;
|
||||
static const uint32_t TOO_BIG_EXPONENT = (FloatingPoint<double>::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<float>::ExponentBits;
|
||||
static const uint32_t EXPONENT_SHIFT = FloatingPoint<float>::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<float>::ExponentBias + 63)
|
||||
<< EXPONENT_SHIFT;
|
||||
|
||||
// Check exponent to avoid fp exceptions.
|
||||
Label failPopFloat;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<double>();
|
||||
return mozilla::PositiveInfinity<double>();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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<double>()) \
|
||||
return PositiveInfinity<double>(); \
|
||||
if (x == NegativeInfinity<double>()) \
|
||||
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<double>();
|
||||
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<double>();
|
||||
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<double>();
|
||||
}
|
||||
#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<double>() :
|
||||
isNaN ? GenericNaN() :
|
||||
scale * sqrt(sumsq);
|
||||
args.rval().setNumber(result);
|
||||
|
@ -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<double>();
|
||||
number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity<double>();
|
||||
|
||||
number_constants[NC_MIN_VALUE].dval = MinDoubleValue();
|
||||
number_constants[NC_MIN_VALUE].dval = MinNumberValue<double>();
|
||||
|
||||
// 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<double>() : PositiveInfinity<double>();
|
||||
estr = istr + 8;
|
||||
} else {
|
||||
int err;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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<double>();
|
||||
updateTimeZoneAdjustment();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,13 @@ ToUintWidth(double d)
|
||||
"ResultType must be an unsigned type");
|
||||
|
||||
uint64_t bits = mozilla::BitwiseCast<uint64_t>(d);
|
||||
unsigned DoubleExponentShift = mozilla::FloatingPoint<double>::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<double>::ExponentBits) >> DoubleExponentShift) -
|
||||
int_fast16_t(mozilla::FloatingPoint<double>::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<double>::SignBit) ? ~result + 1 : result;
|
||||
}
|
||||
|
||||
template<typename ResultType>
|
||||
|
@ -245,8 +245,8 @@ JSRuntime::JSRuntime(JSRuntime *parentRuntime, JSUseHelperThreads useHelperThrea
|
||||
#endif
|
||||
scriptAndCountsVector(nullptr),
|
||||
NaNValue(DoubleNaNValue()),
|
||||
negativeInfinityValue(DoubleValue(NegativeInfinity())),
|
||||
positiveInfinityValue(DoubleValue(PositiveInfinity())),
|
||||
negativeInfinityValue(DoubleValue(NegativeInfinity<double>())),
|
||||
positiveInfinityValue(DoubleValue(PositiveInfinity<double>())),
|
||||
emptyString(nullptr),
|
||||
debugMode(false),
|
||||
spsProfiler(thisFromCtor()),
|
||||
|
Loading…
Reference in New Issue
Block a user