[JAEGER] Added JSOP_BITXOR.

This commit is contained in:
David Anderson 2010-06-05 15:27:56 -07:00
parent 15bafd4e40
commit 7c6f4d702b
4 changed files with 34 additions and 3 deletions

View File

@ -360,6 +360,7 @@ mjit::Compiler::generateMethod()
frame.dup2(); frame.dup2();
END_CASE(JSOP_DUP2) END_CASE(JSOP_DUP2)
BEGIN_CASE(JSOP_BITXOR)
BEGIN_CASE(JSOP_BITAND) BEGIN_CASE(JSOP_BITAND)
jsop_bitop(op); jsop_bitop(op);
END_CASE(JSOP_BITAND) END_CASE(JSOP_BITAND)

View File

@ -780,6 +780,19 @@ stubs::BitAnd(VMFrame &f)
f.regs.sp[-2].setInt32(i); f.regs.sp[-2].setInt32(i);
} }
void JS_FASTCALL
stubs::BitXor(VMFrame &f)
{
int32_t i, j;
if (!ValueToECMAInt32(f.cx, f.regs.sp[-2], &i) ||
!ValueToECMAInt32(f.cx, f.regs.sp[-1], &j)) {
THROW();
}
i = i ^ j;
f.regs.sp[-2].setInt32(i);
}
void JS_FASTCALL void JS_FASTCALL
stubs::Lsh(VMFrame &f) stubs::Lsh(VMFrame &f)
{ {

View File

@ -74,6 +74,7 @@ JSBool JS_FASTCALL Equal(VMFrame &f);
JSBool JS_FASTCALL NotEqual(VMFrame &f); JSBool JS_FASTCALL NotEqual(VMFrame &f);
void JS_FASTCALL BitAnd(VMFrame &f); void JS_FASTCALL BitAnd(VMFrame &f);
void JS_FASTCALL BitXor(VMFrame &f);
void JS_FASTCALL Lsh(VMFrame &f); void JS_FASTCALL Lsh(VMFrame &f);
void JS_FASTCALL Rsh(VMFrame &f); void JS_FASTCALL Rsh(VMFrame &f);
void JS_FASTCALL Add(VMFrame &f); void JS_FASTCALL Add(VMFrame &f);

View File

@ -77,6 +77,9 @@ mjit::Compiler::jsop_bitop(JSOp op)
case JSOP_BITAND: case JSOP_BITAND:
stub = stubs::BitAnd; stub = stubs::BitAnd;
break; break;
case JSOP_BITXOR:
stub = stubs::BitXor;
break;
case JSOP_LSH: case JSOP_LSH:
stub = stubs::Lsh; stub = stubs::Lsh;
break; break;
@ -124,6 +127,9 @@ mjit::Compiler::jsop_bitop(JSOp op)
frame.popn(2); frame.popn(2);
switch (op) { switch (op) {
case JSOP_BITXOR:
frame.push(Int32Tag(L ^ R));
break;
case JSOP_BITAND: case JSOP_BITAND:
frame.push(Int32Tag(L & R)); frame.push(Int32Tag(L & R));
return; return;
@ -141,6 +147,7 @@ mjit::Compiler::jsop_bitop(JSOp op)
RegisterID reg; RegisterID reg;
switch (op) { switch (op) {
case JSOP_BITXOR:
case JSOP_BITAND: case JSOP_BITAND:
{ {
/* Commutative, and we're guaranteed both are ints. */ /* Commutative, and we're guaranteed both are ints. */
@ -153,12 +160,21 @@ mjit::Compiler::jsop_bitop(JSOp op)
reg = frame.ownRegForData(lhs); reg = frame.ownRegForData(lhs);
if (rhs->isConstant()) { if (rhs->isConstant()) {
masm.and32(Imm32(rhs->getValue().asInt32()), reg); if (op == JSOP_BITAND)
masm.and32(Imm32(rhs->getValue().asInt32()), reg);
else if (op == JSOP_BITXOR)
masm.xor32(Imm32(rhs->getValue().asInt32()), reg);
} else if (frame.shouldAvoidDataRemat(rhs)) { } else if (frame.shouldAvoidDataRemat(rhs)) {
masm.and32(masm.payloadOf(frame.addressOf(rhs)), reg); if (op == JSOP_BITAND)
masm.and32(masm.payloadOf(frame.addressOf(rhs)), reg);
else if (op == JSOP_BITXOR)
masm.xor32(masm.payloadOf(frame.addressOf(rhs)), reg);
} else { } else {
RegisterID rhsReg = frame.tempRegForData(rhs); RegisterID rhsReg = frame.tempRegForData(rhs);
masm.and32(rhsReg, reg); if (op == JSOP_BITAND)
masm.and32(rhsReg, reg);
else if (op == JSOP_BITXOR)
masm.xor32(rhsReg, reg);
} }
break; break;