OSDN Git Service

Eliminate the chaining cells for direct JNI calls.
authorBen Cheng <bccheng@android.com>
Wed, 22 Dec 2010 20:27:41 +0000 (12:27 -0800)
committerBen Cheng <bccheng@android.com>
Wed, 22 Dec 2010 21:23:49 +0000 (13:23 -0800)
The JNI code is dispatched through TEMPLATE_INVOKE_METHOD_NATIVE, so
having a chaining cell for a non-virtual native call simply wastes
space.

Change-Id: Iaf944f745a0723a7772ea168fb35f79e79b21fae

vm/compiler/Frontend.c

index a44c489..d146e22 100644 (file)
@@ -798,13 +798,16 @@ bool dvmCompileTrace(JitTraceDescription *desc, int numMaxInsts,
         if (curBB->taken == NULL &&
             (isGoto(lastInsn) || isInvoke ||
             (targetOffset != UNKNOWN_TARGET && targetOffset != curOffset))) {
-            BasicBlock *newBB;
+            BasicBlock *newBB = NULL;
             if (isInvoke) {
                 /* Monomorphic callee */
                 if (callee) {
-                    newBB = dvmCompilerNewBB(kChainingCellInvokeSingleton);
-                    newBB->startOffset = 0;
-                    newBB->containingMethod = callee;
+                    /* JNI call doesn't need a chaining cell */
+                    if (!dvmIsNativeMethod(callee)) {
+                        newBB = dvmCompilerNewBB(kChainingCellInvokeSingleton);
+                        newBB->startOffset = 0;
+                        newBB->containingMethod = callee;
+                    }
                 /* Will resolve at runtime */
                 } else {
                     newBB = dvmCompilerNewBB(kChainingCellInvokePredicted);
@@ -830,10 +833,12 @@ bool dvmCompileTrace(JitTraceDescription *desc, int numMaxInsts,
                 newBB->startOffset = targetOffset;
 #endif
             }
-            newBB->id = numBlocks++;
-            curBB->taken = newBB;
-            lastBB->next = newBB;
-            lastBB = newBB;
+            if (newBB) {
+                newBB->id = numBlocks++;
+                curBB->taken = newBB;
+                lastBB->next = newBB;
+                lastBB = newBB;
+            }
         }
     }