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 GET_GLUE(%ecx) 13 EXPORT_PC() 14 movl offGlue_methodClassDex(%ecx),%ecx # ecx<- pDvmDex 15 movzwl 2(rPC),%eax # eax<- CCCC 16 movl offDvmDex_pResClasses(%ecx),%ecx # ecx<- pDvmDex->pResClasses 17 movl (%ecx,%eax,4),%ecx # ecx<- resolved class 18 movzbl rINST_HI,%eax 19 sarl $$4,%eax # eax<- B 20 GET_VREG(%eax,%eax) # eax<- vB (array length) 21 movzbl rINST_HI,rINST_FULL 22 andb $$0xf,rINST_LO # rINST_FULL<- A 23 testl %eax,%eax 24 js common_errNegativeArraySize # bail 25 testl %ecx,%ecx # already resolved? 26 jne .L${opcode}_finish # yes, fast path 27 jmp .L${opcode}_resolve # resolve now 28%break 29 30 /* 31 * Resolve class. (This is an uncommon case.) 32 * ecx holds class (null here) 33 * eax holds array length (vB) 34 */ 35.L${opcode}_resolve: 36 GET_GLUE(%ecx) 37 SPILL_TMP(%eax) # save array length 38 movl offGlue_method(%ecx),%ecx # ecx<- glue->method 39 movzwl 2(rPC),%eax # eax<- CCCC 40 movl offMethod_clazz(%ecx),%ecx # ecx<- method->clazz 41 movl %eax,OUT_ARG1(%esp) 42 movl $$0,OUT_ARG2(%esp) 43 movl %ecx,OUT_ARG0(%esp) 44 SPILL(rPC) 45 call dvmResolveClass # eax<- call(clazz,ref,flag) 46 UNSPILL(rPC) 47 movl %eax,%ecx 48 UNSPILL_TMP(%eax) 49 testl %ecx,%ecx # successful resolution? 50 je common_exceptionThrown # no, bail. 51# fall through to ${opcode}_finish 52 53 /* 54 * Finish allocation 55 * 56 * ecx holds class 57 * eax holds array length (vB) 58 */ 59.L${opcode}_finish: 60 movl %ecx,OUT_ARG0(%esp) 61 movl %eax,OUT_ARG1(%esp) 62 movl $$ALLOC_DONT_TRACK,OUT_ARG2(%esp) 63 SPILL(rPC) 64 call dvmAllocArrayByClass # eax<- call(clazz,length,flags) 65 UNSPILL(rPC) 66 testl %eax,%eax # failed? 67 je common_exceptionThrown # yup - go handle 68 movl rINST_FULL,%ecx 69 FETCH_INST_WORD(2) 70 SET_VREG(%eax,%ecx) 71 ADVANCE_PC(2) 72 GOTO_NEXT 73