OP_FILLED_NEW_ARRAY.S revision f3e177289ac078f18401cfd8eebafe584dd0d01f
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 movl rGLUE,%eax 12 movl offGlue_methodClassDex(%eax),%eax # eax<- pDvmDex 13 movzwl 2(rPC),%ecx # ecx<- BBBB 14 movl offDvmDex_pResClasses(%eax),%eax # eax<- pDvmDex->pResClasses 15 movl (%eax,%ecx,4),%eax # eax<- resolved class 16 EXPORT_PC 17 testl %eax,%eax # already resolved? 18 jne .L${opcode}_continue # yes, continue 19 # less frequent path, so we'll redo some work 20 movl rGLUE,%eax 21 movl $$0,OUT_ARG2(%esp) # arg2<- false 22 movl %ecx,OUT_ARG1(%esp) # arg1<- BBBB 23 movl offGlue_method(%eax),%eax # eax<- glue->method 24 jmp .L${opcode}_more 25%break 26 27.L${opcode}_more: 28 movl offMethod_clazz(%eax),%eax # eax<- method->clazz 29 movl %eax,OUT_ARG0(%esp) # arg0<- clazz 30 call dvmResolveClass # eax<- call(clazz,ref,flag) 31 testl %eax,%eax # null? 32 je common_exceptionThrown # yes, handle it 33 34 # note: fall through to .L${opcode}_continue 35 36 /* 37 * On entry: 38 * eax holds array class [r0] 39 * rINST holds AA or BB [r10] 40 * ecx is scratch 41 */ 42.L${opcode}_continue: 43 movl offClassObject_descriptor(%eax),%ecx # ecx<- arrayClass->descriptor 44 movl $$ALLOC_DONT_TRACK,OUT_ARG2(%esp) # arg2<- flags 45 movzbl 1(%ecx),%ecx # ecx<- descriptor[1] 46 movl %eax,OUT_ARG0(%esp) # arg0<- arrayClass 47 movl rGLUE,%eax 48 cmpb $$'I',%cl # supported? 49 je 1f 50 cmpb $$'L',%cl 51 je 1f 52 cmpb $$'[',%cl 53 jne .L${opcode}_notimpl # no, not handled yet 541: 55 movl %ecx,offGlue_retval+4(%eax) # save type 56 .if (!$isrange) 57 SPILL_TMP1(rINST) # save copy, need "B" later 58 sarl $$4,rINST 59 .endif 60 movl rINST,OUT_ARG1(%esp) # arg1<- A or AA (length) 61 call dvmAllocArrayByClass # eax<- call(arrayClass, length, flags) 62 movl rGLUE,%ecx 63 testl %eax,%eax # alloc successful? 64 je common_exceptionThrown # no, handle exception 65 movl %eax,offGlue_retval(%ecx) # retval.l<- new array 66 movzwl 4(rPC),%ecx # ecx<- FEDC or CCCC 67 leal offArrayObject_contents(%eax),%eax # eax<- newArray->contents 68 69/* at this point: 70 * eax is pointer to tgt 71 * rINST is length 72 * ecx is FEDC or CCCC 73 * TMP_SPILL is BA 74 * We now need to copy values from registers into the array 75 */ 76 77 .if $isrange 78 # set up src pointer 79 SPILL_TMP2(%esi) 80 SPILL_TMP3(%edi) 81 movl %eax,%edi # set up dst ptr 82 leal (rFP,%ecx,4),%esi # set up src ptr 83 movl rINST,%ecx # load count register 84 rep 85 movsd 86 UNSPILL_TMP2(%esi) 87 UNSPILL_TMP3(%edi) 88 movl rGLUE,%ecx 89 movl offGlue_retval+4(%ecx),%eax # eax<- type 90 FETCH_INST_OPCODE 3 %edx 91 .else 92 testl rINST,rINST 93 je 4f 94 andl $$0x0f,%edx # edx<- 0000000A 95 sall $$16,%edx # edx<- 000A0000 96 orl %ecx,%edx # edx<- 000AFEDC 973: 98 movl $$0xf,%ecx 99 andl %edx,%ecx # ecx<- next reg to load 100 GET_VREG_R %ecx %ecx 101 shrl $$4,%edx 102 leal 4(%eax),%eax 103 movl %ecx,-4(%eax) 104 sub $$1,rINST 105 jne 3b 1064: 107 movl rGLUE,%ecx 108 movl offGlue_retval+4(%ecx),%eax # eax<- type 109 FETCH_INST_OPCODE 3 %edx 110 .endif 111 112 cmpb $$'I',%al # Int array? 113 je 5f # skip card mark if so 114 movl offGlue_retval(%ecx),%eax # eax<- object head 115 movl offGlue_cardTable(%ecx),%ecx # card table base 116 shrl $$GC_CARD_SHIFT,%eax # convert to card num 117 movb %cl,(%ecx,%eax) # mark card 1185: 119 ADVANCE_PC 3 120 GOTO_NEXT_R %edx 121 122 123 /* 124 * Throw an exception indicating that we have not implemented this 125 * mode of filled-new-array. 126 */ 127.L${opcode}_notimpl: 128 movl $$.LstrInternalErrorA,%eax 129 movl %eax,OUT_ARG0(%esp) 130 movl $$.LstrFilledNewArrayNotImplA,%eax 131 movl %eax,OUT_ARG1(%esp) 132 call dvmThrowException 133 jmp common_exceptionThrown 134