mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 942550: Take care of all particular cases in ecmaPow instead of js_math_pow; r=jandem
This commit is contained in:
parent
0466b1681e
commit
cac8501966
6
js/src/jit-test/tests/ion/bug942550.js
Normal file
6
js/src/jit-test/tests/ion/bug942550.js
Normal file
@ -0,0 +1,6 @@
|
||||
function pow(x,y) {
|
||||
return Math.pow(x,y);
|
||||
}
|
||||
var x = pow(3, -.5);
|
||||
var y = pow(3, -.5);
|
||||
assertEq(x, y);
|
@ -625,9 +625,21 @@ js::ecmaPow(double x, double y)
|
||||
*/
|
||||
if (!IsFinite(y) && (x == 1.0 || x == -1.0))
|
||||
return GenericNaN();
|
||||
|
||||
/* pow(x, +-0) is always 1, even for x = NaN (MSVC gets this wrong). */
|
||||
if (y == 0)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* Special case for square roots. Note that pow(x, 0.5) != sqrt(x)
|
||||
* when x = -0.0, so we have to guard for this.
|
||||
*/
|
||||
if (IsFinite(x) && x != 0.0) {
|
||||
if (y == 0.5)
|
||||
return sqrt(x);
|
||||
if (y == -0.5)
|
||||
return 1.0 / sqrt(x);
|
||||
}
|
||||
return pow(x, y);
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
@ -651,29 +663,7 @@ js_math_pow(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (!ToNumber(cx, args.get(1), &y))
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Special case for square roots. Note that pow(x, 0.5) != sqrt(x)
|
||||
* when x = -0.0, so we have to guard for this.
|
||||
*/
|
||||
if (IsFinite(x) && x != 0.0) {
|
||||
if (y == 0.5) {
|
||||
args.rval().setNumber(sqrt(x));
|
||||
return true;
|
||||
}
|
||||
if (y == -0.5) {
|
||||
args.rval().setNumber(1.0/sqrt(x));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* pow(x, +-0) is always 1, even for x = NaN. */
|
||||
if (y == 0) {
|
||||
args.rval().setInt32(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
double z = ecmaPow(x, y);
|
||||
|
||||
args.rval().setNumber(z);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user