Demote modulo operations to integer if both args are int (456934, r=brendan).

This commit is contained in:
Andreas Gal
2008-09-24 23:28:56 -07:00
parent b553acac97
commit f6128156c6
3 changed files with 19 additions and 9 deletions

View File

@@ -86,15 +86,13 @@ js_dmod(jsdouble a, jsdouble b)
return r;
}
/*
* Note: Caller is responsible for ensuring that b is not 0, or really bad
* things are going to happen.
*/
jsint FASTCALL
js_imod(jsint a, jsint b)
{
return a % b;
if (a < 0 || b <= 0)
return -1;
int r = a % b;
return r;
}
/* The following boxing/unboxing primitives we can't emit inline because