bug 450392 - fixing -Wstrict-aliasing warnings, r=crowder

This commit is contained in:
Igor Bukanov 2008-08-25 12:33:23 +02:00
Родитель 92b66a1337
Коммит 24b731fa18
5 изменённых файлов: 82 добавлений и 90 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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