[JAEGER] Added JSOP_BITXOR.
authorDavid Anderson <danderson@mozilla.com>
Sat, 05 Jun 2010 15:27:56 -0700
changeset 52718 2ee44fdce7d232da7b694e141353cd8d66f15fd7
parent 52717 5d4331d3edb69bc618522218d6d043c5c344a2cc
child 52719 ab27317264a4d0b7c507fb58678a3eef44d60e20
push idunknown
push userunknown
push dateunknown
milestone1.9.3a5pre
[JAEGER] Added JSOP_BITXOR.
js/src/methodjit/Compiler.cpp
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
js/src/methodjit/nunbox/FastOps.cpp
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -355,16 +355,17 @@ mjit::Compiler::generateMethod()
           BEGIN_CASE(JSOP_DUP)
             frame.dup();
           END_CASE(JSOP_DUP)
 
           BEGIN_CASE(JSOP_DUP2)
             frame.dup2();
           END_CASE(JSOP_DUP2)
 
+          BEGIN_CASE(JSOP_BITXOR)
           BEGIN_CASE(JSOP_BITAND)
             jsop_bitop(op);
           END_CASE(JSOP_BITAND)
 
           BEGIN_CASE(JSOP_LT)
           BEGIN_CASE(JSOP_LE)
           BEGIN_CASE(JSOP_GT)
           BEGIN_CASE(JSOP_GE)
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -776,16 +776,29 @@ stubs::BitAnd(VMFrame &f)
         !ValueToECMAInt32(f.cx, f.regs.sp[-1], &j)) {
         THROW();
     }
     i = i & j;
     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)
 {
     int32_t i, j;
     if (!ValueToECMAInt32(f.cx, f.regs.sp[-2], &i))
         THROW();
     if (!ValueToECMAInt32(f.cx, f.regs.sp[-1], &j))
         THROW();
     i = i << (j & 31);
--- a/js/src/methodjit/StubCalls.h
+++ b/js/src/methodjit/StubCalls.h
@@ -69,16 +69,17 @@ void JS_FASTCALL IncVp(VMFrame &f, Value
 JSBool JS_FASTCALL LessThan(VMFrame &f);
 JSBool JS_FASTCALL LessEqual(VMFrame &f);
 JSBool JS_FASTCALL GreaterThan(VMFrame &f);
 JSBool JS_FASTCALL GreaterEqual(VMFrame &f);
 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);
 void JS_FASTCALL Sub(VMFrame &f);
 void JS_FASTCALL Mul(VMFrame &f);
 void JS_FASTCALL Div(VMFrame &f);
 void JS_FASTCALL Mod(VMFrame &f);
 void JS_FASTCALL Neg(VMFrame &f);
--- a/js/src/methodjit/nunbox/FastOps.cpp
+++ b/js/src/methodjit/nunbox/FastOps.cpp
@@ -72,16 +72,19 @@ mjit::Compiler::jsop_bitop(JSOp op)
     FrameEntry *rhs = frame.peek(-1);
     FrameEntry *lhs = frame.peek(-2);
 
     VoidStub stub;
     switch (op) {
       case JSOP_BITAND:
         stub = stubs::BitAnd;
         break;
+      case JSOP_BITXOR:
+        stub = stubs::BitXor;
+        break;
       case JSOP_LSH:
         stub = stubs::Lsh;
         break;
       case JSOP_RSH:
         stub = stubs::Rsh;
         break;
       default:
         JS_NOT_REACHED("wat");
@@ -119,16 +122,19 @@ mjit::Compiler::jsop_bitop(JSOp op)
     }
 
     if (lhs->isConstant() && rhs->isConstant()) {
         int32 L = lhs->getValue().asInt32();
         int32 R = rhs->getValue().asInt32();
 
         frame.popn(2);
         switch (op) {
+          case JSOP_BITXOR:
+            frame.push(Int32Tag(L ^ R));
+            break;
           case JSOP_BITAND:
             frame.push(Int32Tag(L & R));
             return;
           case JSOP_LSH:
             frame.push(Int32Tag(L << R));
             return;
           case JSOP_RSH:
             frame.push(Int32Tag(L >> R));
@@ -136,34 +142,44 @@ mjit::Compiler::jsop_bitop(JSOp op)
           default:
             JS_NOT_REACHED("say wat");
         }
     }
 
     RegisterID reg;
 
     switch (op) {
+      case JSOP_BITXOR:
       case JSOP_BITAND:
       {
         /* Commutative, and we're guaranteed both are ints. */
         if (lhs->isConstant()) {
             JS_ASSERT(!rhs->isConstant());
             FrameEntry *temp = rhs;
             rhs = lhs;
             lhs = temp;
         }
 
         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;
       }
 
       case JSOP_LSH:
       case JSOP_RSH:
       {