OP_FILLED_NEW_ARRAY.S revision 89c1feb0a69a7707b271086e749975b3f7acacf7
1%default { "isrange":"0" } 2%verify "executed" 3%verify "unimplemented array type" 4 /* 5 * Create a new array with elements filled from registers. 6 * 7 * for: filled-new-array, filled-new-array/range 8 */ 9 /* op vB, {vD, vE, vF, vG, vA}, class@CCCC */ 10 /* op {vCCCC..v(CCCC+AA-1)}, type@BBBB */ 11 GET_GLUE(%eax) 12 movzbl rINST_HI,rINST_FULL # rINST_FULL<- AA or BA 13 movl offGlue_methodClassDex(%eax),%eax # eax<- pDvmDex 14 movzwl 2(rPC),%ecx # ecx<- BBBB 15 movl offDvmDex_pResClasses(%eax),%eax # eax<- pDvmDex->pResClasses 16 SPILL(rPC) 17 movl (%eax,%ecx,4),%eax # eax<- resolved class 18 EXPORT_PC() 19 testl %eax,%eax # already resolved? 20 jne .L${opcode}_continue # yes, continue 21 # less frequent path, so we'll redo some work 22 GET_GLUE(%eax) 23 movl $$0,OUT_ARG2(%esp) # arg2<- false 24 movl %ecx,OUT_ARG1(%esp) # arg1<- BBBB 25 movl offGlue_method(%eax),%eax # eax<- glue->method 26 jmp .L${opcode}_more 27%break 28 29.L${opcode}_more: 30 movl offMethod_clazz(%eax),%eax # eax<- method->clazz 31 movl %eax,OUT_ARG0(%esp) # arg0<- clazz 32 call dvmResolveClass # eax<- call(clazz,ref,flag) 33 UNSPILL(rPC) 34 testl %eax,%eax # null? 35 je common_exceptionThrown # yes, handle it 36 37 # note: fall through to .L${opcode}_continue 38 39 /* 40 * On entry: 41 * eax holds array class [r0] 42 * rINST_FULL holds AA or BB [r10] 43 * ecx is scratch 44 * rPC is valid, but has been spilled 45 */ 46.L${opcode}_continue: 47 movl offClassObject_descriptor(%eax),%ecx # ecx<- arrayClass->descriptor 48 movl $$ALLOC_DONT_TRACK,OUT_ARG2(%esp) # arg2<- flags 49 movzbl 1(%ecx),%ecx # ecx<- descriptor[1] 50 movl %ecx,OUT_ARG0(%esp) # arg0<- typeCh 51 cmpb $$'I',%cl # supported? 52 jne .L${opcode}_notimpl # no, not handled yet 53 .if (!$isrange) 54 SPILL_TMP(rINST_FULL) # save copy, need "B" later 55 sarl $$4,rINST_FULL 56 .endif 57 movl rINST_FULL,OUT_ARG1(%esp) # arg1<- A or AA (length) 58 call dvmAllocPrimitiveArray # eax<- call(typeCh, length, flags) 59 UNSPILL(rPC) 60 GET_GLUE(%ecx) 61 testl %eax,%eax # alloc successful? 62 je common_exceptionThrown # no, handle exception 63 movl %eax,offGlue_retval(%ecx) # retval.l<- new array 64 movzwl 4(rPC),%ecx # ecx<- FEDC or CCCC 65 leal offArrayObject_contents(%eax),%eax # eax<- newArray->contents 66 67/* at this point: 68 * eax is pointer to tgt 69 * rINST_FULL is length 70 * ecx is FEDC or CCCC 71 * TMP_SPILL is BA 72 * rPC is valid, but spilled 73 * We now need to copy values from registers into the array 74 */ 75 76 .if $isrange 77 # set up src pointer 78 SPILL(rFP) # esi 79 SPILL(rIBASE) # edi 80 movl %eax,%edi # set up dst ptr 81 leal (rFP,%ecx,4),%esi # set up src ptr 82 movl rINST_FULL,%ecx # load count register 83 FETCH_INST_WORD(3) 84 rep 85 movsd 86 UNSPILL(rIBASE) 87 UNSPILL(rFP) 88 .else 89 testl rINST_FULL,rINST_FULL 90 je 4f 91 UNSPILL_TMP(rPC) 92 andl $$0xf0,rPC # rPC<- 000000B0 93 sall $$12,rPC # rPC<- 000B0000 94 orl %ecx,rPC # rpc<- 000BFEDC 953: 96 movl $$0xf,%ecx 97 andl rPC,%ecx # ecx<- next reg to load 98 GET_VREG(%ecx,%ecx) 99 shrl $$4,rPC 100 leal 4(%eax),%eax 101 movl %ecx,-4(%eax) 102 sub $$1,rINST_FULL 103 jne 3b 1044: 105 UNSPILL(rPC) 106 FETCH_INST_WORD(3) 107 .endif 108 109 ADVANCE_PC(3) 110 GOTO_NEXT 111 112 113 /* 114 * Throw an exception indicating that we have not implemented this 115 * mode of filled-new-array. 116 */ 117.L${opcode}_notimpl: 118 movl $$.LstrInternalError,%eax 119 movl %eax,OUT_ARG0(%esp) 120 movl $$.LstrFilledNewArrayNotImpl,%eax 121 movl %eax,OUT_ARG1(%esp) 122 call dvmThrowException 123 UNSPILL(rPC) 124 jmp common_exceptionThrown 125 126