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