1 %default { "isrange":"0", "routine":"NoRange" } 2 %verify "executed" 3 %verify "unknown method" 4 %verify "null object" 5 /* 6 * Handle a virtual method call. 7 * 8 * for: invoke-virtual, invoke-virtual/range 9 */ 10 /* op vB, {vD, vE, vF, vG, vA}, class@CCCC */ 11 /* op vAA, {vCCCC..v(CCCC+AA-1)}, meth@BBBB */ 12 ldr r3, [rSELF, #offThread_methodClassDex] @ r3<- pDvmDex 13 FETCH(r1, 1) @ r1<- BBBB 14 ldr r3, [r3, #offDvmDex_pResMethods] @ r3<- pDvmDex->pResMethods 15 FETCH(r10, 2) @ r10<- GFED or CCCC 16 ldr r0, [r3, r1, lsl #2] @ r0<- resolved baseMethod 17 .if (!$isrange) 18 and r10, r10, #15 @ r10<- D (or stays CCCC) 19 .endif 20 cmp r0, #0 @ already resolved? 21 EXPORT_PC() @ must export for invoke 22 bne .L${opcode}_continue @ yes, continue on 23 ldr r3, [rSELF, #offThread_method] @ r3<- self->method 24 ldr r0, [r3, #offMethod_clazz] @ r0<- method->clazz 25 mov r2, #METHOD_VIRTUAL @ resolver method type 26 bl dvmResolveMethod @ r0<- call(clazz, ref, flags) 27 cmp r0, #0 @ got null? 28 bne .L${opcode}_continue @ no, continue 29 b common_exceptionThrown @ yes, handle exception 30 %break 31 32 /* 33 * At this point: 34 * r0 = resolved base method 35 * r10 = C or CCCC (index of first arg, which is the "this" ptr) 36 */ 37 .L${opcode}_continue: 38 GET_VREG(r9, r10) @ r9<- "this" ptr 39 ldrh r2, [r0, #offMethod_methodIndex] @ r2<- baseMethod->methodIndex 40 cmp r9, #0 @ is "this" null? 41 beq common_errNullObject @ null "this", throw exception 42 ldr r3, [r9, #offObject_clazz] @ r3<- thisPtr->clazz 43 ldr r3, [r3, #offClassObject_vtable] @ r3<- thisPtr->clazz->vtable 44 ldr r0, [r3, r2, lsl #2] @ r3<- vtable[methodIndex] 45 bl common_invokeMethod${routine} @ (r0=method, r9="this") 46