[JAEGER] Constant fold neg on ints better (bug 584838, r=dvander).

This commit is contained in:
Jan De Mooij 2010-08-05 16:09:47 -07:00
parent 2bd80dd548
commit 335c2b44df

View File

@ -703,11 +703,21 @@ mjit::Compiler::generateMethod()
{
FrameEntry *top = frame.peek(-1);
if (top->isConstant() && top->getValue().isPrimitive()) {
double d;
ValueToNumber(cx, top->getValue(), &d);
d = -d;
frame.pop();
frame.push(DoubleValue(d));
if (top->isType(JSVAL_TYPE_INT32) &&
top->getValue().toInt32() != 0 &&
top->getValue().toInt32() != (1 << 31))
{
int32 value = top->getValue().toInt32();
value = -value;
frame.pop();
frame.push(Int32Value(value));
} else {
double d;
ValueToNumber(cx, top->getValue(), &d);
d = -d;
frame.pop();
frame.push(DoubleValue(d));
}
} else {
jsop_neg();
}