1 %verify "executed" 2 %verify "negative array length" 3 %verify "allocation fails" 4 /* 5 * Allocate an array of objects, specified with the array class 6 * and a count. 7 * 8 * The verifier guarantees that this is an array class, so we don't 9 * check for it here. 10 */ 11 /* new-array/jumbo vBBBB, vCCCC, class@AAAAAAAA */ 12 FETCH(r2, 1) @ r2<- aaaa (lo) 13 FETCH(r3, 2) @ r3<- AAAA (hi) 14 FETCH(r0, 4) @ r0<- vCCCC 15 orr r2, r2, r3, lsl #16 @ r2<- AAAAaaaa 16 ldr r3, [rSELF, #offThread_methodClassDex] @ r3<- pDvmDex 17 GET_VREG(r1, r0) @ r1<- vCCCC (array length) 18 ldr r3, [r3, #offDvmDex_pResClasses] @ r3<- pDvmDex->pResClasses 19 cmp r1, #0 @ check length 20 ldr r0, [r3, r2, lsl #2] @ r0<- resolved class 21 bmi common_errNegativeArraySize @ negative length, bail - len in r1 22 cmp r0, #0 @ already resolved? 23 EXPORT_PC() @ req'd for resolve, alloc 24 bne .L${opcode}_finish @ resolved, continue 25 b .L${opcode}_resolve @ do resolve now 26 %break 27 28 29 /* 30 * Resolve class. (This is an uncommon case.) 31 * 32 * r1 holds array length 33 * r2 holds class ref AAAAAAAA 34 */ 35 .L${opcode}_resolve: 36 ldr r3, [rSELF, #offThread_method] @ r3<- self->method 37 mov r9, r1 @ r9<- length (save) 38 mov r1, r2 @ r1<- AAAAAAAA 39 mov r2, #0 @ r2<- false 40 ldr r0, [r3, #offMethod_clazz] @ r0<- method->clazz 41 bl dvmResolveClass @ r0<- call(clazz, ref) 42 cmp r0, #0 @ got null? 43 mov r1, r9 @ r1<- length (restore) 44 beq common_exceptionThrown @ yes, handle exception 45 @ fall through to ${opcode}_finish 46 47 /* 48 * Finish allocation. 49 * 50 * r0 holds class 51 * r1 holds array length 52 */ 53 .L${opcode}_finish: 54 mov r2, #ALLOC_DONT_TRACK @ don't track in local refs table 55 bl dvmAllocArrayByClass @ r0<- call(clazz, length, flags) 56 cmp r0, #0 @ failed? 57 FETCH(r2, 3) @ r2<- vBBBB 58 beq common_exceptionThrown @ yes, handle the exception 59 FETCH_ADVANCE_INST(5) @ advance rPC, load rINST 60 GET_INST_OPCODE(ip) @ extract opcode from rINST 61 SET_VREG(r0, r2) @ vBBBB<- r0 62 GOTO_OPCODE(ip) @ jump to next instruction 63