OSDN Git Service

Jit: Support for inline-execute/range [issue 2268232]
authorBill Buzbee <buzbee@google.com>
Fri, 20 Nov 2009 23:41:34 +0000 (15:41 -0800)
committerBill Buzbee <buzbee@google.com>
Mon, 23 Nov 2009 17:57:56 +0000 (09:57 -0800)
tests/082-inline-execute/src/Main.java
vm/compiler/Dataflow.c
vm/compiler/codegen/arm/CodegenDriver.c

index ac2b946..b512091 100644 (file)
@@ -138,8 +138,15 @@ public class Main {
         String sub = offset.substring(3, 13);
         String str32 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
         String str33 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy";
+        String lc = "abcdefg";
+        String uc = "ABCDEFG";
         Object blah = new Object();
 
+        for (int i = 0; i < 100; i++) {
+            String y = lc.toUpperCase();
+            Assert.assertTrue(y.equals(uc));
+        }
+
         Assert.assertEquals(str32.compareTo(str33), -1);
         Assert.assertEquals(str33.compareTo(str32), 1);
 
index d520d84..787ac15 100644 (file)
@@ -747,7 +747,7 @@ int dvmCompilerDataFlowAttributes[kMirOpLast] = {
     DF_FORMAT_35C,
 
     // EF OP_EXECUTE_INLINE_RANGE
-    DF_NOP,
+    DF_FORMAT_3RC,
 
     // F0 OP_INVOKE_DIRECT_EMPTY
     DF_NOP,
index 35460ed..37fd65f 100644 (file)
@@ -3289,15 +3289,14 @@ static bool genInlinedIndexOf(CompilationUnit *cUnit, MIR *mir, bool singleI)
 
 
 /*
- * NOTE: We assume here that the special native inline routines
- * are side-effect free.  By making this assumption, we can safely
- * re-execute the routine from the interpreter if it decides it
- * wants to throw an exception. We still need to EXPORT_PC(), though.
+ * NOTE: Handles both range and non-range versions (arguments
+ * have already been normalized by this point).
  */
-static bool handleFmt3inline(CompilationUnit *cUnit, MIR *mir)
+static bool handleExecuteInline(CompilationUnit *cUnit, MIR *mir)
 {
     DecodedInstruction *dInsn = &mir->dalvikInsn;
     switch( mir->dalvikInsn.opCode) {
+        case OP_EXECUTE_INLINE_RANGE:
         case OP_EXECUTE_INLINE: {
             unsigned int i;
             const InlineOperation* inLineTable = dvmGetInlineOpsTable();
@@ -3370,7 +3369,14 @@ static bool handleFmt3inline(CompilationUnit *cUnit, MIR *mir)
             }
             opReg(cUnit, kOpBlx, r4PC);
             opRegImm(cUnit, kOpAdd, r13, 8);
-            genZeroCheck(cUnit, r0, mir->offset, NULL);
+            opRegImm(cUnit, kOpCmp, r0, 0); /* NULL? */
+            ArmLIR *branchOver = opCondBranch(cUnit, kArmCondNe);
+            loadConstant(cUnit, r0,
+                         (int) (cUnit->method->insns + mir->offset));
+            genDispatchToHandler(cUnit, TEMPLATE_THROW_EXCEPTION_COMMON);
+            ArmLIR *target = newLIR0(cUnit, kArmPseudoTargetLabel);
+            target->defMask = ENCODE_ALL;
+            branchOver->generic.target = (LIR *) target;
             break;
         }
         default:
@@ -3379,13 +3385,6 @@ static bool handleFmt3inline(CompilationUnit *cUnit, MIR *mir)
     return false;
 }
 
-static bool handleFmt3rinline(CompilationUnit *cUnit, MIR *mir)
-{
-    /* For OP_EXECUTE_INLINE_RANGE */
-    genInterpSingleStep(cUnit, mir);
-    return false;
-}
-
 static bool handleFmt51l(CompilationUnit *cUnit, MIR *mir)
 {
     //TUNING: We're using core regs here - not optimal when target is a double
@@ -3955,10 +3954,8 @@ void dvmCompilerMIR2LIR(CompilationUnit *cUnit)
                                                         labelList);
                         break;
                     case kFmt3inline:
-                        notHandled = handleFmt3inline(cUnit, mir);
-                        break;
                     case kFmt3rinline:
-                        notHandled = handleFmt3rinline(cUnit, mir);
+                        notHandled = handleExecuteInline(cUnit, mir);
                         break;
                     case kFmt51l:
                         notHandled = handleFmt51l(cUnit, mir);