From d255a545ce8f7ab1848e6932e7136465e3852b39 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Wed, 22 Dec 2010 12:27:41 -0800 Subject: [PATCH] Eliminate the chaining cells for direct JNI calls. 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 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vm/compiler/Frontend.c b/vm/compiler/Frontend.c index a44c4894e..d146e22c3 100644 --- a/vm/compiler/Frontend.c +++ b/vm/compiler/Frontend.c @@ -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; + } } } -- 2.11.0