OSDN Git Service

Don't accidentally convert % into /...
authorElliott Hughes <enh@google.com>
Wed, 28 Apr 2010 20:52:02 +0000 (13:52 -0700)
committerElliott Hughes <enh@google.com>
Wed, 28 Apr 2010 21:09:46 +0000 (14:09 -0700)
Fix a JIT bug I introduced the other day by not paying attention to the exact
dalvik opcode being optimized.

Change-Id: Ic0518645a5436e2903c2a34ef46d0205f23d571b

vm/compiler/codegen/arm/CodegenDriver.c

index ef7de28..c691d15 100644 (file)
@@ -1900,9 +1900,12 @@ static int lowestSetBit(unsigned int x) {
 
 // Returns true if it added instructions to 'cUnit' to divide 'rlSrc' by 'lit'
 // and store the result in 'rlDest'.
-static bool handleEasyDivide(CompilationUnit *cUnit,
+static bool handleEasyDivide(CompilationUnit *cUnit, OpCode dalvikOpCode,
                              RegLocation rlSrc, RegLocation rlDest, int lit)
 {
+    if (dalvikOpCode != OP_DIV_INT_LIT8 && dalvikOpCode != OP_DIV_INT_LIT16) {
+        return false;
+    }
     if (lit < 2 || !isPowerOfTwo(lit)) {
         return false;
     }
@@ -2050,7 +2053,7 @@ static bool handleFmt22b_Fmt22s(CompilationUnit *cUnit, MIR *mir)
                 genInterpSingleStep(cUnit, mir);
                 return false;
             }
-            if (handleEasyDivide(cUnit, rlSrc, rlDest, lit)) {
+            if (handleEasyDivide(cUnit, dalvikOpCode, rlSrc, rlDest, lit)) {
                 return false;
             }
             dvmCompilerFlushAllRegs(cUnit);   /* Everything to home location */