1ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng /* 2ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng * For monomorphic callsite, setup the Dalvik frame and return to the 3ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng * Thumb code through the link register to transfer control to the callee 4ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng * method through a dedicated chaining cell. 5ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng */ 6ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng @ r0 = methodToCall, r1 = returnCell, rPC = dalvikCallsite 738329f5678fd7a4879528b02a0ab60322d38a897Ben Cheng @ methodToCall is guaranteed to be non-native 838329f5678fd7a4879528b02a0ab60322d38a897Ben Cheng.LinvokeChain: 9ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldrh r7, [r0, #offMethod_registersSize] @ r7<- methodToCall->regsSize 10ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldrh r2, [r0, #offMethod_outsSize] @ r2<- methodToCall->outsSize 11ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr r9, [rGLUE, #offGlue_interpStackEnd] @ r9<- interpStackEnd 12ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr r8, [rGLUE, #offGlue_pSelfSuspendCount] @ r8<- &suspendCount 13ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng add r3, r1, #1 @ Thumb addr is odd 14ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng SAVEAREA_FROM_FP(r1, rFP) @ r1<- stack save area 15ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng sub r1, r1, r7, lsl #2 @ r1<- newFp (old savearea - regsSize) 16ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng SAVEAREA_FROM_FP(r10, r1) @ r10<- stack save area 17ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng add r12, lr, #2 @ setup the punt-to-interp address 18ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng sub r10, r10, r2, lsl #2 @ r10<- bottom (newsave - outsSize) 197a0bcd0de6c4da6499a088a18d1750e51204c2a6Ben Cheng ldr r8, [r8] @ r8<- suspendCount (int) 20ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng cmp r10, r9 @ bottom < interpStackEnd? 21a62475ecfcc80c58add8f153c9605762dafb8227Ben Cheng bxlo r12 @ return to raise stack overflow excep. 22ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng @ r1 = newFP, r0 = methodToCall, r3 = returnCell, rPC = dalvikCallsite 23ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr r9, [r0, #offMethod_clazz] @ r9<- method->clazz 24ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str rPC, [rFP, #(offStackSaveArea_currentPc - sizeofStackSaveArea)] 25ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str rPC, [r1, #(offStackSaveArea_savedPc - sizeofStackSaveArea)] 26ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr rPC, [r0, #offMethod_insns] @ rPC<- methodToCall->insns 27ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng 28ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng 29ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng @ set up newSaveArea 30ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str rFP, [r1, #(offStackSaveArea_prevFrame - sizeofStackSaveArea)] 31ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str r3, [r1, #(offStackSaveArea_returnAddr - sizeofStackSaveArea)] 32ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str r0, [r1, #(offStackSaveArea_method - sizeofStackSaveArea)] 33ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng cmp r8, #0 @ suspendCount != 0 34ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng bxne r12 @ bail to the interpreter 35ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng 36ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr r3, [r9, #offClassObject_pDvmDex] @ r3<- method->clazz->pDvmDex 37ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng ldr r2, [rGLUE, #offGlue_self] @ r2<- glue->self 38ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng 39ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng @ Update "glue" values for the new method 40ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str r0, [rGLUE, #offGlue_method] @ glue->method = methodToCall 41ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str r3, [rGLUE, #offGlue_methodClassDex] @ glue->methodClassDex = ... 42ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng mov rFP, r1 @ fp = newFp 43ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng str rFP, [r2, #offThread_curFrame] @ self->curFrame = newFp 44ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng 45ba4fc8bfc1bccae048403bd1cea3b869dca61dd7Ben Cheng bx lr @ return to the callee-chaining cell 46