OSDN Git Service

Dalvik fast interpreter support and JIT implementation
[android-x86/dalvik.git] / vm / mterp / mips / OP_NEW_ARRAY_JUMBO.S
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/jumbo vBBBB, vCCCC, class@AAAAAAAA */
12     FETCH(a2, 1)                           # a2<- aaaa (lo)
13     FETCH(a3, 2)                           # a3<- AAAA (hi)
14     FETCH(a0, 4)                           # a0<- vCCCC
15     sll     a3,a3,16                       #
16     or      a2, a2, a3                     # a2<- AAAAaaaa
17
18     LOAD_rSELF_methodClassDex(a3)          #  a3 <- pDvmDex
19     GET_VREG(a1, a0)                       #  a1 <- vCCCC (array length)
20     LOAD_base_offDvmDex_pResClasses(a3, a3) #  a3 <- pDvmDex->pResClasses
21     LOAD_eas2(a0, a3, a2)                  #  a0 <- resolved class
22     # check length
23     bltz      a1, common_errNegativeArraySize #  negative length, bail - len in a1
24     EXPORT_PC()                            #  req'd for resolve, alloc
25     # already resolved?
26     beqz      a0, .L${opcode}_resolve      #  not resolved,
27     b         .L${opcode}_finish
28 %break
29
30     /*
31      * Finish allocation.
32      *
33      *  a0 holds class
34      *  a1 holds array length
35      */
36 .L${opcode}_finish:
37     li        a2, ALLOC_DONT_TRACK         #  don't track in local refs table
38     JAL(dvmAllocArrayByClass)              #  v0 <- call(clazz, length, flags)
39     FETCH(a2, 3)                           # r2<- vBBBB
40     # failed?
41     beqz      v0, common_exceptionThrown   #  yes, handle the exception
42     FETCH_ADVANCE_INST(5)                  #  advance rPC, load rINST
43     GET_INST_OPCODE(t0)                    #  extract opcode from rINST
44     SET_VREG(v0, a2)                       #  vBBBB <- v0
45     GOTO_OPCODE(t0)                        #  jump to next instruction
46 #%break
47
48
49
50     /*
51      * Resolve class.  (This is an uncommon case.)
52      *
53      *  a1 holds array length
54      *  a2 holds class ref AAAAAAAA
55      */
56 .L${opcode}_resolve:
57     LOAD_rSELF_method(a3)                  #  a3 <- self->method
58     move      rOBJ, a1                     #  rOBJ <- length (save)
59     move      a1, a2                       #  a1 <- AAAAAAAA
60     li        a2, 0                        #  a2 <- false
61     LOAD_base_offMethod_clazz(a0, a3)      #  a0 <- method->clazz
62     JAL(dvmResolveClass)                   #  v0 <- call(clazz, ref)
63     move      a1, rOBJ                     #  a1 <- length (restore)
64     # got null?
65     beqz      v0, common_exceptionThrown   #  yes, handle exception
66     move      a0, v0
67     b         .L${opcode}_finish           #  continue with to ${opcode}_finish