blob: 6561f8f79f304c29fa722d9aca050c690780621f [file] [log] [blame]
%def op_aput(store="sw", shift="2", data_offset="MIRROR_INT_ARRAY_DATA_OFFSET"):
/*
* Array put, 32 bits or less. vBB[vCC] <- vAA.
*
* for: aput, aput-boolean, aput-byte, aput-char, aput-short
*
* NOTE: this assumes data offset for arrays is the same for all non-wide types.
* If this changes, specialize.
*/
/* op vAA, vBB, vCC */
FETCH_B(a2, 1, 0) # a2 <- BB
GET_OPA(rOBJ) # rOBJ <- AA
FETCH_B(a3, 1, 1) # a3 <- CC
GET_VREG(a0, a2) # a0 <- vBB (array object)
GET_VREG(a1, a3) # a1 <- vCC (requested index)
# null array object?
beqz a0, common_errNullObject # yes, bail
LOAD_base_offMirrorArray_length(a3, a0) # a3 <- arrayObj->length
EASN(a0, a0, a1, $shift) # a0 <- arrayObj + index*width
bgeu a1, a3, common_errArrayIndex # index >= length, bail
FETCH_ADVANCE_INST(2) # advance rPC, load rINST
GET_VREG(a2, rOBJ) # a2 <- vAA
GET_INST_OPCODE(t0) # extract opcode from rINST
GET_OPCODE_TARGET(t0)
$store a2, $data_offset(a0) # vBB[vCC] <- a2
JR(t0) # jump to next instruction