Home | History | Annotate | Download | only in mips
      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     LOAD_rSELF_methodClassDex(a3)          #  a3 <- pDvmDex
     14     FETCH(a1, 1)                           #  a1 <- BBBB
     15     LOAD_base_offDvmDex_pResClasses(a3, a3) #  a3 <- pDvmDex->pResClasses
     16     LOAD_eas2(a0, a3, a1)                  #  a0 <- resolved class
     17 #if defined(WITH_JIT)
     18     EAS2(rBIX, a3, a1)                     #  rBIX <- &resolved_class
     19 #endif
     20     EXPORT_PC()                            #  req'd for init, resolve, alloc
     21     # already resolved?
     22     beqz      a0, .L${opcode}_resolve      #  no, resolve it now
     23 .L${opcode}_resolved:                      #  a0=class
     24     lbu       a1, offClassObject_status(a0) #  a1 <- ClassStatus enum
     25     # has class been initialized?
     26     li        t0, CLASS_INITIALIZED
     27     move      rOBJ, a0                     #  save a0
     28     bne       a1, t0, .L${opcode}_needinit #  no, init class now
     29 
     30 .L${opcode}_initialized:                   #  a0=class
     31     LOAD_base_offClassObject_accessFlags(a3, a0) #  a3 <- clazz->accessFlags
     32     li        a1, ALLOC_DONT_TRACK         #  flags for alloc call
     33     # a0=class
     34     JAL(dvmAllocObject)                    #  v0 <- new object
     35     GET_OPA(a3)                            #  a3 <- AA
     36 #if defined(WITH_JIT)
     37     /*
     38      * The JIT needs the class to be fully resolved before it can
     39      * include this instruction in a trace.
     40      */
     41     lhu       a1, offThread_subMode(rSELF)
     42     beqz      v0, common_exceptionThrown   #  yes, handle the exception
     43     and       a1, kSubModeJitTraceBuild    #  under construction?
     44     bnez      a1, .L${opcode}_jitCheck
     45 #else
     46     # failed?
     47     beqz      v0, common_exceptionThrown   #  yes, handle the exception
     48 #endif
     49     b         .L${opcode}_continue
     50 
     51 %break
     52 
     53 .L${opcode}_continue:
     54     FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
     55     GET_INST_OPCODE(t0)                    #  extract opcode from rINST
     56     SET_VREG(v0, a3)                       #  vAA <- v0
     57     GOTO_OPCODE(t0)                        #  jump to next instruction
     58 
     59 #if defined(WITH_JIT)
     60     /*
     61      * Check to see if we need to stop the trace building early.
     62      * v0: new object
     63      * a3: vAA
     64      */
     65 .L${opcode}_jitCheck:
     66     lw        a1, 0(rBIX)                  #  reload resolved class
     67     # okay?
     68     bnez      a1, .L${opcode}_continue     #  yes, finish
     69     move      rOBJ, v0                     #  preserve new object
     70     move      rBIX, a3                     #  preserve vAA
     71     move      a0, rSELF
     72     move      a1, rPC
     73     JAL(dvmJitEndTraceSelect)              #  (self, pc)
     74     FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
     75     GET_INST_OPCODE(t0)                    #  extract opcode from rINST
     76     SET_VREG(rOBJ, rBIX)                   #  vAA <- new object
     77     GOTO_OPCODE(t0)                        #  jump to next instruction
     78 #endif
     79 
     80     /*
     81      * Class initialization required.
     82      *
     83      *  a0 holds class object
     84      */
     85 .L${opcode}_needinit:
     86     JAL(dvmInitClass)                      #  initialize class
     87     move      a0, rOBJ                     #  restore a0
     88     # check boolean result
     89     bnez      v0, .L${opcode}_initialized  #  success, continue
     90     b         common_exceptionThrown       #  failed, deal with init exception
     91 
     92 
     93     /*
     94      * Resolution required.  This is the least-likely path.
     95      *
     96      *  a1 holds BBBB
     97      */
     98 .L${opcode}_resolve:
     99     LOAD_rSELF_method(a3)                  #  a3 <- self->method
    100     li        a2, 0                        #  a2 <- false
    101     LOAD_base_offMethod_clazz(a0, a3)      #  a0 <- method->clazz
    102     JAL(dvmResolveClass)                   #  v0 <- resolved ClassObject ptr
    103     move      a0, v0
    104     # got null?
    105     bnez      v0, .L${opcode}_resolved     #  no, continue
    106     b         common_exceptionThrown       #  yes, handle exception
    107