• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%verify "executed"
2%verify "negative array length"
3%verify "allocation fails"
4    /*
5     * Allocate an array of objects, specified with the array class
6     * and a count.
7     *
8     * The verifier guarantees that this is an array class, so we don't
9     * check for it here.
10     */
11    /* new-array vA, vB, class@CCCC */
12    GET_OPB(a0)                            #  a0 <- B
13    FETCH(a2, 1)                           #  a2 <- CCCC
14    LOAD_rSELF_methodClassDex(a3)          #  a3 <- pDvmDex
15    GET_VREG(a1, a0)                       #  a1 <- vB (array length)
16    LOAD_base_offDvmDex_pResClasses(a3, a3) #  a3 <- pDvmDex->pResClasses
17    LOAD_eas2(a0, a3, a2)                  #  a0 <- resolved class
18    # check length
19    bltz      a1, common_errNegativeArraySize #  negative length, bail - len in a1
20    EXPORT_PC()                            #  req'd for resolve, alloc
21    # already resolved?
22    beqz      a0, .L${opcode}_resolve
23
24    /*
25     * Finish allocation.
26     *
27     *  a0 holds class
28     *  a1 holds array length
29     */
30.L${opcode}_finish:
31    li        a2, ALLOC_DONT_TRACK         #  don't track in local refs table
32    JAL(dvmAllocArrayByClass)              #  v0 <- call(clazz, length, flags)
33    GET_OPA4(a2)                           #  a2 <- A+
34    # failed?
35    beqz      v0, common_exceptionThrown   #  yes, handle the exception
36    FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
37    GET_INST_OPCODE(t0)                    #  extract opcode from rINST
38    SET_VREG(v0, a2)                       #  vA <- v0
39    GOTO_OPCODE(t0)                        #  jump to next instruction
40%break
41
42    /*
43     * Resolve class.  (This is an uncommon case.)
44     *
45     *  a1 holds array length
46     *  a2 holds class ref CCCC
47     */
48.L${opcode}_resolve:
49    LOAD_rSELF_method(a3)                  #  a3 <- self->method
50    move      rOBJ, a1                     #  rOBJ <- length (save)
51    move      a1, a2                       #  a1 <- CCCC
52    li        a2, 0                        #  a2 <- false
53    LOAD_base_offMethod_clazz(a0, a3)      #  a0 <- method->clazz
54    JAL(dvmResolveClass)                   #  v0 <- call(clazz, ref)
55    move      a1, rOBJ                     #  a1 <- length (restore)
56    # got null?
57    beqz      v0, common_exceptionThrown   #  yes, handle exception
58    move      a0, v0
59    b         .L${opcode}_finish           #  continue with ${opcode}_finish
60
61
62