Backing out changeset 043ea4ef249c to try to fix failed mochitests on Windows and Linux

This commit is contained in:
Robert O'Callahan 2008-08-26 01:06:15 +12:00
parent 2b4f50f46f
commit 5c0b889677
5 changed files with 90 additions and 82 deletions

View File

@ -1,4 +1,3 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/****************************************************************
*
* The author of this software is David M. Gay.
@ -142,6 +141,11 @@
* floating-point numbers and flushes underflows to zero rather
* than implementing gradual underflow, then you must also #define
* Sudden_Underflow.
* #define YES_ALIAS to permit aliasing certain double values with
* arrays of ULongs. This leads to slightly better code with
* some compilers and was always used prior to 19990916, but it
* is not strictly legal and can cause trouble with aggressively
* optimizing compilers (e.g., gcc 2.95.1 under -O2).
* #define USE_LOCALE to use the current locale's decimal_point value.
* #define SET_INEXACT if IEEE arithmetic is being used and extra
* computation should be done to set the inexact flag when the
@ -273,13 +277,24 @@ Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
typedef union { double d; ULong L[2]; } U;
#define dval(x) ((x).d)
#ifdef YES_ALIAS
#define dval(x) x
#ifdef IEEE_8087
#define word0(x) ((x).L[1])
#define word1(x) ((x).L[0])
#define word0(x) ((ULong *)&x)[1]
#define word1(x) ((ULong *)&x)[0]
#else
#define word0(x) ((x).L[0])
#define word1(x) ((x).L[1])
#define word0(x) ((ULong *)&x)[0]
#define word1(x) ((ULong *)&x)[1]
#endif
#else
#ifdef IEEE_8087
#define word0(x) ((U*)&x)->L[1]
#define word1(x) ((U*)&x)->L[0]
#else
#define word0(x) ((U*)&x)->L[0]
#define word1(x) ((U*)&x)->L[1]
#endif
#define dval(x) ((U*)&x)->d
#endif
/* The following definition of Storeinc is appropriate for MIPS processors.
@ -1088,13 +1103,13 @@ diff
static double
ulp
#ifdef KR_headers
(x) U x;
(x) double x;
#else
(U x)
(double x)
#endif
{
register Long L;
U a;
double a;
L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
#ifndef Avoid_Underflow
@ -1137,7 +1152,7 @@ b2d
{
ULong *xa, *xa0, w, y, z;
int k;
U d;
double d;
#ifdef VAX
ULong d0, d1;
#else
@ -1200,9 +1215,9 @@ b2d
static Bigint *
d2b
#ifdef KR_headers
(d, e, bits) U d; int *e, *bits;
(d, e, bits) double d; int *e, *bits;
#else
(U d, int *e, int *bits)
(double d, int *e, int *bits)
#endif
{
Bigint *b;
@ -1343,7 +1358,7 @@ ratio
(Bigint *a, Bigint *b)
#endif
{
U da, db;
double da, db;
int k, ka, kb;
dval(da) = b2d(a, &ka);
@ -1448,9 +1463,9 @@ match
static void
hexnan
#ifdef KR_headers
(rvp, sp) U *rvp; CONST char **sp;
(rvp, sp) double *rvp; CONST char **sp;
#else
(U *rvp, CONST char **sp)
(double *rvp, CONST char **sp)
#endif
{
ULong c, x[2];
@ -1530,8 +1545,7 @@ _strtod
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
CONST char *s, *s0, *s1;
double aadj, adj;
U aadj1, rv, rv0;
double aadj, aadj1, adj, rv, rv0;
Long L;
ULong y, z;
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
@ -1948,7 +1962,7 @@ _strtod
for(;;) {
bd = Balloc(bd0->k);
Bcopy(bd, bd0);
bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */
bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
bs = i2b(1);
if (e >= 0) {
@ -2065,13 +2079,13 @@ _strtod
if ((word0(rv) & Exp_mask) <=
P*Exp_msk1) {
word0(rv) += P*Exp_msk1;
dval(rv) += adj*ulp(rv);
dval(rv) += adj*ulp(dval(rv));
word0(rv) -= P*Exp_msk1;
}
else
#endif /*Sudden_Underflow*/
#endif /*Avoid_Underflow*/
dval(rv) += adj*ulp(rv);
dval(rv) += adj*ulp(dval(rv));
}
break;
}
@ -2094,7 +2108,7 @@ _strtod
#ifdef Sudden_Underflow
if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
word0(rv) += P*Exp_msk1;
adj *= ulp(rv);
adj *= ulp(dval(rv));
if (dsign)
dval(rv) += adj;
else
@ -2104,7 +2118,7 @@ _strtod
}
#endif /*Sudden_Underflow*/
#endif /*Avoid_Underflow*/
adj *= ulp(rv);
adj *= ulp(dval(rv));
if (dsign)
dval(rv) += adj;
else
@ -2213,10 +2227,10 @@ _strtod
break;
#endif
if (dsign)
dval(rv) += ulp(rv);
dval(rv) += ulp(dval(rv));
#ifndef ROUND_BIASED
else {
dval(rv) -= ulp(rv);
dval(rv) -= ulp(dval(rv));
#ifndef Sudden_Underflow
if (!dval(rv))
goto undfl;
@ -2230,14 +2244,14 @@ _strtod
}
if ((aadj = ratio(delta, bs)) <= 2.) {
if (dsign)
aadj = dval(aadj1) = 1.;
aadj = aadj1 = 1.;
else if (word1(rv) || word0(rv) & Bndry_mask) {
#ifndef Sudden_Underflow
if (word1(rv) == Tiny1 && !word0(rv))
goto undfl;
#endif
aadj = 1.;
dval(aadj1) = -1.;
aadj1 = -1.;
}
else {
/* special case -- power of FLT_RADIX to be */
@ -2247,24 +2261,24 @@ _strtod
aadj = 1./FLT_RADIX;
else
aadj *= 0.5;
dval(aadj1) = -aadj;
aadj1 = -aadj;
}
}
else {
aadj *= 0.5;
dval(aadj1) = dsign ? aadj : -aadj;
aadj1 = dsign ? aadj : -aadj;
#ifdef Check_FLT_ROUNDS
switch(Rounding) {
case 2: /* towards +infinity */
dval(aadj1) -= 0.5;
aadj1 -= 0.5;
break;
case 0: /* towards 0 */
case 3: /* towards -infinity */
dval(aadj1) += 0.5;
aadj1 += 0.5;
}
#else
if (Flt_Rounds == 0)
dval(aadj1) += 0.5;
aadj1 += 0.5;
#endif /*Check_FLT_ROUNDS*/
}
y = word0(rv) & Exp_mask;
@ -2274,7 +2288,7 @@ _strtod
if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
dval(rv0) = dval(rv);
word0(rv) -= P*Exp_msk1;
adj = dval(aadj1) * ulp(rv);
adj = aadj1 * ulp(dval(rv));
dval(rv) += adj;
if ((word0(rv) & Exp_mask) >=
Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
@ -2294,18 +2308,18 @@ _strtod
if ((z = (ULong) aadj) <= 0)
z = 1;
aadj = z;
dval(aadj1) = dsign ? aadj : -aadj;
aadj1 = dsign ? aadj : -aadj;
}
word0(aadj1) += (2*P+1)*Exp_msk1 - y;
}
adj = dval(aadj1) * ulp(rv);
adj = aadj1 * ulp(dval(rv));
dval(rv) += adj;
#else
#ifdef Sudden_Underflow
if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
dval(rv0) = dval(rv);
word0(rv) += P*Exp_msk1;
adj = dval(aadj1) * ulp(rv);
adj = aadj1 * ulp(dval(rv));
dval(rv) += adj;
#ifdef IBM
if ((word0(rv) & Exp_mask) < P*Exp_msk1)
@ -2324,7 +2338,7 @@ _strtod
word0(rv) -= P*Exp_msk1;
}
else {
adj = dval(aadj1) * ulp(rv);
adj = aadj1 * ulp(dval(rv));
dval(rv) += adj;
}
#else /*Sudden_Underflow*/
@ -2336,11 +2350,11 @@ _strtod
* example: 1.2e-307 .
*/
if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
dval(aadj1) = (double)(int)(aadj + 0.5);
aadj1 = (double)(int)(aadj + 0.5);
if (!dsign)
dval(aadj1) = -dval(aadj1);
aadj1 = -aadj1;
}
adj = dval(aadj1) * ulp(rv);
adj = aadj1 * ulp(dval(rv));
dval(rv) += adj;
#endif /*Sudden_Underflow*/
#endif /*Avoid_Underflow*/
@ -2632,9 +2646,9 @@ freedtoa(char *s)
dtoa
#ifdef KR_headers
(d, mode, ndigits, decpt, sign, rve)
U d; int mode, ndigits, *decpt, *sign; char **rve;
double d; int mode, ndigits, *decpt, *sign; char **rve;
#else
(U d, int mode, int ndigits, int *decpt, int *sign, char **rve)
(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
{
/* Arguments ndigits, decpt, sign are similar to those
@ -2680,8 +2694,7 @@ dtoa
ULong x;
#endif
Bigint *b, *b1, *delta, *mlo, *mhi, *S;
U d2, eps;
double ds;
double d2, ds, eps;
char *s, *s0;
#ifdef Honor_FLT_ROUNDS
int rounding;
@ -2748,7 +2761,7 @@ dtoa
}
#endif
b = d2b(d, &be, &bbits);
b = d2b(dval(d), &be, &bbits);
#ifdef Sudden_Underflow
i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
#else

View File

@ -1361,12 +1361,10 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
js_InitDateClass(cx, obj);
}
#define CLASP(name) (&js_##name##Class)
#define EXT_CLASP(name) (&js_##name##Class.base)
#define CLASP(name) ((JSClass *)&js_##name##Class)
#define EAGER_ATOM(name) ATOM_OFFSET(name), NULL
#define EAGER_CLASS_ATOM(name) CLASS_ATOM_OFFSET(name), NULL
#define EAGER_ATOM_AND_CLASP(name) EAGER_CLASS_ATOM(name), CLASP(name)
#define EAGER_ATOM_AND_EXT_CLASP(name) EAGER_CLASS_ATOM(name), EXT_CLASP(name)
#define LAZY_ATOM(name) ATOM_OFFSET(lazy.name), js_##name##_str
typedef struct JSStdName {
@ -1417,8 +1415,8 @@ static JSStdName standard_class_atoms[] = {
#endif
#if JS_HAS_XML_SUPPORT
{js_InitXMLClass, EAGER_ATOM_AND_CLASP(XML)},
{js_InitNamespaceClass, EAGER_ATOM_AND_EXT_CLASP(Namespace)},
{js_InitQNameClass, EAGER_ATOM_AND_EXT_CLASP(QName)},
{js_InitNamespaceClass, EAGER_ATOM_AND_CLASP(Namespace)},
{js_InitQNameClass, EAGER_ATOM_AND_CLASP(QName)},
#endif
#if JS_HAS_FILE_OBJECT
{js_InitFileClass, EAGER_ATOM_AND_CLASP(File)},

View File

@ -510,7 +510,9 @@ js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp)
if (unlocked)
JS_LOCK_GC(rt);
cx = (JSContext *) (cx ? cx->links.next : rt->contextList.next);
if (!cx)
cx = (JSContext *)&rt->contextList;
cx = (JSContext *)cx->links.next;
if (&cx->links == &rt->contextList)
cx = NULL;
*iterp = cx;

View File

@ -86,7 +86,7 @@ FindTrap(JSRuntime *rt, JSScript *script, jsbytecode *pc)
JSTrap *trap;
for (trap = (JSTrap *)rt->trapList.next;
&trap->links != &rt->trapList;
trap != (JSTrap *)&rt->trapList;
trap = (JSTrap *)trap->links.next) {
if (trap->script == script && trap->pc == pc)
return trap;
@ -105,8 +105,7 @@ js_UntrapScriptCode(JSContext *cx, JSScript *script)
rt = cx->runtime;
DBG_LOCK(rt);
for (trap = (JSTrap *)rt->trapList.next;
&trap->links !=
&rt->trapList;
trap != (JSTrap *)&rt->trapList;
trap = (JSTrap *)trap->links.next) {
if (trap->script == script &&
(size_t)(trap->pc - script->code) < script->length) {
@ -241,7 +240,7 @@ JS_ClearScriptTraps(JSContext *cx, JSScript *script)
rt = cx->runtime;
DBG_LOCK(rt);
for (trap = (JSTrap *)rt->trapList.next;
&trap->links != &rt->trapList;
trap != (JSTrap *)&rt->trapList;
trap = next) {
next = (JSTrap *)trap->links.next;
if (trap->script == script) {
@ -265,7 +264,7 @@ JS_ClearAllTraps(JSContext *cx)
rt = cx->runtime;
DBG_LOCK(rt);
for (trap = (JSTrap *)rt->trapList.next;
&trap->links != &rt->trapList;
trap != (JSTrap *)&rt->trapList;
trap = next) {
next = (JSTrap *)trap->links.next;
sample = rt->debuggerMutations;
@ -431,7 +430,7 @@ js_TraceWatchPoints(JSTracer *trc, JSObject *obj)
rt = trc->context->runtime;
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = (JSWatchPoint *)wp->links.next) {
if (wp->object == obj) {
TRACE_SCOPE_PROPERTY(trc, wp->sprop);
@ -455,7 +454,7 @@ js_SweepWatchPoints(JSContext *cx)
rt = cx->runtime;
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = next) {
next = (JSWatchPoint *)wp->links.next;
if (js_IsAboutToBeFinalized(cx, wp->object)) {
@ -482,7 +481,7 @@ FindWatchPoint(JSRuntime *rt, JSScope *scope, jsid id)
JSWatchPoint *wp;
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = (JSWatchPoint *)wp->links.next) {
if (wp->object == scope->object && wp->sprop->id == id)
return wp;
@ -518,7 +517,7 @@ js_GetWatchedSetter(JSRuntime *rt, JSScope *scope,
if (scope)
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = (JSWatchPoint *)wp->links.next) {
if ((!scope || wp->object == scope->object) && wp->sprop == sprop) {
setter = wp->setter;
@ -543,7 +542,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
rt = cx->runtime;
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = (JSWatchPoint *)wp->links.next) {
sprop = wp->sprop;
if (wp->object == obj && SPROP_USERID(sprop) == id &&
@ -861,7 +860,7 @@ JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsval id,
rt = cx->runtime;
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = (JSWatchPoint *)wp->links.next) {
if (wp->object == obj && SPROP_USERID(wp->sprop) == id) {
if (handlerp)
@ -889,7 +888,7 @@ JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj)
rt = cx->runtime;
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = next) {
next = (JSWatchPoint *)wp->links.next;
if (wp->object == obj) {
@ -915,7 +914,7 @@ JS_ClearAllWatchPoints(JSContext *cx)
rt = cx->runtime;
DBG_LOCK(rt);
for (wp = (JSWatchPoint *)rt->watchPointList.next;
&wp->links != &rt->watchPointList;
wp != (JSWatchPoint *)&rt->watchPointList;
wp = next) {
next = (JSWatchPoint *)wp->links.next;
sample = rt->debuggerMutations;

View File

@ -139,9 +139,8 @@ JS_strtod(const char *s00, char **se, int *err)
}
JS_FRIEND_API(char *)
JS_dtostr(char *buffer, size_t bufferSize, JSDToStrMode mode, int precision, double dinput)
JS_dtostr(char *buffer, size_t bufferSize, JSDToStrMode mode, int precision, double d)
{
U d;
int decPt; /* Offset of decimal point from first digit */
int sign; /* Nonzero if the sign bit was set in d */
int nDigits; /* Number of significand digits returned by js_dtoa */
@ -156,11 +155,10 @@ JS_dtostr(char *buffer, size_t bufferSize, JSDToStrMode mode, int precision, dou
* Change mode here rather than below because the buffer may not be large
* enough to hold a large integer.
*/
if (mode == DTOSTR_FIXED && (dinput >= 1e21 || dinput <= -1e21))
if (mode == DTOSTR_FIXED && (d >= 1e21 || d <= -1e21))
mode = DTOSTR_STANDARD;
LOCK_DTOA();
dval(d) = dinput;
numBegin = dtoa(d, dtoaModes[mode], precision, &decPt, &sign, &numEnd);
if (!numBegin) {
UNLOCK_DTOA();
@ -354,30 +352,28 @@ static uint32 quorem2(Bigint *b, int32 k)
#define BASEDIGIT(digit) ((char)(((digit) >= 10) ? 'a' - 10 + (digit) : '0' + (digit)))
JS_FRIEND_API(char *)
JS_dtobasestr(int base, double dinput)
JS_dtobasestr(int base, double d)
{
U d;
char *buffer; /* The output string */
char *p; /* Pointer to current position in the buffer */
char *pInt; /* Pointer to the beginning of the integer part of the string */
char *q;
uint32 digit;
U di; /* d truncated to an integer */
U df; /* The fractional part of d */
double di; /* d truncated to an integer */
double df; /* The fractional part of d */
JS_ASSERT(base >= 2 && base <= 36);
dval(d) = dinput;
buffer = (char*) malloc(DTOBASESTR_BUFFER_SIZE);
if (buffer) {
p = buffer;
if (dval(d) < 0.0
if (d < 0.0
#if defined(XP_WIN) || defined(XP_OS2)
&& !((word0(d) & Exp_mask) == Exp_mask && ((word0(d) & Frac_mask) || word1(d))) /* Visual C++ doesn't know how to compare against NaN */
#endif
) {
*p++ = '-';
dval(d) = -dval(d);
d = -d;
}
/* Check for Infinity and NaN */
@ -389,9 +385,9 @@ JS_dtobasestr(int base, double dinput)
LOCK_DTOA();
/* Output the integer part of d with the digits in reverse order. */
pInt = p;
dval(di) = fd_floor(dval(d));
if (dval(di) <= 4294967295.0) {
uint32 n = (uint32)dval(di);
di = fd_floor(d);
if (di <= 4294967295.0) {
uint32 n = (uint32)di;
if (n)
do {
uint32 m = n / base;
@ -430,8 +426,8 @@ JS_dtobasestr(int base, double dinput)
*q-- = ch;
}
dval(df) = dval(d) - dval(di);
if (dval(df) != 0.0) {
df = d - di;
if (df != 0.0) {
/* We have a fraction. */
int e, bbits;
int32 s2, done;