mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
[INFER] Add overflow check for Math.pow(1, x), bug 642154. r=bhackett
This commit is contained in:
parent
db525548f6
commit
ae5397c993
16
js/src/jit-test/tests/basic/bug642154.js
Normal file
16
js/src/jit-test/tests/basic/bug642154.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
assertEq(Math.pow(1, undefined), NaN);
|
||||||
|
assertEq(Math.pow(1, null), 1);
|
||||||
|
assertEq(Math.pow(1, true), 1);
|
||||||
|
assertEq(Math.pow(1, false), 1);
|
||||||
|
assertEq(Math.pow(1, 0), 1);
|
||||||
|
assertEq(Math.pow(1, -0), 1);
|
||||||
|
assertEq(Math.pow(1, NaN), NaN);
|
||||||
|
assertEq(Math.pow(1, {}), NaN);
|
||||||
|
assertEq(Math.pow(1, {valueOf: function() { return undefined; }}), NaN);
|
||||||
|
|
||||||
|
x = 2.2;
|
||||||
|
assertEq(Math.pow(x - 1.2, undefined), NaN);
|
||||||
|
|
||||||
|
var y;
|
||||||
|
assertEq(Math.pow(1, y), NaN);
|
||||||
|
|
@ -504,7 +504,7 @@ math_pow(JSContext *cx, uintN argc, Value *vp)
|
|||||||
*/
|
*/
|
||||||
if (!JSDOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0)) {
|
if (!JSDOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0)) {
|
||||||
vp->setDouble(js_NaN);
|
vp->setDouble(js_NaN);
|
||||||
return JS_TRUE;
|
return vp[3].isDouble() || cx->markTypeCallerOverflow();
|
||||||
}
|
}
|
||||||
/* pow(x, +-0) is always 1, even for x = NaN. */
|
/* pow(x, +-0) is always 1, even for x = NaN. */
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user