If we see a f2i(UnboxDouble) chain, simplify it to UnboxInt32 which does the conversion internally. This also enables a fastpath to read 31-bit jsval integers from arrays.

This commit is contained in:
Andreas Gal
2008-07-27 14:55:26 -07:00
parent a7c268942d
commit 3d6f674216
3 changed files with 14 additions and 4 deletions

View File

@@ -111,10 +111,7 @@ jsint FASTCALL builtin_UnboxInt32(jsval v)
{
if (JS_LIKELY(JSVAL_IS_INT(v)))
return JSVAL_TO_INT(v);
jsint i;
if (JSVAL_IS_DOUBLE(v) && JSDOUBLE_IS_INT(*JSVAL_TO_DOUBLE(v), i))
return i;
return INT32_ERROR_COOKIE;
return js_DoubleToECMAInt32(*JSVAL_TO_DOUBLE(v));
}
int32 FASTCALL builtin_doubleToInt32(jsdouble d)