mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 720941 - Remove JSDOUBLE_COMPARE (and DOUBLE_COMPARE, outside SpiderMonkey), as tinderbox's Windows compilers seem not to need it any more. r=dmandelin
--HG-- extra : rebase_source : 1ee5ff83329ef22e6ea471f5a06815bafa45f345
This commit is contained in:
parent
0f5a015dd3
commit
6f2cbe7a02
@ -2124,13 +2124,6 @@ public:
|
|||||||
DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK}}
|
DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK}}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
|
||||||
#define DOUBLE_COMPARE(LVAL, OP, RVAL) \
|
|
||||||
(!DOUBLE_IS_NaN(LVAL) && !DOUBLE_IS_NaN(RVAL) && (LVAL) OP (RVAL))
|
|
||||||
#else
|
|
||||||
#define DOUBLE_COMPARE(LVAL, OP, RVAL) ((LVAL) OP (RVAL))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In the following helper macros we exploit the fact that the result of a
|
* In the following helper macros we exploit the fact that the result of a
|
||||||
* series of additions will not be finite if any one of the operands in the
|
* series of additions will not be finite if any one of the operands in the
|
||||||
|
@ -119,7 +119,7 @@ RelationalExpr::compareResults(txIEvalContext* aContext, txAExprResult* aLeft,
|
|||||||
rtype == txAExprResult::NUMBER) {
|
rtype == txAExprResult::NUMBER) {
|
||||||
double lval = aLeft->numberValue();
|
double lval = aLeft->numberValue();
|
||||||
double rval = aRight->numberValue();
|
double rval = aRight->numberValue();
|
||||||
result = DOUBLE_COMPARE(lval, ==, rval);
|
result = (lval == rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise compare as strings. Try to use the stringobject in
|
// Otherwise compare as strings. Try to use the stringobject in
|
||||||
@ -154,19 +154,19 @@ RelationalExpr::compareResults(txIEvalContext* aContext, txAExprResult* aLeft,
|
|||||||
switch (mOp) {
|
switch (mOp) {
|
||||||
case LESS_THAN:
|
case LESS_THAN:
|
||||||
{
|
{
|
||||||
return DOUBLE_COMPARE(leftDbl, <, rightDbl);
|
return (leftDbl < rightDbl);
|
||||||
}
|
}
|
||||||
case LESS_OR_EQUAL:
|
case LESS_OR_EQUAL:
|
||||||
{
|
{
|
||||||
return DOUBLE_COMPARE(leftDbl, <=, rightDbl);
|
return (leftDbl <= rightDbl);
|
||||||
}
|
}
|
||||||
case GREATER_THAN:
|
case GREATER_THAN:
|
||||||
{
|
{
|
||||||
return DOUBLE_COMPARE(leftDbl, >, rightDbl);
|
return (leftDbl > rightDbl);
|
||||||
}
|
}
|
||||||
case GREATER_OR_EQUAL:
|
case GREATER_OR_EQUAL:
|
||||||
{
|
{
|
||||||
return DOUBLE_COMPARE(leftDbl, >=, rightDbl);
|
return (leftDbl >= rightDbl);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -824,7 +824,7 @@ js::LooselyEqual(JSContext *cx, const Value &lval, const Value &rval, bool *resu
|
|||||||
|
|
||||||
if (lval.isDouble()) {
|
if (lval.isDouble()) {
|
||||||
double l = lval.toDouble(), r = rval.toDouble();
|
double l = lval.toDouble(), r = rval.toDouble();
|
||||||
*result = JSDOUBLE_COMPARE(l, ==, r, false);
|
*result = (l == r);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,7 +875,7 @@ js::LooselyEqual(JSContext *cx, const Value &lval, const Value &rval, bool *resu
|
|||||||
double l, r;
|
double l, r;
|
||||||
if (!ToNumber(cx, lvalue, &l) || !ToNumber(cx, rvalue, &r))
|
if (!ToNumber(cx, lvalue, &l) || !ToNumber(cx, rvalue, &r))
|
||||||
return false;
|
return false;
|
||||||
*result = JSDOUBLE_COMPARE(l, ==, r, false);
|
*result = (l == r);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,7 +887,7 @@ js::StrictlyEqual(JSContext *cx, const Value &lref, const Value &rref, bool *equ
|
|||||||
if (lval.isString())
|
if (lval.isString())
|
||||||
return EqualStrings(cx, lval.toString(), rval.toString(), equal);
|
return EqualStrings(cx, lval.toString(), rval.toString(), equal);
|
||||||
if (lval.isDouble()) {
|
if (lval.isDouble()) {
|
||||||
*equal = JSDOUBLE_COMPARE(lval.toDouble(), ==, rval.toDouble(), JS_FALSE);
|
*equal = (lval.toDouble() == rval.toDouble());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lval.isObject()) {
|
if (lval.isObject()) {
|
||||||
@ -905,13 +905,13 @@ js::StrictlyEqual(JSContext *cx, const Value &lref, const Value &rref, bool *equ
|
|||||||
if (lval.isDouble() && rval.isInt32()) {
|
if (lval.isDouble() && rval.isInt32()) {
|
||||||
double ld = lval.toDouble();
|
double ld = lval.toDouble();
|
||||||
double rd = rval.toInt32();
|
double rd = rval.toInt32();
|
||||||
*equal = JSDOUBLE_COMPARE(ld, ==, rd, JS_FALSE);
|
*equal = (ld == rd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lval.isInt32() && rval.isDouble()) {
|
if (lval.isInt32() && rval.isDouble()) {
|
||||||
double ld = lval.toInt32();
|
double ld = lval.toInt32();
|
||||||
double rd = rval.toDouble();
|
double rd = rval.toDouble();
|
||||||
*equal = JSDOUBLE_COMPARE(ld, ==, rd, JS_FALSE);
|
*equal = (ld == rd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2325,7 +2325,7 @@ END_CASE(JSOP_CASE)
|
|||||||
double l, r; \
|
double l, r; \
|
||||||
if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r)) \
|
if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r)) \
|
||||||
goto error; \
|
goto error; \
|
||||||
cond = JSDOUBLE_COMPARE(l, OP, r, false); \
|
cond = (l OP r); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
TRY_BRANCH_AFTER_COND(cond, 2); \
|
TRY_BRANCH_AFTER_COND(cond, 2); \
|
||||||
|
@ -129,15 +129,6 @@ JS_HASH_DOUBLE(jsdouble d)
|
|||||||
return u.s.lo ^ u.s.hi;
|
return u.s.lo ^ u.s.hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
|
||||||
#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN) \
|
|
||||||
((JSDOUBLE_IS_NaN(LVAL) || JSDOUBLE_IS_NaN(RVAL)) \
|
|
||||||
? (IFNAN) \
|
|
||||||
: (LVAL) OP (RVAL))
|
|
||||||
#else
|
|
||||||
#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN) ((LVAL) OP (RVAL))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern jsdouble js_NaN;
|
extern jsdouble js_NaN;
|
||||||
extern jsdouble js_PositiveInfinity;
|
extern jsdouble js_PositiveInfinity;
|
||||||
extern jsdouble js_NegativeInfinity;
|
extern jsdouble js_NegativeInfinity;
|
||||||
|
@ -5315,7 +5315,7 @@ js_TestXMLEquality(JSContext *cx, const Value &v1, const Value &v2, JSBool *bp)
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v)
|
d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v)
|
||||||
: JSVAL_TO_DOUBLE(v);
|
: JSVAL_TO_DOUBLE(v);
|
||||||
*bp = JSDOUBLE_COMPARE(d, ==, d2, JS_FALSE);
|
*bp = (d == d2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -525,7 +525,7 @@ template void JS_FASTCALL stubs::DefFun<false>(VMFrame &f, JSFunction *fun);
|
|||||||
double l, r; \
|
double l, r; \
|
||||||
if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r)) \
|
if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r)) \
|
||||||
THROWV(JS_FALSE); \
|
THROWV(JS_FALSE); \
|
||||||
cond = JSDOUBLE_COMPARE(l, OP, r, false); \
|
cond = (l OP r); \
|
||||||
} \
|
} \
|
||||||
regs.sp[-2].setBoolean(cond); \
|
regs.sp[-2].setBoolean(cond); \
|
||||||
return cond; \
|
return cond; \
|
||||||
@ -568,7 +568,7 @@ stubs::Not(VMFrame &f)
|
|||||||
f.regs.sp[-1].setBoolean(b);
|
f.regs.sp[-1].setBoolean(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool EQ, bool IFNAN>
|
template <bool EQ>
|
||||||
static inline bool
|
static inline bool
|
||||||
StubEqualityOp(VMFrame &f)
|
StubEqualityOp(VMFrame &f)
|
||||||
{
|
{
|
||||||
@ -606,9 +606,9 @@ StubEqualityOp(VMFrame &f)
|
|||||||
double l = lval.toDouble();
|
double l = lval.toDouble();
|
||||||
double r = rval.toDouble();
|
double r = rval.toDouble();
|
||||||
if (EQ)
|
if (EQ)
|
||||||
cond = JSDOUBLE_COMPARE(l, ==, r, IFNAN);
|
cond = (l == r);
|
||||||
else
|
else
|
||||||
cond = JSDOUBLE_COMPARE(l, !=, r, IFNAN);
|
cond = (l != r);
|
||||||
} else if (lval.isObject()) {
|
} else if (lval.isObject()) {
|
||||||
JSObject *l = &lval.toObject(), *r = &rval.toObject();
|
JSObject *l = &lval.toObject(), *r = &rval.toObject();
|
||||||
if (JSEqualityOp eq = l->getClass()->ext.equality) {
|
if (JSEqualityOp eq = l->getClass()->ext.equality) {
|
||||||
@ -652,9 +652,9 @@ StubEqualityOp(VMFrame &f)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (EQ)
|
if (EQ)
|
||||||
cond = JSDOUBLE_COMPARE(l, ==, r, false);
|
cond = (l == r);
|
||||||
else
|
else
|
||||||
cond = JSDOUBLE_COMPARE(l, !=, r, true);
|
cond = (l != r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,7 +666,7 @@ StubEqualityOp(VMFrame &f)
|
|||||||
JSBool JS_FASTCALL
|
JSBool JS_FASTCALL
|
||||||
stubs::Equal(VMFrame &f)
|
stubs::Equal(VMFrame &f)
|
||||||
{
|
{
|
||||||
if (!StubEqualityOp<true, false>(f))
|
if (!StubEqualityOp<true>(f))
|
||||||
THROWV(JS_FALSE);
|
THROWV(JS_FALSE);
|
||||||
return f.regs.sp[-2].toBoolean();
|
return f.regs.sp[-2].toBoolean();
|
||||||
}
|
}
|
||||||
@ -674,7 +674,7 @@ stubs::Equal(VMFrame &f)
|
|||||||
JSBool JS_FASTCALL
|
JSBool JS_FASTCALL
|
||||||
stubs::NotEqual(VMFrame &f)
|
stubs::NotEqual(VMFrame &f)
|
||||||
{
|
{
|
||||||
if (!StubEqualityOp<false, true>(f))
|
if (!StubEqualityOp<false>(f))
|
||||||
THROWV(JS_FALSE);
|
THROWV(JS_FALSE);
|
||||||
return f.regs.sp[-2].toBoolean();
|
return f.regs.sp[-2].toBoolean();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user