1%default { "isrange":"0", "routine":"NoRange" }
2%verify "executed"
3%verify "unknown method"
4    /*
5     * Handle a direct method call.
6     *
7     * (We could defer the "is 'this' pointer null" test to the common
8     * method invocation code, and use a flag to indicate that static
9     * calls don't count.  If we do this as part of copying the arguments
10     * out we could avoiding loading the first arg twice.)
11     *
12     * for: invoke-direct, invoke-direct/range
13     */
14    /* op vB, {vD, vE, vF, vG, vA}, class@CCCC */
15    /* op {vCCCC..v(CCCC+AA-1)}, meth@BBBB */
16    ldr     r3, [rSELF, #offThread_methodClassDex]    @ r3<- pDvmDex
17    FETCH(r1, 1)                        @ r1<- BBBB
18    ldr     r3, [r3, #offDvmDex_pResMethods]    @ r3<- pDvmDex->pResMethods
19    FETCH(r10, 2)                       @ r10<- GFED or CCCC
20    ldr     r0, [r3, r1, lsl #2]        @ r0<- resolved methodToCall
21    .if     (!$isrange)
22    and     r10, r10, #15               @ r10<- D (or stays CCCC)
23    .endif
24    cmp     r0, #0                      @ already resolved?
25    EXPORT_PC()                         @ must export for invoke
26    GET_VREG(r9, r10)                   @ r9<- "this" ptr
27    beq     .L${opcode}_resolve         @ not resolved, do it now
28.L${opcode}_finish:
29    cmp     r9, #0                      @ null "this" ref?
30    bne     common_invokeMethod${routine}   @ r0=method, r9="this"
31    b       common_errNullObject        @ yes, throw exception
32%break
33
34    /*
35     * On entry:
36     *  r1 = reference (BBBB or CCCC)
37     *  r10 = "this" register
38     */
39.L${opcode}_resolve:
40    ldr     r3, [rSELF, #offThread_method] @ r3<- self->method
41    ldr     r0, [r3, #offMethod_clazz]  @ r0<- method->clazz
42    mov     r2, #METHOD_DIRECT          @ resolver method type
43    bl      dvmResolveMethod            @ r0<- call(clazz, ref, flags)
44    cmp     r0, #0                      @ got null?
45    bne     .L${opcode}_finish          @ no, continue
46    b       common_exceptionThrown      @ yes, handle exception
47