mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 580051 - Catch ints-as-doubles in JSOP_TABLESWITCH (r=jorendorff)
This commit is contained in:
parent
890c4cda11
commit
0fd878fe59
@ -4961,11 +4961,11 @@ BEGIN_CASE(JSOP_TABLESWITCH)
|
||||
int32_t i;
|
||||
if (rref.isInt32()) {
|
||||
i = rref.toInt32();
|
||||
} else if (rref.isDouble() && rref.toDouble() == 0) {
|
||||
/* Treat -0 (double) as 0. */
|
||||
i = 0;
|
||||
} else {
|
||||
DO_NEXT_OP(len);
|
||||
double d;
|
||||
/* Don't use JSDOUBLE_IS_INT32; treat -0 (double) as 0. */
|
||||
if (!rref.isDouble() || (d = rref.toDouble()) != (i = int32_t(rref.toDouble())))
|
||||
DO_NEXT_OP(len);
|
||||
}
|
||||
|
||||
pc2 += JUMP_OFFSET_LEN;
|
||||
|
7
js/src/trace-test/tests/basic/testDoubleZeroInSwitch1.js
Normal file
7
js/src/trace-test/tests/basic/testDoubleZeroInSwitch1.js
Normal file
@ -0,0 +1,7 @@
|
||||
var a = Math.sin(Math.PI/2); // spec does not specify precise answer here...
|
||||
if (a === 1) { // ...but if a === 1 here...
|
||||
switch (a) {
|
||||
case 1: break; // ...then it must also match here
|
||||
default: throw "FAIL";
|
||||
}
|
||||
}
|
9
js/src/trace-test/tests/basic/testDoubleZeroInSwitch2.js
Normal file
9
js/src/trace-test/tests/basic/testDoubleZeroInSwitch2.js
Normal file
@ -0,0 +1,9 @@
|
||||
var arr = Float32Array(1);
|
||||
arr[0] = 15;
|
||||
var a = arr[0];
|
||||
assertEq(a, 15);
|
||||
switch (a) {
|
||||
case 15: break;
|
||||
default: throw "FAIL";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user