1%verify "executed"
2    /*
3     * Store an object into an array.  vBB[vCC] <- vAA.
4     */
5    /* op vAA, vBB, vCC */
6    FETCH(r0, 1)                        @ r0<- CCBB
7    mov     r9, rINST, lsr #8           @ r9<- AA
8    and     r2, r0, #255                @ r2<- BB
9    mov     r3, r0, lsr #8              @ r3<- CC
10    GET_VREG(rINST, r2)                 @ rINST<- vBB (array object)
11    GET_VREG(r1, r3)                    @ r1<- vCC (requested index)
12    cmp     rINST, #0                   @ null array object?
13    GET_VREG(r9, r9)                    @ r9<- vAA
14    beq     common_errNullObject        @ yes, bail
15    ldr     r3, [rINST, #offArrayObject_length]   @ r3<- arrayObj->length
16    add     r10, rINST, r1, lsl #2      @ r10<- arrayObj + index*width
17    cmp     r1, r3                      @ compare unsigned index, length
18    bcc     .L${opcode}_finish          @ we're okay, continue on
19    b       common_errArrayIndex        @ index >= length, bail
20
21%break
22    /*
23     * On entry:
24     *  rINST = vBB (arrayObj)
25     *  r9 = vAA (obj)
26     *  r10 = offset into array (vBB + vCC * width)
27     */
28.L${opcode}_finish:
29    cmp     r9, #0                      @ storing null reference?
30    beq     .L${opcode}_skip_check      @ yes, skip type checks
31    ldr     r0, [r9, #offObject_clazz]  @ r0<- obj->clazz
32    ldr     r1, [rINST, #offObject_clazz]  @ r1<- arrayObj->clazz
33    bl      dvmCanPutArrayElement       @ test object type vs. array type
34    cmp     r0, #0                      @ okay?
35    beq     .L${opcode}_throw           @ no
36    mov     r1, rINST                   @ r1<- arrayObj
37    FETCH_ADVANCE_INST(2)               @ advance rPC, load rINST
38    ldr     r2, [rSELF, #offThread_cardTable]     @ get biased CT base
39    add     r10, #offArrayObject_contents   @ r0<- pointer to slot
40    GET_INST_OPCODE(ip)                 @ extract opcode from rINST
41    str     r9, [r10]                   @ vBB[vCC]<- vAA
42    strb    r2, [r2, r1, lsr #GC_CARD_SHIFT] @ mark card using object head
43    GOTO_OPCODE(ip)                     @ jump to next instruction
44.L${opcode}_skip_check:
45    FETCH_ADVANCE_INST(2)               @ advance rPC, load rINST
46    GET_INST_OPCODE(ip)                 @ extract opcode from rINST
47    str     r9, [r10, #offArrayObject_contents] @ vBB[vCC]<- vAA
48    GOTO_OPCODE(ip)                     @ jump to next instruction
49.L${opcode}_throw:
50    @ The types don't match.  We need to throw an ArrayStoreException.
51    ldr     r0, [r9, #offObject_clazz]
52    ldr     r1, [rINST, #offObject_clazz]
53    EXPORT_PC()
54    bl      dvmThrowArrayStoreExceptionIncompatibleElement
55    b       common_exceptionThrown
56