Bug 804064 - TableSwitchV, unbox integers values before branching. r=h4writer

This commit is contained in:
Nicolas B. Pierron 2012-10-29 22:28:47 -07:00
parent 755e644afe
commit 7a0380e724
2 changed files with 25 additions and 2 deletions

View File

@ -392,13 +392,18 @@ CodeGenerator::visitTableSwitchV(LTableSwitchV *ins)
Register tag = masm.extractTag(value, index);
masm.branchTestNumber(Assembler::NotEqual, tag, defaultcase);
Label isInt;
masm.branchTestInt32(Assembler::Equal, tag, &isInt);
Label unboxInt, isInt;
masm.branchTestInt32(Assembler::Equal, tag, &unboxInt);
{
FloatRegister floatIndex = ToFloatRegister(ins->tempFloat());
masm.unboxDouble(value, floatIndex);
emitDoubleToInt32(floatIndex, index, defaultcase, false);
masm.jmp(&isInt);
}
masm.bind(&unboxInt);
masm.unboxInt32(value, index);
masm.bind(&isInt);
return emitTableSwitchDispatch(mir, index, ToRegisterOrInvalid(ins->tempPointer()));

View File

@ -0,0 +1,18 @@
function f (v, i) {
var c = v[i];
switch (c) {
case 0:
assertEq(v[i], 0);
break;
case 1:
assertEq(v[i], 1);
break;
default:
if (c == 0 || c == 1)
assertEq(c, false);
}
}
var v = [0, 0.0, 0.1, 1, 1.0, 1.1, null, undefined];
for (var i = 0; i < 100; i++)
f(v, i % v.length);