[prev in list] [next in list] [prev in thread] [next in thread]
List: mozilla-patches
Subject: javascript floating point patch
From: Hankin <hankin () dunno ! com>
Date: 1998-06-24 20:14:15
[Download RAW message or body]
In JS_DefineConstDoubles it's checking whether the name is 0 to see when
the list of doubles end, the last entry's name needs to be 0.
Also, a computer that I have access to is a PentiumII - BSD v2.2.6, it
has some strict floating point exceptions, doesn't like converting
strange double numbers to int.
["t" (text/plain)]
Index: jsapi.h
===================================================================
RCS file: /cvsroot/mozilla/js/ref/jsapi.h,v
retrieving revision 1.3
diff -r1.3 jsapi.h
82a83,90
> #ifdef BSDI
> #include <limits.h>
> #define DOUBLE_FITS_IN_INT(d) \
> (!(isnan(d) || isinf(d) || d>=INT_MAX || d<=INT_MIN))
> #else
> #define DOUBLE_FITS_IN_INT(d) 1
> #endif
>
Index: jsemit.c
===================================================================
RCS file: /cvsroot/mozilla/js/ref/jsemit.c,v
retrieving revision 1.4
diff -r1.4 jsemit.c
400,409c400,413
< ival = (jsint)dval;
< if (JSDOUBLE_IS_INT(dval, ival) && INT_FITS_IN_JSVAL(ival)) {
< if (ival == 0)
< return js_Emit1(cx, cg, JSOP_ZERO) >= 0;
< if (ival == 1)
< return js_Emit1(cx, cg, JSOP_ONE) >= 0;
< if ((jsuint)ival < (jsuint)ATOM_INDEX_LIMIT) {
< atomIndex = (jsatomid)ival;
< EMIT_ATOM_INDEX_OP(JSOP_UINT16, atomIndex);
< return JS_TRUE;
---
> if(DOUBLE_FITS_IN_INT(dval)) {
> ival = (jsint)dval;
> if (JSDOUBLE_IS_INT(dval, ival) && INT_FITS_IN_JSVAL(ival)) {
> if (ival == 0)
> return js_Emit1(cx, cg, JSOP_ZERO) >= 0;
> if (ival == 1)
> return js_Emit1(cx, cg, JSOP_ONE) >= 0;
> if ((jsuint)ival < (jsuint)ATOM_INDEX_LIMIT) {
> atomIndex = (jsatomid)ival;
> EMIT_ATOM_INDEX_OP(JSOP_UINT16, atomIndex);
> return JS_TRUE;
> }
> atom = js_AtomizeInt(cx, ival, 0);
> goto atom_done;
411,413d414
< atom = js_AtomizeInt(cx, ival, 0);
< } else {
< atom = js_AtomizeDouble(cx, dval, 0);
414a416,417
> atom = js_AtomizeDouble(cx, dval, 0);
> atom_done:;
Index: jsmath.c
===================================================================
RCS file: /cvsroot/mozilla/js/ref/jsmath.c,v
retrieving revision 1.2
diff -r1.2 jsmath.c
71c71
< {0}
---
> {0,NULL}
Index: jsnum.c
===================================================================
RCS file: /cvsroot/mozilla/js/ref/jsnum.c,v
retrieving revision 1.9
diff -r1.9 jsnum.c
279c279
< {0}
---
> {0,NULL}
396,401c396,401
< i = (jsint)d;
< if (JSDOUBLE_IS_INT(d, i) && INT_FITS_IN_JSVAL(i)) {
< *rval = INT_TO_JSVAL(i);
< } else {
< if (!js_NewDoubleValue(cx, d, rval))
< return JS_FALSE;
---
> if(DOUBLE_FITS_IN_INT(d)) {
> i = (jsint)d;
> if (JSDOUBLE_IS_INT(d, i) && INT_FITS_IN_JSVAL(i)) {
> *rval = INT_TO_JSVAL(i);
> }
> return JS_TRUE;
402a403,404
> if (!js_NewDoubleValue(cx, d, rval))
> return JS_FALSE;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic