1%verify "executed"
2    /*
3     * Array put, 32 bits or less.  vBB[vCC] <- vAA
4     *
5     * for: aput, aput-object, aput-boolean, aput-byte, aput-char, aput-short
6     */
7    /* op vAA, vBB, vCC */
8    movzbl    2(rPC),%eax               # eax<- BB
9    movzbl    3(rPC),%ecx               # ecx<- CC
10    GET_VREG_R  %eax %eax               # eax<- vBB (array object)
11    GET_VREG_R  %ecx %ecx               # ecs<- vCC (requested index)
12    GET_VREG_R  rINST rINST             # rINST<- vAA
13    testl     %eax,%eax                 # null array object?
14    je        common_errNullObject      # bail if so
15    cmpl      offArrayObject_length(%eax),%ecx
16    jae       common_errArrayIndex      # index >= length, bail.  Expects
17                                        #    arrayObj in eax
18                                        #    index in ecx
19    /* On entry:
20     *   eax<- array object
21     *   ecx<- index
22     *   rINST<- vAA
23     */
24    leal      offArrayObject_contents(%eax,%ecx,4),%ecx
25    testl     rINST,rINST                    # storing null reference?
26    je        .L${opcode}_skip_check
27    SPILL_TMP1(%ecx)                         # save target address
28    SPILL_TMP2(%eax)                         # save object head
29    movl      offObject_clazz(%eax),%eax     # eax<- arrayObj->clazz
30    movl      offObject_clazz(rINST),%ecx    # ecx<- obj->clazz
31    movl      %eax,OUT_ARG1(%esp)
32    movl      %ecx,OUT_ARG0(%esp)
33    movl      %ecx,sReg0                     # store the two classes for later
34    movl      %eax,sReg1
35    SPILL(rIBASE)
36    call      dvmCanPutArrayElement          # test object type vs. array type
37    UNSPILL(rIBASE)
38    UNSPILL_TMP1(%ecx)                       # recover target address
39    testl     %eax,%eax
40    movl      rSELF,%eax
41    jne       .L${opcode}_types_okay
42
43    # The types don't match.  We need to throw an ArrayStoreException.
44    EXPORT_PC
45    movl      sReg0,%eax                     # restore the two classes...
46    movl      %eax,OUT_ARG0(%esp)
47    movl      sReg1,%ecx
48    movl      %ecx,OUT_ARG1(%esp)
49    call      dvmThrowArrayStoreExceptionIncompatibleElement # ...and throw
50    jmp       common_exceptionThrown
51
52.L${opcode}_types_okay:
53    movl      offThread_cardTable(%eax),%eax   # get card table base
54    movl      rINST,(%ecx)                   # store into array
55    UNSPILL_TMP2(rINST)                      # recover object head
56    FETCH_INST_OPCODE 2 %ecx
57    shrl      $$GC_CARD_SHIFT,rINST          # object head to card number
58    movb      %al,(%eax,rINST)               # mark card using object head
59    ADVANCE_PC 2
60    GOTO_NEXT_R %ecx
61
62.L${opcode}_skip_check:
63    movl      rINST,(%ecx)
64    FETCH_INST_OPCODE 2 %ecx
65    ADVANCE_PC 2
66    GOTO_NEXT_R %ecx
67