Move the type level from int/double to number. All traces start out as double in all slots, and denote and promote to/from int as needed. The FuncFilter optimizes on-trace casting and elininates redundant f->i-> chains. More optimization needed on this of course, and this code is now a bit slower than the previous integer-register use. However, this does solve the q += 2.5 issues. The heap access code does not properly cast yet and is likely unstable.
This commit is contained in:
@@ -72,6 +72,9 @@ FASTCALL jsdouble builtin_dmod(jsdouble a, jsdouble b)
|
||||
|
||||
FASTCALL jsval builtin_BoxDouble(JSContext* cx, jsdouble d)
|
||||
{
|
||||
jsint i;
|
||||
if (JSDOUBLE_IS_INT(d, i))
|
||||
return INT_TO_JSVAL(i);
|
||||
if (!cx->doubleFreeList) /* we must be certain the GC won't kick in */
|
||||
return JSVAL_ERROR_COOKIE;
|
||||
jsval v; /* not rooted but ok here because we know GC won't run */
|
||||
@@ -84,9 +87,22 @@ FASTCALL jsval builtin_BoxInt32(JSContext* cx, jsint i)
|
||||
{
|
||||
if (JS_LIKELY(INT_FITS_IN_JSVAL(i)))
|
||||
return INT_TO_JSVAL(i);
|
||||
return builtin_BoxDouble(cx, (jsdouble)i);
|
||||
if (!cx->doubleFreeList) /* we must be certain the GC won't kick in */
|
||||
return JSVAL_ERROR_COOKIE;
|
||||
jsval v; /* not rooted but ok here because we know GC won't run */
|
||||
jsdouble d = (jsdouble)i;
|
||||
if (!js_NewDoubleInRootedValue(cx, d, &v))
|
||||
return JSVAL_ERROR_COOKIE;
|
||||
return v;
|
||||
}
|
||||
|
||||
FASTCALL jsdouble builtin_UnboxDouble(jsval v)
|
||||
{
|
||||
if (JS_LIKELY(JSVAL_IS_INT(v)))
|
||||
return (jsdouble)JSVAL_TO_INT(v);
|
||||
return *JSVAL_TO_DOUBLE(v);
|
||||
}
|
||||
|
||||
FASTCALL jsint builtin_UnboxInt32(jsval v)
|
||||
{
|
||||
if (JS_LIKELY(JSVAL_IS_INT(v)))
|
||||
|
||||
Reference in New Issue
Block a user