Backed out changeset 14c76164f4c2 - patch for bug 524346 caused test fails

This commit is contained in:
Igor Bukanov 2009-10-27 19:21:47 +03:00
parent ed4f6edf7f
commit 8785797ba7
13 changed files with 137 additions and 120 deletions

View File

@ -127,19 +127,19 @@ JS_Now()
JS_PUBLIC_API(jsval)
JS_GetNaNValue(JSContext *cx)
{
return cx->runtime->NaNValue;
return DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
}
JS_PUBLIC_API(jsval)
JS_GetNegativeInfinityValue(JSContext *cx)
{
return cx->runtime->negativeInfinityValue;
return DOUBLE_TO_JSVAL(cx->runtime->jsNegativeInfinity);
}
JS_PUBLIC_API(jsval)
JS_GetPositiveInfinityValue(JSContext *cx)
{
return cx->runtime->positiveInfinityValue;
return DOUBLE_TO_JSVAL(cx->runtime->jsPositiveInfinity);
}
JS_PUBLIC_API(jsval)

View File

@ -1708,11 +1708,11 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, jsva
JS_ASSERT(start == MAXINDEX);
jsval tmp[2] = {JSVAL_NULL, JSVAL_NULL};
JSAutoTempValueRooter tvr(cx, JS_ARRAY_LENGTH(tmp), tmp);
if (!js_NewDoubleInRootedValue(cx, MAXINDEX, &tmp[0]))
jsdouble* dp = js_NewWeaklyRootedDouble(cx, MAXINDEX);
if (!dp)
return JS_FALSE;
jsdouble *dp = JSVAL_TO_DOUBLE(tmp[0]);
JS_ASSERT(*dp == MAXINDEX);
tmp[0] = DOUBLE_TO_JSVAL(dp);
JSAutoTempValueRooter tvr(cx, JS_ARRAY_LENGTH(tmp), tmp);
JSAutoTempIdRooter idr(cx);
do {
tmp[1] = *vector++;

View File

@ -66,6 +66,8 @@
using namespace avmplus;
using namespace nanojit;
extern jsdouble js_NaN;
JS_FRIEND_API(void)
js_SetTraceableNativeFailed(JSContext *cx)
{

View File

@ -533,9 +533,9 @@ struct JSRuntime {
JSSetSlotRequest *setSlotRequests;
/* Well-known numbers held for use by this runtime's contexts. */
jsval NaNValue;
jsval negativeInfinityValue;
jsval positiveInfinityValue;
jsdouble *jsNaN;
jsdouble *jsNegativeInfinity;
jsdouble *jsPositiveInfinity;
#ifdef JS_THREADSAFE
JSLock *deflatedStringCacheLock;

View File

@ -478,7 +478,7 @@ msFromTime(jsdouble t)
#define TIMECLIP(d) ((JSDOUBLE_IS_FINITE(d) \
&& !((d < 0 ? -d : d) > HalfTimeDomain)) \
? js_DoubleToInteger(d + (+0.)) : js_NaN)
? js_DoubleToInteger(d + (+0.)) : *cx->runtime->jsNaN)
/**
* end of ECMA 'support' functions
@ -595,7 +595,7 @@ date_msecFromArgs(JSContext *cx, uintN argc, jsval *argv, jsdouble *rval)
return JS_FALSE;
/* return NaN if any arg is not finite */
if (!JSDOUBLE_IS_FINITE(d)) {
*rval = js_NaN;
*rval = *cx->runtime->jsNaN;
return JS_TRUE;
}
array[loop] = js_DoubleToInteger(d);
@ -1164,16 +1164,16 @@ date_parse(JSContext *cx, uintN argc, jsval *vp)
jsdouble result;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
return true;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
str = js_ValueToString(cx, vp[2]);
if (!str)
return JS_FALSE;
vp[2] = STRING_TO_JSVAL(str);
if (!date_parseString(str, &result)) {
*vp = cx->runtime->NaNValue;
return true;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
result = TIMECLIP(result);
@ -1218,10 +1218,11 @@ SetDateToNaN(JSContext *cx, JSObject *obj, jsval *vp = NULL)
{
JS_ASSERT(OBJ_GET_CLASS(cx, obj) == &js_DateClass);
obj->fslots[JSSLOT_LOCAL_TIME] = cx->runtime->NaNValue;
obj->fslots[JSSLOT_UTC_TIME] = cx->runtime->NaNValue;
jsval nan = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
obj->fslots[JSSLOT_LOCAL_TIME] = nan;
obj->fslots[JSSLOT_UTC_TIME] = nan;
if (vp)
*vp = cx->runtime->NaNValue;
*vp = nan;
}
/*
@ -1232,7 +1233,7 @@ SetUTCTime(JSContext *cx, JSObject *obj, jsdouble t, jsval *vp = NULL)
{
JS_ASSERT(OBJ_GET_CLASS(cx, obj) == &js_DateClass);
obj->fslots[JSSLOT_LOCAL_TIME] = cx->runtime->NaNValue;
obj->fslots[JSSLOT_LOCAL_TIME] = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
if (!js_NewDoubleInRootedValue(cx, t, &obj->fslots[JSSLOT_UTC_TIME]))
return false;
if (vp)
@ -1247,24 +1248,33 @@ SetUTCTime(JSContext *cx, JSObject *obj, jsdouble t, jsval *vp = NULL)
static JSBool
GetAndCacheLocalTime(JSContext *cx, JSObject *obj, jsval *vp, jsdouble *dp)
{
if (!obj || !JS_InstanceOf(cx, obj, &js_DateClass, vp ? vp + 2 : NULL))
return false;
jsval v;
jsdouble result;
jsdouble *cached;
if (!obj || !JS_InstanceOf(cx, obj, &js_DateClass, vp ? vp + 2 : NULL))
return JS_FALSE;
v = obj->fslots[JSSLOT_LOCAL_TIME];
result = *JSVAL_TO_DOUBLE(v);
jsval *slotp = &obj->fslots[JSSLOT_LOCAL_TIME];
jsdouble result = *JSVAL_TO_DOUBLE(*vp);
if (JSDOUBLE_IS_NaN(result)) {
result = *JSVAL_TO_DOUBLE(obj->fslots[JSSLOT_UTC_TIME]);
if (!GetUTCTime(cx, obj, vp, &result))
return JS_FALSE;
/* if result is NaN, it couldn't be finite. */
if (JSDOUBLE_IS_FINITE(result))
result = LocalTime(result);
if (!js_NewDoubleInRootedValue(cx, result, slotp))
return false;
cached = js_NewWeaklyRootedDouble(cx, result);
if (!cached)
return JS_FALSE;
obj->fslots[JSSLOT_LOCAL_TIME] = DOUBLE_TO_JSVAL(cached);
}
*dp = result;
return true;
return JS_TRUE;
}
/*

View File

@ -56,6 +56,8 @@
#include "jslibmath.h"
#include "jsobj.h"
extern jsdouble js_NaN;
#ifndef M_E
#define M_E 2.7182818284590452354
#endif
@ -107,7 +109,7 @@ math_abs(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -123,7 +125,7 @@ math_acos(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -131,7 +133,7 @@ math_acos(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
#if defined(SOLARIS) && defined(__GNUC__)
if (x < -1 || 1 < x) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
#endif
@ -145,7 +147,7 @@ math_asin(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -153,7 +155,7 @@ math_asin(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
#if defined(SOLARIS) && defined(__GNUC__)
if (x < -1 || 1 < x) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
#endif
@ -167,7 +169,7 @@ math_atan(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -213,7 +215,7 @@ math_atan2(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, y;
if (argc <= 1) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -241,7 +243,7 @@ js_math_ceil(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -257,7 +259,7 @@ math_cos(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -273,7 +275,7 @@ math_exp(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -281,11 +283,11 @@ math_exp(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
#ifdef _WIN32
if (!JSDOUBLE_IS_NaN(x)) {
if (x == js_PositiveInfinity) {
*vp = cx->runtime->positiveInfinityValue;
if (x == *cx->runtime->jsPositiveInfinity) {
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsPositiveInfinity);
return JS_TRUE;
}
if (x == js_NegativeInfinity) {
if (x == *cx->runtime->jsNegativeInfinity) {
*vp = JSVAL_ZERO;
return JS_TRUE;
}
@ -301,7 +303,7 @@ js_math_floor(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -317,7 +319,7 @@ math_log(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -325,7 +327,7 @@ math_log(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
#if defined(SOLARIS) && defined(__GNUC__)
if (x < 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
#endif
@ -336,12 +338,12 @@ math_log(JSContext *cx, uintN argc, jsval *vp)
JSBool
js_math_max(JSContext *cx, uintN argc, jsval *vp)
{
jsdouble x, z = js_NegativeInfinity;
jsdouble x, z = *cx->runtime->jsNegativeInfinity;
jsval *argv;
uintN i;
if (argc == 0) {
*vp = cx->runtime->negativeInfinityValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNegativeInfinity);
return JS_TRUE;
}
argv = vp + 2;
@ -350,7 +352,7 @@ js_math_max(JSContext *cx, uintN argc, jsval *vp)
if (JSVAL_IS_NULL(argv[i]))
return JS_FALSE;
if (JSDOUBLE_IS_NaN(x)) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
if (x == 0 && x == z) {
@ -366,12 +368,12 @@ js_math_max(JSContext *cx, uintN argc, jsval *vp)
JSBool
js_math_min(JSContext *cx, uintN argc, jsval *vp)
{
jsdouble x, z = js_PositiveInfinity;
jsdouble x, z = *cx->runtime->jsPositiveInfinity;
jsval *argv;
uintN i;
if (argc == 0) {
*vp = cx->runtime->positiveInfinityValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsPositiveInfinity);
return JS_TRUE;
}
argv = vp + 2;
@ -380,7 +382,7 @@ js_math_min(JSContext *cx, uintN argc, jsval *vp)
if (JSVAL_IS_NULL(argv[i]))
return JS_FALSE;
if (JSDOUBLE_IS_NaN(x)) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
if (x == 0 && x == z) {
@ -399,7 +401,7 @@ math_pow(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, y, z;
if (argc <= 1) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -413,7 +415,7 @@ math_pow(JSContext *cx, uintN argc, jsval *vp)
* we need to wrap the libm call to make it ECMA compliant.
*/
if (!JSDOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0)) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
/* pow(x, +-0) is always 1, even for x = NaN. */
@ -490,7 +492,7 @@ js_math_round(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -506,7 +508,7 @@ math_sin(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -522,7 +524,7 @@ math_sqrt(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -538,7 +540,7 @@ math_tan(JSContext *cx, uintN argc, jsval *vp)
jsdouble x, z;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
x = js_ValueToNumber(cx, &vp[2]);
@ -600,11 +602,13 @@ static jsdouble FASTCALL
math_exp_tn(JSContext *cx, jsdouble d)
{
if (!JSDOUBLE_IS_NaN(d)) {
if (d == js_PositiveInfinity)
return js_PositiveInfinity;
if (d == js_NegativeInfinity)
if (d == *cx->runtime->jsPositiveInfinity) {
return *cx->runtime->jsPositiveInfinity;
}
if (d == *cx->runtime->jsNegativeInfinity) {
return 0.0;
}
}
return exp(d);
}

View File

@ -141,7 +141,7 @@ num_parseFloat(JSContext *cx, uintN argc, jsval *vp)
const jschar *bp, *end, *ep;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
str = js_ValueToString(cx, vp[2]);
@ -151,7 +151,7 @@ num_parseFloat(JSContext *cx, uintN argc, jsval *vp)
if (!js_strtod(cx, bp, end, &ep, &d))
return JS_FALSE;
if (ep == bp) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
return js_NewNumberInRootedValue(cx, d, vp);
@ -183,7 +183,7 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp)
const jschar *bp, *end, *ep;
if (argc == 0) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
if (argc > 1) {
@ -194,7 +194,7 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp)
radix = 0;
}
if (radix != 0 && (radix < 2 || radix > 36)) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
@ -210,7 +210,7 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp)
if (!js_strtointeger(cx, bp, end, &ep, radix, &d))
return JS_FALSE;
if (ep == bp) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
return js_NewNumberInRootedValue(cx, d, vp);
@ -669,8 +669,7 @@ static JSConstDoubleSpec number_constants[] = {
};
jsdouble js_NaN;
jsdouble js_PositiveInfinity;
jsdouble js_NegativeInfinity;
#if (defined __GNUC__ && defined __i386__)
@ -695,37 +694,41 @@ inline void FIX_FPU() {
JSBool
js_InitRuntimeNumberState(JSContext *cx)
{
JS_STATIC_ASSERT(JSVAL_NULL == jsval(0));
JSRuntime *rt;
jsdpun u;
struct lconv *locale;
JSRuntime *rt = cx->runtime;
JS_ASSERT(JSVAL_IS_NULL(rt->NaNValue));
rt = cx->runtime;
JS_ASSERT(!rt->jsNaN);
FIX_FPU();
jsdpun u;
u.s.hi = JSDOUBLE_HI32_EXPMASK | JSDOUBLE_HI32_MANTMASK;
u.s.lo = 0xffffffff;
number_constants[NC_NaN].dval = js_NaN = u.d;
if (!js_NewDoubleInRootedValue(cx, u.d, &rt->NaNValue))
return false;
rt->jsNaN = js_NewWeaklyRootedDouble(cx, js_NaN);
if (!rt->jsNaN)
return JS_FALSE;
u.s.hi = JSDOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000;
number_constants[NC_POSITIVE_INFINITY].dval = js_PositiveInfinity = u.d;
if (!js_NewDoubleInRootedValue(cx, u.d, &rt->positiveInfinityValue))
return false;
number_constants[NC_POSITIVE_INFINITY].dval = u.d;
rt->jsPositiveInfinity = js_NewWeaklyRootedDouble(cx, u.d);
if (!rt->jsPositiveInfinity)
return JS_FALSE;
u.s.hi = JSDOUBLE_HI32_SIGNBIT | JSDOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000;
number_constants[NC_NEGATIVE_INFINITY].dval = js_NegativeInfinity = u.d;
if (!js_NewDoubleInRootedValue(cx, u.d, &rt->negativeInfinityValue))
return false;
number_constants[NC_NEGATIVE_INFINITY].dval = u.d;
rt->jsNegativeInfinity = js_NewWeaklyRootedDouble(cx, u.d);
if (!rt->jsNegativeInfinity)
return JS_FALSE;
u.s.hi = 0;
u.s.lo = 1;
number_constants[NC_MIN_VALUE].dval = u.d;
struct lconv *locale = localeconv();
locale = localeconv();
rt->thousandsSeparator =
JS_strdup(cx, locale->thousands_sep ? locale->thousands_sep : "'");
rt->decimalSeparator =
@ -739,18 +742,15 @@ js_InitRuntimeNumberState(JSContext *cx)
void
js_TraceRuntimeNumberState(JSTracer *trc)
{
JSRuntime *rt = trc->context->runtime;
JSRuntime *rt;
if (!JSVAL_IS_NULL(rt->NaNValue))
JS_CALL_DOUBLE_TRACER(trc, JSVAL_TO_DOUBLE(rt->NaNValue), "NaN");
if (!JSVAL_IS_NULL(rt->positiveInfinityValue)) {
JS_CALL_DOUBLE_TRACER(trc, JSVAL_TO_DOUBLE(rt->positiveInfinityValue),
"+Infinity");
}
if (!JSVAL_IS_NULL(rt->negativeInfinityValue)) {
JS_CALL_DOUBLE_TRACER(trc, JSVAL_TO_DOUBLE(rt->negativeInfinityValue),
"-Infinity");
}
rt = trc->context->runtime;
if (rt->jsNaN)
JS_CALL_DOUBLE_TRACER(trc, rt->jsNaN, "NaN");
if (rt->jsPositiveInfinity)
JS_CALL_DOUBLE_TRACER(trc, rt->jsPositiveInfinity, "+Infinity");
if (rt->jsNegativeInfinity)
JS_CALL_DOUBLE_TRACER(trc, rt->jsNegativeInfinity, "-Infinity");
}
void
@ -758,13 +758,13 @@ js_FinishRuntimeNumberState(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
rt->NaNValue = JSVAL_NULL;
rt->negativeInfinityValue = JSVAL_NULL;
rt->positiveInfinityValue = JSVAL_NULL;
rt->jsNaN = NULL;
rt->jsNegativeInfinity = NULL;
rt->jsPositiveInfinity = NULL;
cx->free((void *) rt->thousandsSeparator);
cx->free((void *) rt->decimalSeparator);
cx->free((void *) rt->numGrouping);
cx->free((void *)rt->thousandsSeparator);
cx->free((void *)rt->decimalSeparator);
cx->free((void *)rt->numGrouping);
rt->thousandsSeparator = rt->decimalSeparator = rt->numGrouping = NULL;
}
@ -790,13 +790,14 @@ js_InitNumberClass(JSContext *cx, JSObject *obj)
/* ECMA 15.1.1.1 */
rt = cx->runtime;
if (!JS_DefineProperty(cx, obj, js_NaN_str, rt->NaNValue,
if (!JS_DefineProperty(cx, obj, js_NaN_str, DOUBLE_TO_JSVAL(rt->jsNaN),
NULL, NULL, JSPROP_PERMANENT)) {
return NULL;
}
/* ECMA 15.1.1.2 */
if (!JS_DefineProperty(cx, obj, js_Infinity_str, rt->positiveInfinityValue,
if (!JS_DefineProperty(cx, obj, js_Infinity_str,
DOUBLE_TO_JSVAL(rt->jsPositiveInfinity),
NULL, NULL, JSPROP_PERMANENT)) {
return NULL;
}
@ -941,7 +942,7 @@ js_ValueToNumber(JSContext *cx, jsval *vp)
jsval v;
JSString *str;
const jschar *bp, *end, *ep;
jsdouble d;
jsdouble d, *dp;
JSObject *obj;
v = *vp;
@ -1019,8 +1020,9 @@ js_ValueToNumber(JSContext *cx, jsval *vp)
break;
}
*vp = cx->runtime->NaNValue;
return js_NaN;
dp = cx->runtime->jsNaN;
*vp = DOUBLE_TO_JSVAL(dp);
return *dp;
}
int32
@ -1191,15 +1193,15 @@ js_strtod(JSContext *cx, const jschar *s, const jschar *send,
if ((negative = (*istr == '-')) != 0 || *istr == '+')
istr++;
if (*istr == 'I' && !strncmp(istr, js_Infinity_str, sizeof js_Infinity_str - 1)) {
d = negative ? js_NegativeInfinity : js_PositiveInfinity;
d = *(negative ? cx->runtime->jsNegativeInfinity : cx->runtime->jsPositiveInfinity);
estr = istr + 8;
} else {
int err;
d = JS_strtod(cstr, &estr, &err);
if (d == HUGE_VAL)
d = js_PositiveInfinity;
d = *cx->runtime->jsPositiveInfinity;
else if (d == -HUGE_VAL)
d = js_NegativeInfinity;
d = *cx->runtime->jsNegativeInfinity;
}
i = estr - cstr;
@ -1334,7 +1336,7 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar *send,
return JS_FALSE;
}
if (err == JS_DTOA_ERANGE && value == HUGE_VAL)
value = js_PositiveInfinity;
value = *cx->runtime->jsPositiveInfinity;
cx->free(cstr);
} else if ((base & (base - 1)) == 0) {
/*

View File

@ -169,8 +169,6 @@ JS_HASH_DOUBLE(jsdouble d)
#endif
extern jsdouble js_NaN;
extern jsdouble js_PositiveInfinity;
extern jsdouble js_NegativeInfinity;
/* Initialize number constants and runtime state for the first context. */
extern JSBool

View File

@ -1095,15 +1095,15 @@ BEGIN_CASE(JSOP_DIV)
#ifdef XP_WIN
/* XXX MSVC miscompiles such that (NaN == 0) */
if (JSDOUBLE_IS_NaN(d2))
rval = rt->NaNValue;
rval = DOUBLE_TO_JSVAL(rt->jsNaN);
else
#endif
if (d == 0 || JSDOUBLE_IS_NaN(d))
rval = rt->NaNValue;
rval = DOUBLE_TO_JSVAL(rt->jsNaN);
else if (JSDOUBLE_IS_NEG(d) != JSDOUBLE_IS_NEG(d2))
rval = rt->negativeInfinityValue;
rval = DOUBLE_TO_JSVAL(rt->jsNegativeInfinity);
else
rval = rt->positiveInfinityValue;
rval = DOUBLE_TO_JSVAL(rt->jsPositiveInfinity);
STORE_OPND(-1, rval);
} else {
d /= d2;
@ -1116,7 +1116,7 @@ BEGIN_CASE(JSOP_MOD)
FETCH_NUMBER(cx, -2, d);
regs.sp--;
if (d2 == 0) {
STORE_OPND(-1, rt->NaNValue);
STORE_OPND(-1, DOUBLE_TO_JSVAL(rt->jsNaN));
} else {
d = js_fmod(d, d2);
STORE_NUMBER(cx, -1, d);

View File

@ -8449,15 +8449,15 @@ FoldBinaryNumeric(JSContext *cx, JSOp op, JSParseNode *pn1, JSParseNode *pn2,
#if defined(XP_WIN)
/* XXX MSVC miscompiles such that (NaN == 0) */
if (JSDOUBLE_IS_NaN(d2))
d = js_NaN;
d = *cx->runtime->jsNaN;
else
#endif
if (d == 0 || JSDOUBLE_IS_NaN(d))
d = js_NaN;
d = *cx->runtime->jsNaN;
else if (JSDOUBLE_IS_NEG(d) != JSDOUBLE_IS_NEG(d2))
d = js_NegativeInfinity;
d = *cx->runtime->jsNegativeInfinity;
else
d = js_PositiveInfinity;
d = *cx->runtime->jsPositiveInfinity;
} else {
d /= d2;
}
@ -8465,7 +8465,7 @@ FoldBinaryNumeric(JSContext *cx, JSOp op, JSParseNode *pn1, JSParseNode *pn2,
case JSOP_MOD:
if (d2 == 0) {
d = js_NaN;
d = *cx->runtime->jsNaN;
} else {
d = js_fmod(d, d2);
}

View File

@ -1004,6 +1004,7 @@ out_of_range:
}
#ifdef JS_TRACER
extern jsdouble js_NaN;
jsdouble FASTCALL
js_String_p_charCodeAt(JSString* str, jsdouble d)

View File

@ -8659,7 +8659,7 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
args[0] = l_ins, args[1] = cx_ins;
l_ins = lir->insCall(&js_BooleanOrUndefinedToNumber_ci, args);
l = (l == JSVAL_VOID)
? cx->runtime->NaNValue
? DOUBLE_TO_JSVAL(cx->runtime->jsNaN)
: INT_TO_JSVAL(l == JSVAL_TRUE);
return equalityHelper(l, r, l_ins, r_ins, negate,
tryBranchAfterCond, rval);
@ -8673,7 +8673,7 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
args[0] = r_ins, args[1] = cx_ins;
r_ins = lir->insCall(&js_BooleanOrUndefinedToNumber_ci, args);
r = (r == JSVAL_VOID)
? cx->runtime->NaNValue
? DOUBLE_TO_JSVAL(cx->runtime->jsNaN)
: INT_TO_JSVAL(r == JSVAL_TRUE);
return equalityHelper(l, r, l_ins, r_ins, negate,
tryBranchAfterCond, rval);

View File

@ -5578,7 +5578,7 @@ xml_childIndex(JSContext *cx, uintN argc, jsval *vp)
NON_LIST_XML_METHOD_PROLOG;
parent = xml->parent;
if (!parent || xml->xml_class == JSXML_CLASS_ATTRIBUTE) {
*vp = cx->runtime->NaNValue;
*vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
for (i = 0, n = JSXML_LENGTH(parent); i < n; i++) {