Fine-tune the instructions on the method invocation path.
1) Initialize the register and out sizes for callee methods through
constant moves.
2) Eliminate an unnecessary load of Dalvik PC for chained and
native callees.
Improved method invocation performance by ~3%.
Change-Id: Iead1276eed0ba527e82eb876f08d169ab9b496b2
diff --git a/vm/compiler/codegen/arm/CodegenDriver.c b/vm/compiler/codegen/arm/CodegenDriver.c
index 2d92d88..d90050b 100644
--- a/vm/compiler/codegen/arm/CodegenDriver.c
+++ b/vm/compiler/codegen/arm/CodegenDriver.c
@@ -1062,16 +1062,21 @@
ArmLIR *retChainingCell = &labelList[bb->fallThrough->id];
/* r1 = &retChainingCell */
- dvmCompilerLockTemp(cUnit, r1);
ArmLIR *addrRetChain = opRegRegImm(cUnit, kOpAdd, r1, rpc, 0);
+
/* r4PC = dalvikCallsite */
loadConstant(cUnit, r4PC,
(int) (cUnit->method->insns + mir->offset));
addrRetChain->generic.target = (LIR *) retChainingCell;
+
+ /* r7 = calleeMethod->registersSize */
+ loadConstant(cUnit, r7, calleeMethod->registersSize);
/*
* r0 = calleeMethod (loaded upon calling genInvokeSingletonCommon)
* r1 = &ChainingCell
+ * r2 = calleeMethod->outsSize (to be loaded later for Java callees)
* r4PC = callsiteDPC
+ * r7 = calleeMethod->registersSize
*/
if (dvmIsNativeMethod(calleeMethod)) {
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_NATIVE);
@@ -1079,6 +1084,8 @@
gDvmJit.invokeNative++;
#endif
} else {
+ /* For Java callees, set up r2 to be calleeMethod->outsSize */
+ loadConstant(cUnit, r2, calleeMethod->outsSize);
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_CHAIN);
#if defined(WITH_JIT_TUNING)
gDvmJit.invokeMonomorphic++;