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 ldr r3, [rGLUE, #offGlue_methodClassDex] @ r3<- pDvmDex 14 FETCH(r1, 1) @ r1<- BBBB 15 ldr r3, [r3, #offDvmDex_pResClasses] @ r3<- pDvmDex->pResClasses 16 ldr r0, [r3, r1, lsl #2] @ r0<- resolved class 17 EXPORT_PC() @ req'd for init, resolve, alloc 18 cmp r0, #0 @ already resolved? 19 beq .L${opcode}_resolve @ no, resolve it now 20 .L${opcode}_resolved: @ r0=class 21 ldrb r1, [r0, #offClassObject_status] @ r1<- ClassStatus enum 22 cmp r1, #CLASS_INITIALIZED @ has class been initialized? 23 bne .L${opcode}_needinit @ no, init class now 24 .L${opcode}_initialized: @ r0=class 25 mov r1, #ALLOC_DONT_TRACK @ flags for alloc call 26 bl dvmAllocObject @ r0<- new object 27 b .L${opcode}_finish @ continue 28 %break 29 30 .balign 32 @ minimize cache lines 31 .L${opcode}_finish: @ r0=new object 32 mov r3, rINST, lsr #8 @ r3<- AA 33 cmp r0, #0 @ failed? 34 beq common_exceptionThrown @ yes, handle the exception 35 FETCH_ADVANCE_INST(2) @ advance rPC, load rINST 36 GET_INST_OPCODE(ip) @ extract opcode from rINST 37 SET_VREG(r0, r3) @ vAA<- r0 38 GOTO_OPCODE(ip) @ jump to next instruction 39 40 /* 41 * Class initialization required. 42 * 43 * r0 holds class object 44 */ 45 .L${opcode}_needinit: 46 mov r9, r0 @ save r0 47 bl dvmInitClass @ initialize class 48 cmp r0, #0 @ check boolean result 49 mov r0, r9 @ restore r0 50 bne .L${opcode}_initialized @ success, continue 51 b common_exceptionThrown @ failed, deal with init exception 52 53 /* 54 * Resolution required. This is the least-likely path. 55 * 56 * r1 holds BBBB 57 */ 58 .L${opcode}_resolve: 59 ldr r3, [rGLUE, #offGlue_method] @ r3<- glue->method 60 mov r2, #0 @ r2<- false 61 ldr r0, [r3, #offMethod_clazz] @ r0<- method->clazz 62 bl dvmResolveClass @ r0<- resolved ClassObject ptr 63 cmp r0, #0 @ got null? 64 bne .L${opcode}_resolved @ no, continue 65 b common_exceptionThrown @ yes, handle exception 66 67 .LstrInstantiationErrorPtr: 68 .word .LstrInstantiationError 69