Home | History | Annotate | Download | only in x86
      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     SPILL_TMP2(%ebx)
     18     movl      offDvmDex_pResClasses(%ecx),%ecx # ecx<- pDvmDex->pResClasses
     19     EXPORT_PC
     20 #if defined(WITH_JIT)
     21     lea       (%ecx,%eax,4),%ebx        # ebx <- &resolved class
     22 #endif
     23     movl      (%ecx,%eax,4),%ecx        # ecx<- resolved class
     24     testl     %ecx,%ecx                 # resolved?
     25     je        .L${opcode}_resolve       # no, go do it
     26 .L${opcode}_resolved:  # on entry, ecx<- class
     27     cmpb      $$CLASS_INITIALIZED,offClassObject_status(%ecx)
     28     jne       .L${opcode}_needinit
     29 .L${opcode}_initialized:  # on entry, ecx<- class
     30     movl      $$ALLOC_DONT_TRACK,OUT_ARG1(%esp)
     31     movl     %ecx,OUT_ARG0(%esp)
     32     call     dvmAllocObject             # eax<- new object
     33     testl    %eax,%eax                  # success?
     34     je       common_exceptionThrown     # no, bail out
     35 #if defined(WITH_JIT)
     36         /*
     37      * The JIT needs the class to be fully resolved before it can
     38      * include this instruction in a trace.
     39      */
     40     movl    rSELF, %ecx
     41     movl    offThread_subMode(%ecx), %ecx
     42     andl    $$kSubModeJitTraceBuild, %ecx # under construction?
     43     jne     .L${opcode}_jitCheck
     44 #endif
     45 .L${opcode}_end:
     46     UNSPILL_TMP2(%ebx)
     47     SET_VREG %eax rINST
     48     UNSPILL(rIBASE)
     49     FETCH_INST_OPCODE 2 %ecx
     50     ADVANCE_PC 2
     51     GOTO_NEXT_R %ecx
     52 
     53 #if defined(WITH_JIT)
     54     /*
     55      * Check to see if we need to stop the trace building early.
     56      * eax: new object
     57      */
     58 .L${opcode}_jitCheck:
     59     cmp     $$0, (%ebx)                   # okay?
     60     jne     .L${opcode}_end        # yes, finish
     61     SPILL_TMP1(%eax)                     # preserve new object
     62     movl    rSELF, %ecx
     63     movl    %ecx, OUT_ARG0(%esp)
     64     movl    rPC, OUT_ARG1(%esp)
     65     call    dvmJitEndTraceSelect         # (self, pc)
     66     UNSPILL_TMP1(%eax)
     67     UNSPILL_TMP2(%ebx)
     68     SET_VREG %eax rINST                  # vAA <- new object
     69     UNSPILL(rIBASE)
     70     FETCH_INST_OPCODE 2 %ecx
     71     ADVANCE_PC 2
     72     GOTO_NEXT_R %ecx
     73 #endif
     74 
     75     /*
     76      * Class initialization required.
     77      *
     78      *  ecx holds class object
     79      */
     80 .L${opcode}_needinit:
     81     SPILL_TMP1(%ecx)                    # save object
     82     movl    %ecx,OUT_ARG0(%esp)
     83     call    dvmInitClass                # initialize class
     84     UNSPILL_TMP1(%ecx)                  # restore object
     85     testl   %eax,%eax                   # success?
     86     jne     .L${opcode}_initialized     # success, continue
     87     jmp     common_exceptionThrown      # go deal with init exception
     88 
     89     /*
     90      * Resolution required.  This is the least-likely path.
     91      *
     92      */
     93 .L${opcode}_resolve:
     94     movl    rSELF,%ecx
     95     movzwl  2(rPC),%eax
     96     movl    offThread_method(%ecx),%ecx   # ecx<- self->method
     97     movl    %eax,OUT_ARG1(%esp)
     98     movl    offMethod_clazz(%ecx),%ecx  # ecx<- method->clazz
     99     movl    $$0,OUT_ARG2(%esp)
    100     movl    %ecx,OUT_ARG0(%esp)
    101     call    dvmResolveClass             # call(clazz,off,flags)
    102     movl    %eax,%ecx                   # ecx<- resolved ClassObject ptr
    103     testl   %ecx,%ecx                   # success?
    104     jne     .L${opcode}_resolved        # good to go
    105     jmp     common_exceptionThrown      # no, handle exception
    106