• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%default { "load":"lw", "shift":"2" }
2%verify "executed"
3    /*
4     * Array get, 32 bits or less.  vAA <- vBB[vCC].
5     *
6     * Note: using the usual FETCH/and/shift stuff, this fits in exactly 17
7     * instructions.  We use a pair of FETCH_Bs instead.
8     *
9     * for: aget, aget-object, aget-boolean, aget-byte, aget-char, aget-short
10     */
11    /* op vAA, vBB, vCC */
12    FETCH_B(a2, 1)                         #  a2 <- BB
13    GET_OPA(rOBJ)                          #  rOBJ <- AA
14    FETCH_C(a3, 1)                         #  a3 <- CC
15    GET_VREG(a0, a2)                       #  a0 <- vBB (array object)
16    GET_VREG(a1, a3)                       #  a1 <- vCC (requested index)
17    # null array object?
18    beqz      a0, common_errNullObject     #  yes, bail
19    LOAD_base_offArrayObject_length(a3, a0) #  a3 <- arrayObj->length
20    .if $shift
21    EASN(a0, a0, a1, $shift)               #  a0 <- arrayObj + index*width
22    .else
23    addu      a0, a0, a1
24    .endif
25    # a1 >= a3; compare unsigned index
26    bgeu      a1, a3, common_errArrayIndex #  index >= length, bail
27    FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
28    $load a2, offArrayObject_contents(a0)  #  a2 <- vBB[vCC]
29    GET_INST_OPCODE(t0)                    #  extract opcode from rINST
30    SET_VREG_GOTO(a2, rOBJ, t0)            #  vAA <- a2
31
32