1%verify "executed"
2%verify "class not resolved"
3%verify "class cannot be resolved"
4%verify "class not initialized"
5%verify "class fails to initialize"
6%verify "class already resolved/initialized"
7%verify "class is abstract or interface"
8%verify "allocation fails"
9    /*
10     * Create a new instance of a class.
11     */
12    /* new-instance vAA, class@BBBB */
13    movl      rSELF,%ecx
14    movzwl    2(rPC),%eax               # eax<- BBBB
15    movl      offThread_methodClassDex(%ecx),%ecx  # ecx<- pDvmDex
16    SPILL(rIBASE)
17    movl      offDvmDex_pResClasses(%ecx),%ecx # ecx<- pDvmDex->pResClasses
18    EXPORT_PC
19    movl      (%ecx,%eax,4),%ecx        # ecx<- resolved class
20    testl     %ecx,%ecx                 # resolved?
21    je        .L${opcode}_resolve       # no, go do it
22.L${opcode}_resolved:  # on entry, ecx<- class
23    cmpb      $$CLASS_INITIALIZED,offClassObject_status(%ecx)
24    jne       .L${opcode}_needinit
25.L${opcode}_initialized:  # on entry, ecx<- class
26    movl      $$ALLOC_DONT_TRACK,OUT_ARG1(%esp)
27    movl     %ecx,OUT_ARG0(%esp)
28    call     dvmAllocObject             # eax<- new object
29    FETCH_INST_OPCODE 2 %ecx
30    UNSPILL(rIBASE)
31    testl    %eax,%eax                  # success?
32    je       common_exceptionThrown     # no, bail out
33    SET_VREG %eax rINST
34    ADVANCE_PC 2
35    GOTO_NEXT_R %ecx
36
37    /*
38     * Class initialization required.
39     *
40     *  ecx holds class object
41     */
42.L${opcode}_needinit:
43    SPILL_TMP1(%ecx)                    # save object
44    movl    %ecx,OUT_ARG0(%esp)
45    call    dvmInitClass                # initialize class
46    UNSPILL_TMP1(%ecx)                  # restore object
47    testl   %eax,%eax                   # success?
48    jne     .L${opcode}_initialized     # success, continue
49    jmp     common_exceptionThrown      # go deal with init exception
50
51    /*
52     * Resolution required.  This is the least-likely path.
53     *
54     */
55.L${opcode}_resolve:
56    movl    rSELF,%ecx
57    movzwl  2(rPC),%eax
58    movl    offThread_method(%ecx),%ecx   # ecx<- self->method
59    movl    %eax,OUT_ARG1(%esp)
60    movl    offMethod_clazz(%ecx),%ecx  # ecx<- method->clazz
61    movl    $$0,OUT_ARG2(%esp)
62    movl    %ecx,OUT_ARG0(%esp)
63    call    dvmResolveClass             # call(clazz,off,flags)
64    movl    %eax,%ecx                   # ecx<- resolved ClassObject ptr
65    testl   %ecx,%ecx                   # success?
66    jne     .L${opcode}_resolved        # good to go
67    jmp     common_exceptionThrown      # no, handle exception
68