From 7c6f4d702b8fe7c25393c1b39f8a7b9f28fa8986 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 5 Jun 2010 15:27:56 -0700 Subject: [PATCH] [JAEGER] Added JSOP_BITXOR. --- js/src/methodjit/Compiler.cpp | 1 + js/src/methodjit/StubCalls.cpp | 13 +++++++++++++ js/src/methodjit/StubCalls.h | 1 + js/src/methodjit/nunbox/FastOps.cpp | 22 +++++++++++++++++++--- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/js/src/methodjit/Compiler.cpp b/js/src/methodjit/Compiler.cpp index 828c2372a6c..b864064e122 100644 --- a/js/src/methodjit/Compiler.cpp +++ b/js/src/methodjit/Compiler.cpp @@ -360,6 +360,7 @@ mjit::Compiler::generateMethod() frame.dup2(); END_CASE(JSOP_DUP2) + BEGIN_CASE(JSOP_BITXOR) BEGIN_CASE(JSOP_BITAND) jsop_bitop(op); END_CASE(JSOP_BITAND) diff --git a/js/src/methodjit/StubCalls.cpp b/js/src/methodjit/StubCalls.cpp index 05292a47052..7dddc6927bb 100644 --- a/js/src/methodjit/StubCalls.cpp +++ b/js/src/methodjit/StubCalls.cpp @@ -780,6 +780,19 @@ stubs::BitAnd(VMFrame &f) 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 stubs::Lsh(VMFrame &f) { diff --git a/js/src/methodjit/StubCalls.h b/js/src/methodjit/StubCalls.h index 43bf4828c2d..b4a1d2d2378 100644 --- a/js/src/methodjit/StubCalls.h +++ b/js/src/methodjit/StubCalls.h @@ -74,6 +74,7 @@ JSBool JS_FASTCALL Equal(VMFrame &f); JSBool JS_FASTCALL NotEqual(VMFrame &f); void JS_FASTCALL BitAnd(VMFrame &f); +void JS_FASTCALL BitXor(VMFrame &f); void JS_FASTCALL Lsh(VMFrame &f); void JS_FASTCALL Rsh(VMFrame &f); void JS_FASTCALL Add(VMFrame &f); diff --git a/js/src/methodjit/nunbox/FastOps.cpp b/js/src/methodjit/nunbox/FastOps.cpp index a71359c770f..0ba9ed1f58c 100644 --- a/js/src/methodjit/nunbox/FastOps.cpp +++ b/js/src/methodjit/nunbox/FastOps.cpp @@ -77,6 +77,9 @@ mjit::Compiler::jsop_bitop(JSOp op) case JSOP_BITAND: stub = stubs::BitAnd; break; + case JSOP_BITXOR: + stub = stubs::BitXor; + break; case JSOP_LSH: stub = stubs::Lsh; break; @@ -124,6 +127,9 @@ mjit::Compiler::jsop_bitop(JSOp op) frame.popn(2); switch (op) { + case JSOP_BITXOR: + frame.push(Int32Tag(L ^ R)); + break; case JSOP_BITAND: frame.push(Int32Tag(L & R)); return; @@ -141,6 +147,7 @@ mjit::Compiler::jsop_bitop(JSOp op) RegisterID reg; switch (op) { + case JSOP_BITXOR: case JSOP_BITAND: { /* Commutative, and we're guaranteed both are ints. */ @@ -153,12 +160,21 @@ mjit::Compiler::jsop_bitop(JSOp op) reg = frame.ownRegForData(lhs); 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)) { - 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 { 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;