Support for exceptions from array allocation.

Adds support for exceptions during array allocation and checked array
allocation (used by filled-new-array). Adds more unit tests.

Change-Id: I3438b257a1cf19538d8b72529097a74347ac3b99
diff --git a/src/runtime_support.S b/src/runtime_support.S
index 963e1aa..9cfb3ab 100644
--- a/src/runtime_support.S
+++ b/src/runtime_support.S
@@ -219,6 +219,50 @@
     mov    r1, sp                             @ pass SP
     b      artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
 
+    .global art_array_alloc_from_code
+    .extern artArrayAllocFromCode
+    /*
+     * Called by managed code to allocate an array
+     */
+art_array_alloc_from_code:
+    str    sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET]    @ record top of stack and pc in case of
+    str    lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
+    stmdb  sp!, {lr}              @ Save LR
+    sub    sp, #12                @ Align stack
+    bl     artArrayAllocFromCode  @ (uint32_t type_idx, Method* method, int32_t component_count)
+    add    sp, #12
+    ldmia  sp!, {lr}              @ restore LR
+    cmp    r0, #0                 @ success if result is non-null
+    movne  pc, lr                 @ return on success
+                                  @ set up for throwing exception
+    stmdb  sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
+    sub    sp, #16                @ 4 words of space, bottom word will hold Method*
+    mov    r0, r9                 @ pass Thread::Current
+    mov    r1, sp                 @ pass SP
+    b      artDeliverPendingExceptionFromCode  @ artDeliverPendingExceptionFromCode(Thread*, SP)
+
+    .global art_check_and_array_alloc_from_code
+    .extern artCheckAndArrayAllocFromCode
+    /*
+     * Called by managed code to allocate an array
+     */
+art_check_and_array_alloc_from_code:
+    str    sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET]    @ record top of stack and pc in case of
+    str    lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
+    stmdb  sp!, {lr}                      @ Save LR
+    sub    sp, #12                        @ Align stack
+    bl     artCheckAndArrayAllocFromCode  @ (uint32_t type_idx, Method* method, int32_t count)
+    add    sp, #12
+    ldmia  sp!, {lr}                      @ restore LR
+    cmp    r0, #0                         @ success if result is non-null
+    movne  pc, lr                         @ return on success
+                                          @ set up for throwing exception
+    stmdb  sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
+    sub    sp, #16                        @ 4 words of space, bottom word will hold Method*
+    mov    r0, r9                         @ pass Thread::Current
+    mov    r1, sp                         @ pass SP
+    b      artDeliverPendingExceptionFromCode  @ artDeliverPendingExceptionFromCode(Thread*, SP)
+
     .global art_shl_long
 art_shl_long:
     /*