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 vA, vB, class@CCCC */ 12 movl rSELF,%ecx 13 EXPORT_PC 14 movl offThread_methodClassDex(%ecx),%ecx # ecx<- pDvmDex 15 movzwl 2(rPC),%eax # eax<- CCCC 16 movl offDvmDex_pResClasses(%ecx),%ecx # ecx<- pDvmDex->pResClasses 17 SPILL(rIBASE) 18 movl (%ecx,%eax,4),%ecx # ecx<- resolved class 19 movzbl rINSTbl,%eax 20 sarl $$4,%eax # eax<- B 21 GET_VREG_R %eax %eax # eax<- vB (array length) 22 andb $$0xf,rINSTbl # rINST<- A 23 testl %eax,%eax 24 js common_errNegativeArraySize # bail, passing len in eax 25 testl %ecx,%ecx # already resolved? 26 jne .L${opcode}_finish # yes, fast path 27 /* 28 * Resolve class. (This is an uncommon case.) 29 * ecx holds class (null here) 30 * eax holds array length (vB) 31 */ 32 movl rSELF,%ecx 33 SPILL_TMP1(%eax) # save array length 34 movl offThread_method(%ecx),%ecx # ecx<- self->method 35 movzwl 2(rPC),%eax # eax<- CCCC 36 movl offMethod_clazz(%ecx),%ecx # ecx<- method->clazz 37 movl %eax,OUT_ARG1(%esp) 38 movl $$0,OUT_ARG2(%esp) 39 movl %ecx,OUT_ARG0(%esp) 40 call dvmResolveClass # eax<- call(clazz,ref,flag) 41 movl %eax,%ecx 42 UNSPILL_TMP1(%eax) 43 testl %ecx,%ecx # successful resolution? 44 je common_exceptionThrown # no, bail. 45# fall through to ${opcode}_finish 46 47 /* 48 * Finish allocation 49 * 50 * ecx holds class 51 * eax holds array length (vB) 52 */ 53.L${opcode}_finish: 54 movl %ecx,OUT_ARG0(%esp) 55 movl %eax,OUT_ARG1(%esp) 56 movl $$ALLOC_DONT_TRACK,OUT_ARG2(%esp) 57 call dvmAllocArrayByClass # eax<- call(clazz,length,flags) 58 FETCH_INST_OPCODE 2 %ecx 59 UNSPILL(rIBASE) 60 testl %eax,%eax # failed? 61 je common_exceptionThrown # yup - go handle 62 SET_VREG %eax rINST 63 ADVANCE_PC 2 64 GOTO_NEXT_R %ecx 65