quick_entrypoints_mips64.S revision cf283daf579e9eda586f312c3fc89444601e2525
11a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe/*
21a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Copyright (C) 2014 The Android Open Source Project
31a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe *
41a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
51a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * you may not use this file except in compliance with the License.
61a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * You may obtain a copy of the License at
71a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe *
81a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
91a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe *
101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Unless required by applicable law or agreed to in writing, software
111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * See the License for the specific language governing permissions and
141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * limitations under the License.
151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe */
161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "asm_support_mips64.S"
181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "arch/quick_alloc_entrypoints.S"
201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .set noreorder
221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .balign 16
231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /* Deliver the given exception */
251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artDeliverExceptionFromCode
261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /* Deliver an exception pending on a thread */
271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artDeliverPendingExceptionFromCode
281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
3004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic     * Macro that sets up $gp and stores the previous $gp value to $t8.
3104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic     * This macro modifies v1 and t8.
3204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic     */
3304568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic.macro SETUP_GP
3404568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    move $v1, $ra
3504568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    bal 1f
3604568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    nop
3704568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic1:
3804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpsetup $ra, $t8, 1b
3904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    move $ra, $v1
4004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic.endm
4104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic
4204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    /*
431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Macro that sets up the callee save frame to conform with
441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Runtime::CreateCalleeSaveMethod(kSaveAll)
451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * callee-save: padding + $f24-$f31 + $s0-$s7 + $gp + $ra + $s8 = 19 total + 1x8 bytes padding
461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, -160
491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 160
501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     // Ugly compile-time check, but we only have the preprocessor.
521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 160)
531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS64) size not as expected."
541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#endif
551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 152($sp)
571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 152
581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s8, 144($sp)
591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 30, 144
6004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    sd     $t8, 136($sp)           # t8 holds caller's gp, now save it to the stack.
6104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cfi_rel_offset 28, 136        # Value from gp is pushed, so set the cfi offset accordingly.
621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s7, 128($sp)
631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 23, 128
641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s6, 120($sp)
651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 22, 120
661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s5, 112($sp)
671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 21, 112
681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s4, 104($sp)
691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 20, 104
701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s3,  96($sp)
711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 19, 96
721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s2,  88($sp)
731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 18, 88
741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s1,  80($sp)
751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 17, 80
761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s0,  72($sp)
771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 16, 72
781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    // FP callee-saves
801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f31, 64($sp)
811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f30, 56($sp)
821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f29, 48($sp)
831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f28, 40($sp)
841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f27, 32($sp)
851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f26, 24($sp)
861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f25, 16($sp)
871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f24,  8($sp)
881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # load appropriate callee-save-method
9084bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, %got(_ZN3art7Runtime9instance_E)($gp)
9184bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, 0($t1)
9284bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t1)
9384bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    sd      $t1, 0($sp)                                # Place ArtMethod* at bottom of stack.
941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd      $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Macro that sets up the callee save frame to conform with
991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes
1001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * non-moving GC.
1011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Does not include rSUSPEND or rSELF
1021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * callee-save: padding + $s2-$s7 + $gp + $ra + $s8 = 9 total + 1x8 bytes padding
1031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
1041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
1051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, -80
1061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 80
1071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
1091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 80)
1101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS64) size not as expected."
1111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#endif
1121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 72($sp)
1141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 72
1151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s8, 64($sp)
1161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 30, 64
11704568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    sd     $t8, 56($sp)            # t8 holds caller's gp, now save it to the stack.
11804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cfi_rel_offset 28, 56         # Value from gp is pushed, so set the cfi offset accordingly.
1191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s7, 48($sp)
1201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 23, 48
1211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s6, 40($sp)
1221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 22, 40
1231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s5, 32($sp)
1241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 21, 32
1251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s4, 24($sp)
1261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 20, 24
1271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s3, 16($sp)
1281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 19, 16
1291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s2, 8($sp)
1301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 18, 8
1311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # load appropriate callee-save-method
13284bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, %got(_ZN3art7Runtime9instance_E)($gp)
13384bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, 0($t1)
13484bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t1)
13584bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    sd      $t1, 0($sp)                                # Place Method* at bottom of stack.
1361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd      $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
1371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
1381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
1401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 72($sp)
1411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
1421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s8, 64($sp)
1431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 30
14404568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    ld     $t8, 56($sp)            # Restore gp back to it's temp storage.
1451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 28
1461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s7, 48($sp)
1471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 23
1481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s6, 40($sp)
1491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 22
1501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s5, 32($sp)
1511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 21
1521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s4, 24($sp)
1531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 20
1541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s3, 16($sp)
1551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 19
1561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s2, 8($sp)
1571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 18
1581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 80
1591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -80
16004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn
1611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
1621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
1641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 72($sp)
1651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
1661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s8, 64($sp)
1671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 30
16804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    ld     $t8, 56($sp)            # Restore gp back to it's temp storage.
1691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 28
1701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s7, 48($sp)
1711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 23
1721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s6, 40($sp)
1731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 22
1741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s5, 32($sp)
1751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 21
1761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s4, 24($sp)
1771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 20
1781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s3, 16($sp)
1791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 19
1801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s2, 8($sp)
1811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 18
18204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn
1831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $ra
1841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 80
1851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -80
1861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
1871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe// This assumes the top part of these stack frame types are identical.
1891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#define REFS_AND_ARGS_MINUS_REFS_SIZE (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE - FRAME_SIZE_REFS_ONLY_CALLEE_SAVE)
1901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
1921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu  $sp, $sp, -208
1931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 208
1941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
1961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 208)
1971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS64) size not as expected."
1981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#endif
1991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 200($sp)           # = kQuickCalleeSaveFrame_RefAndArgs_LrOffset
2011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 200
2021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s8, 192($sp)
2031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 30, 192
20404568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    sd     $t8, 184($sp)           # t8 holds caller's gp, now save it to the stack.
20504568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cfi_rel_offset 28, 184        # Value from gp is pushed, so set the cfi offset accordingly.
2061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s7, 176($sp)
2071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 23, 176
2081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s6, 168($sp)
2091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 22, 168
2101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s5, 160($sp)
2111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 21, 160
2121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s4, 152($sp)
2131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 20, 152
2141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s3, 144($sp)
2151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 19, 144
2161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s2, 136($sp)
2171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 18, 136
2181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a7, 128($sp)
2201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 11, 128
2211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a6, 120($sp)
2221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 10, 120
2231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a5, 112($sp)
2241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 9, 112
2251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a4, 104($sp)
2261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 8, 104
2271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a3,  96($sp)
2281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 7, 96
2291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a2,  88($sp)
2301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 6, 88
2311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a1,  80($sp)           # = kQuickCalleeSaveFrame_RefAndArgs_Gpr1Offset
2321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 5, 80
2331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f19, 72($sp)
2351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f18, 64($sp)
2361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f17, 56($sp)
2371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f16, 48($sp)
2381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f15, 40($sp)
2391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f14, 32($sp)
2401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f13, 24($sp)           # = kQuickCalleeSaveFrame_RefAndArgs_Fpr1Offset
2411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d    $f12, 16($sp)           # This isn't necessary to store.
2428223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    # 1x8 bytes padding + Method*
2431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
2441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2458223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    /*
2468223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung     * Macro that sets up the callee save frame to conform with
2478223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes
2488223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung     * non-moving GC.
2498223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung     * callee-save: padding + $f12-$f19 + $a1-$a7 + $s2-$s7 + $gp + $ra + $s8 = 24 total + 1 words padding + Method*
2508223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung     */
2511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
2521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
2531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # load appropriate callee-save-method
25484bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, %got(_ZN3art7Runtime9instance_E)($gp)
25584bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, 0($t1)
25684bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    ld      $t1, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t1)
25784bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic    sd      $t1, 0($sp)                                # Place Method* at bottom of stack.
2581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd      $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
2591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
2601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2618223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
2628223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
263e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    sd      $a0, 0($sp)                                # Place Method* at bottom of stack.
2648223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    sd      $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
2658223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung.endm
2668223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung
2671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
2681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 200($sp)
2691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
2701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s8, 192($sp)
2711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 30
27204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    ld     $t8, 184($sp)           # Restore gp back to it's temp storage.
2731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 28
2741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s7, 176($sp)
2751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 23
2761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s6, 168($sp)
2771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 22
2781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s5, 160($sp)
2791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 21
2801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s4, 152($sp)
2811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 20
2821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s3, 144($sp)
2831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 19
2841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s2, 136($sp)
2851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 18
2861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
2871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a7, 128($sp)
2881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 11
2891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a6, 120($sp)
2901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 10
2911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a5, 112($sp)
2921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 9
2931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a4, 104($sp)
2941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 8
2951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a3,  96($sp)
2961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 7
2971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a2,  88($sp)
2981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 6
2991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a1,  80($sp)
3001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 5
3011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f19, 72($sp)
3031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f18, 64($sp)
3041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f17, 56($sp)
3051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f16, 48($sp)
3061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f15, 40($sp)
3071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f14, 32($sp)
3081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f13, 24($sp)
3091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d    $f12, 16($sp)
3101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
31104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn
3121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 208
3131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -208
3141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
3151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
3171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Macro that set calls through to artDeliverPendingExceptionFromCode,
3181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * where the pending
3191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * exception is Thread::Current()->exception_
3201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
3211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro DELIVER_PENDING_EXCEPTION
32204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    SETUP_GP
3231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME     # save callee saves for throw
3241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dla     $t9, artDeliverPendingExceptionFromCode
3251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr    $zero, $t9                   # artDeliverPendingExceptionFromCode(Thread*)
3261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a0, rSELF                   # pass Thread::Current
3271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
3281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RETURN_IF_NO_EXCEPTION
3301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
3311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    bne    $t0, $zero, 1f                      # success if no exception is pending
3331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $ra
3351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
3371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    DELIVER_PENDING_EXCEPTION
3381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
3391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RETURN_IF_ZERO
3411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    bne    $v0, $zero, 1f                # success?
3431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $ra                    # return on success
3451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
3471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    DELIVER_PENDING_EXCEPTION
3481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
3491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
3511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq    $v0, $zero, 1f                # success?
3531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $ra                    # return on success
3551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
3561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
3571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    DELIVER_PENDING_EXCEPTION
3581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
3591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
3601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
3611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
3621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * FIXME: just guessing about the shape of the jmpbuf.  Where will pc be?
3631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
36404568815cbfa18f0fa8b8d751fb83a1089909660Goran JakovljevicENTRY_NO_GP art_quick_do_long_jump
3651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f0, 0($a1)
3661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f1, 8($a1)
3671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f2, 16($a1)
3681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f3, 24($a1)
3691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f4, 32($a1)
3701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f5, 40($a1)
3711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f6, 48($a1)
3721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f7, 56($a1)
3731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f8, 64($a1)
3741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f9, 72($a1)
3751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f10, 80($a1)
3761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f11, 88($a1)
3771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f12, 96($a1)
3781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f13, 104($a1)
3791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f14, 112($a1)
3801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f15, 120($a1)
3811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f16, 128($a1)
3821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f17, 136($a1)
3831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f18, 144($a1)
3841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f19, 152($a1)
3851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f20, 160($a1)
3861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f21, 168($a1)
3871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f22, 176($a1)
3881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f23, 184($a1)
3891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f24, 192($a1)
3901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f25, 200($a1)
3911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f26, 208($a1)
3921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f27, 216($a1)
3931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f28, 224($a1)
3941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f29, 232($a1)
3951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f30, 240($a1)
3961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f31, 248($a1)
3971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .set push
3981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .set nomacro
3991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .set noat
4001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe# no need to load zero
4011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $at, 8($a0)
4021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .set pop
4031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $v0, 16($a0)
4041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $v1, 24($a0)
4051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe# a0 has to be loaded last
4061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a1, 40($a0)
4071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a2, 48($a0)
4081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a3, 56($a0)
4091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a4, 64($a0)
4101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a5, 72($a0)
4111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a6, 80($a0)
4121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a7, 88($a0)
4131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t0, 96($a0)
4141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t1, 104($a0)
4151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t2, 112($a0)
4161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t3, 120($a0)
4171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s0, 128($a0)
4181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s1, 136($a0)
4191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s2, 144($a0)
4201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s3, 152($a0)
4211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s4, 160($a0)
4221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s5, 168($a0)
4231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s6, 176($a0)
4241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s7, 184($a0)
4251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t8, 192($a0)
4261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t9, 200($a0)
4271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe# no need to load k0, k1
4281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $gp, 224($a0)
4291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $sp, 232($a0)
4301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $s8, 240($a0)
4311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $ra, 248($a0)
4321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a0, 32($a0)
4331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $v0, $zero          # clear result registers v0 and v1
434dbf056d38dddda10c5f409e3155c7b4211183f63Andreas Gampe    jalr    $zero, $t9          # do long jump (do not use ra, it must not be clobbered)
4351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $v1, $zero
4361a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_do_long_jump
4371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
4386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code, saves most registers (forms basis of long jump
4406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * context) and passes the bottom of the stack.
4416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * artDeliverExceptionFromCode will place the callee save Method* at
44284bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic     * the bottom of the thread. On entry a0 holds Throwable*
4436ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
4446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_deliver_exception
4456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artDeliverExceptionFromCode
4476ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artDeliverExceptionFromCode(Throwable*, Thread*)
4486ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a1, rSELF                 # pass Thread::Current
4496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_deliver_exception
4506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
4516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to create and deliver a NullPointerException
4536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
4546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowNullPointerExceptionFromCode
4556ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_throw_null_pointer_exception
4566ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Lart_quick_throw_null_pointer_exception_gp_set:
4576ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4586ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowNullPointerExceptionFromCode
4596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowNullPointerExceptionFromCode(Thread*)
4606ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a0, rSELF                 # pass Thread::Current
4616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_throw_null_pointer_exception
4621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
4636ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to create and deliver an ArithmeticException
4656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
4666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowDivZeroFromCode
4676ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_throw_div_zero
4686ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4696ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowDivZeroFromCode
4706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowDivZeroFromCode(Thread*)
4716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a0, rSELF                 # pass Thread::Current
4726ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_throw_div_zero
4731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
4746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4756ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to create and deliver an
4766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * ArrayIndexOutOfBoundsException
4776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
4786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowArrayBoundsFromCode
4796ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_throw_array_bounds
4806ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Lart_quick_throw_array_bounds_gp_set:
4816ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowArrayBoundsFromCode
4836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowArrayBoundsFromCode(index, limit, Thread*)
4846ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a2, rSELF                 # pass Thread::Current
4856ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_throw_array_bounds
4866ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
4876ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4886ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to create and deliver a StackOverflowError.
4896ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
4906ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowStackOverflowFromCode
4916ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_throw_stack_overflow
4926ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowStackOverflowFromCode
4946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowStackOverflowFromCode(Thread*)
4956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a0, rSELF                 # pass Thread::Current
4966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_throw_stack_overflow
4976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
4986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
4996ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to create and deliver a NoSuchMethodError.
5006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
5016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowNoSuchMethodFromCode
5026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_throw_no_such_method
5036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowNoSuchMethodFromCode
5056ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
5066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a1, rSELF                 # pass Thread::Current
5076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_throw_no_such_method
5086ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
5096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
5106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * All generated callsites for interface invokes and invocation slow paths will load arguments
5116ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
5126ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * the method_idx.  This wrapper will save arg1-arg3, load the caller's Method*, align the
5136ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * stack and call the appropriate C helper.
5146ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
5156ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     *
5166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * The helper will attempt to locate the target and return a 128-bit result in $v0/$v1 consisting
5176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * of the target Method* in $v0 and method->code_ in $v1.
5186ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     *
5192cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier     * If unsuccessful, the helper will return null/null. There will be a pending exception in the
5206ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * thread and we branch to another stub to deliver it.
5216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     *
5226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * On success this wrapper will restore arguments and *jump* to the target, leaving the ra
5236ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * pointing back to the original caller.
5246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
5253031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.macro INVOKE_TRAMPOLINE_BODY cxx_name
5266ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern \cxx_name
5276ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME  # save callee saves in case allocation triggers GC
5287ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a2, rSELF                       # pass Thread::Current
5297ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    jal   \cxx_name                        # (method_idx, this, Thread*, $sp)
5307ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a3, $sp                         # pass $sp
5316ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move  $a0, $v0                         # save target Method*
5326ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move  $t9, $v1                         # save $v0->code_
5336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
5346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    beq   $v0, $zero, 1f
5356ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
5366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr  $zero, $t9
5376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
5386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic1:
5396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    DELIVER_PENDING_EXCEPTION
5403031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.endm
5413031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.macro INVOKE_TRAMPOLINE c_name, cxx_name
5423031c8da0c5009183f770b005c245f9bf2a4d01bAndreas GampeENTRY \c_name
5433031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe    INVOKE_TRAMPOLINE_BODY \cxx_name
5446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND \c_name
5456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.endm
5466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
5476ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
5486ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
5496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicINVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
5506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicINVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
5516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicINVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
5526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicINVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
5531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
5541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # On entry:
5551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    #   t0 = shorty
5561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    #   t1 = ptr to arg_array
5571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    #   t2 = number of argument bytes remain
5581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    #   v0 = ptr to stack frame where to copy arg_array
5591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # This macro modifies t3, t9 and v0
5601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro LOOP_OVER_SHORTY_LOADING_REG gpu, fpu, label
5611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lbu    $t3, 0($t0)           # get argument type from shorty
5621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beqz   $t3, \label
5631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t0, 1
5641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li     $t9, 68               # put char 'D' into t9
5651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq    $t9, $t3, 1f          # branch if result type char == 'D'
5661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li     $t9, 70               # put char 'F' into t9
5671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq    $t9, $t3, 2f          # branch if result type char == 'F'
5681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li     $t9, 74               # put char 'J' into t9
5691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq    $t9, $t3, 3f          # branch if result type char == 'J'
5701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
5716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    lw     $\gpu, 0($t1)
5721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $\gpu, 0($v0)
5731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, 4
5741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, 4
5751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    b      4f
5761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -4               # delay slot
5771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
5781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:  # found double
5791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $t3, 0($t1)
5801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mtc1   $t3, $\fpu
5811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 0($v0)
5821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $t3, 4($t1)
5831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mthc1  $t3, $\fpu
5841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 4($v0)
5851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, 8
5861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, 8
5871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    b      4f
5881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -8               # delay slot
5891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
5901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe2:  # found float
5911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $t3, 0($t1)
5921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mtc1   $t3, $\fpu
5931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 0($v0)
5941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, 4
5951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, 4
5961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    b      4f
5971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -4               # delay slot
5981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
5991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe3:  # found long (8 bytes)
6001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $t3, 0($t1)
6011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 0($v0)
6021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $t9, 4($t1)
6031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t9, 4($v0)
6041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsll   $t9, $t9, 32
6051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    or     $\gpu, $t9, $t3
6061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, 8
6071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, 8
6081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -8
6091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe4:
6101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
6111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
6131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Invocation stub for quick code.
6141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * On entry:
6151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a0 = method pointer
6161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a1 = argument array that must at least contain the this ptr.
6171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a2 = size of argument array in bytes
6181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a3 = (managed) thread pointer
6191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a4 = JValue* result
6201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a5 = shorty
6211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
62204568815cbfa18f0fa8b8d751fb83a1089909660Goran JakovljevicENTRY_NO_GP art_quick_invoke_stub
6231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra onto the stack
6241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, -48
6251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 48
6261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 40($sp)
6271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 40
6281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s8, 32($sp)
6291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 30, 32
6301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s1, 24($sp)
6311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 17, 24
6321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s0, 16($sp)
6331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 16, 16
6341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a5, 8($sp)
6351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 9, 8
6361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a4, 0($sp)
6371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 8, 0
6381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL   # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
6401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $s1, $a3              # move managed thread pointer into s1 (rSELF)
6411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $s8, $sp              # save sp in s8 (fp)
6421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
643e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    daddiu $t3, $a2, 24          # add 8 for ArtMethod* and 16 for stack alignment
6441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsrl   $t3, $t3, 4           # shift the frame size right 4
6451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsll   $t3, $t3, 4           # shift the frame size left 4 to align to 16 bytes
6461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsubu  $sp, $sp, $t3         # reserve stack space for argument array
6471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t0, $a5, 1           # t0 = shorty[1] (skip 1 for return type)
6491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, $a1, 4           # t1 = ptr to arg_array[4] (skip this ptr)
6501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, $a2, -4          # t2 = number of argument bytes remain (skip this ptr)
65180f7a57e2aec7515c7a54c4b5c9e703a66623feaNikola Veljkovic    daddiu $v0, $sp, 12          # v0 points to where to copy arg_array
6521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_fn
6531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_fn
6541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_fn
6551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_fn
6561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_fn
6571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_fn
6581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # copy arguments onto stack (t2 should be multiples of 4)
6601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ble    $t2, $zero, call_fn   # t2 = number of argument bytes remain
6611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
6621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lw     $t3, 0($t1)           # load from argument array
6631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, $t1, 4
6641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 0($v0)           # save to stack
6651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -4
6661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    bgt    $t2, $zero, 1b        # t2 = number of argument bytes remain
6671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, $v0, 4
6681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampecall_fn:
6701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # call method (a0 and a1 have been untouched)
6711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lwu    $a1, 0($a1)           # make a1 = this ptr
672e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    sw     $a1, 8($sp)           # copy this ptr (skip 8 bytes for ArtMethod*)
673e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    sd     $zero, 0($sp)         # store null for ArtMethod* at bottom of frame
674e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $t9, ART_METHOD_QUICK_CODE_OFFSET_64($a0)  # get pointer to the code
6751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $t9                   # call the method
6761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
6771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $sp, $s8              # restore sp
6781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # pop a4, a5, s1(rSELF), s8, ra off of the stack
6801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a4, 0($sp)
6811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 8
6821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a5, 8($sp)
6831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 9
6841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s0, 16($sp)
6851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 16
6861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s1, 24($sp)
6871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 17
6881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s8, 32($sp)
6891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 30
6901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 40($sp)
6911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
6921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 48
6931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -48
6941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
6951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # a4 = JValue* result
6961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # a5 = shorty string
6971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lbu   $t1, 0($a5)           # get result type from shorty
6981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li    $t2, 68               # put char 'D' into t2
6991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq   $t1, $t2, 1f          # branch if result type char == 'D'
7001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li    $t3, 70               # put char 'F' into t3
7011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq   $t1, $t3, 1f          # branch if result type char == 'F'
7021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v0, 0($a4)           # store the result
7031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsrl  $v1, $v0, 32
7041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr  $zero, $ra
7051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v1, 4($a4)           # store the other half of the result
7061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
7071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mfc1  $v0, $f0
7081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mfhc1 $v1, $f0
7091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v0, 0($a4)           # store the result
7101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr  $zero, $ra
7111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v1, 4($a4)           # store the other half of the result
7121a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_invoke_stub
7131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
7151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Invocation static stub for quick code.
7161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * On entry:
7171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a0 = method pointer
7181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a1 = argument array that must at least contain the this ptr.
7191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a2 = size of argument array in bytes
7201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a3 = (managed) thread pointer
7211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a4 = JValue* result
7221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     *   a5 = shorty
7231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
72404568815cbfa18f0fa8b8d751fb83a1089909660Goran JakovljevicENTRY_NO_GP art_quick_invoke_static_stub
7251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra, onto the stack
7271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, -48
7281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 48
7291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 40($sp)
7301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 40
7311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s8, 32($sp)
7321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 30, 32
7331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s1, 24($sp)
7341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 17, 24
7351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $s0, 16($sp)
7361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 16, 16
7371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a5, 8($sp)
7381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 9, 8
7391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $a4, 0($sp)
7401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 8, 0
7411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL   # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
7431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $s1, $a3              # move managed thread pointer into s1 (rSELF)
7441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $s8, $sp              # save sp in s8 (fp)
7451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
746e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    daddiu $t3, $a2, 24          # add 8 for ArtMethod* and 16 for stack alignment
7471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsrl   $t3, $t3, 4           # shift the frame size right 4
7481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsll   $t3, $t3, 4           # shift the frame size left 4 to align to 16 bytes
7491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsubu  $sp, $sp, $t3         # reserve stack space for argument array
7501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t0, $a5, 1           # t0 = shorty[1] (skip 1 for return type)
7521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $t1, $a1              # t1 = arg_array
7531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $t2, $a2              # t2 = number of argument bytes remain
754e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    daddiu $v0, $sp, 8           # v0 points to where to copy arg_array
7551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a1, f13, call_sfn
7561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_sfn
7571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_sfn
7581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_sfn
7591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_sfn
7601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_sfn
7611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_sfn
7621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # copy arguments onto stack (t2 should be multiples of 4)
7641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ble    $t2, $zero, call_sfn  # t2 = number of argument bytes remain
7651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
7661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lw     $t3, 0($t1)           # load from argument array
7671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t1, $t1, 4
7681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw     $t3, 0($v0)           # save to stack
7691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $t2, -4
7701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    bgt    $t2, $zero, 1b        # t2 = number of argument bytes remain
7711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $v0, $v0, 4
7721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampecall_sfn:
7741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # call method (a0 has been untouched)
775e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    sd     $zero, 0($sp)         # store null for ArtMethod* at bottom of frame
776e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $t9, ART_METHOD_QUICK_CODE_OFFSET_64($a0)  # get pointer to the code
7771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $t9                   # call the method
7781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
7791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $sp, $s8              # restore sp
7801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # pop a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra off of the stack
7821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a4, 0($sp)
7831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 8
7841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a5, 8($sp)
7851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 9
7861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s0, 16($sp)
7871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 16
7881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s1, 24($sp)
7891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 17
7901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $s8, 32($sp)
7911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 30
7921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 40($sp)
7931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
7941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 48
7951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -48
7961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
7971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # a4 = JValue* result
7981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # a5 = shorty string
7991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    lbu   $t1, 0($a5)           # get result type from shorty
8001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li    $t2, 68               # put char 'D' into t2
8011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq   $t1, $t2, 1f          # branch if result type char == 'D'
8021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    li    $t3, 70               # put char 'F' into t3
8031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq   $t1, $t3, 1f          # branch if result type char == 'F'
8041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v0, 0($a4)           # store the result
8051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dsrl  $v1, $v0, 32
8061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr  $zero, $ra
8071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v1, 4($a4)           # store the other half of the result
8081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
8091a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mfc1  $v0, $f0
8101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mfhc1 $v1, $f0
8111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v0, 0($a4)           # store the result
8121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr  $zero, $ra
8131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sw    $v1, 4($a4)           # store the other half of the result
8141a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_invoke_static_stub
8151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
8166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
8176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Entry from managed code that calls artHandleFillArrayDataFromCode and
8186ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * delivers exception on failure.
8196ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
8206ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artHandleFillArrayDataFromCode
8216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_handle_fill_data
8226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case exception allocation triggers GC
823e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld      $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
8246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal     artHandleFillArrayDataFromCode              # (payload offset, Array*, method, Thread*)
8256ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move    $a3, rSELF                                  # pass Thread::Current
8266ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
8276ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_handle_fill_data
8286ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
8296ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
8306ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Entry from managed code that calls artLockObjectFromCode, may block for GC.
8316ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
8326ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artLockObjectFromCode
8336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_lock_object
8346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    beq     $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set
8356ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
8366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case we block
8376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal     artLockObjectFromCode         # (Object* obj, Thread*)
8386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move    $a1, rSELF                    # pass Thread::Current
8396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
8406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_lock_object
8416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
8426ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
8436ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
8446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
8456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artUnlockObjectFromCode
8466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_unlock_object
8476ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    beq     $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set
8486ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
8496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case exception allocation triggers GC
8506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal     artUnlockObjectFromCode    # (Object* obj, Thread*)
8516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move    $a1, rSELF                 # pass Thread::Current
8526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
8536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_unlock_object
8546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
8556ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
8566ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
8576ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
8586ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artThrowClassCastException
8596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_check_cast
8606ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu $sp, $sp, -32
8616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_adjust_cfa_offset 32
8626ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $ra, 24($sp)
8636ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_rel_offset 31, 24
8646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $t9, 16($sp)
8656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $a1, 8($sp)
8666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $a0, 0($sp)
8676ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artIsAssignableFromCode
86804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                       # Restore gp from t8 in branch delay slot.
86904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic                                    # t8 may be clobbered in artIsAssignableFromCode.
8706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    beq    $v0, $zero, .Lthrow_class_cast_exception
8716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $ra, 24($sp)
8726ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr   $zero, $ra
8736ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu $sp, $sp, 32
8746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_adjust_cfa_offset -32
8756ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Lthrow_class_cast_exception:
8766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $t9, 16($sp)
8776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $a1, 8($sp)
8786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $a0, 0($sp)
8796ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu $sp, $sp, 32
8806ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_adjust_cfa_offset -32
88104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    SETUP_GP
8826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
8836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowClassCastException
8846ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowClassCastException (Class*, Class*, Thread*)
8856ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a2, rSELF                 # pass Thread::Current
8866ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_check_cast
8876ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
8881aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
8891aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    /*
8901aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
8911aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * nReg is the register number for rReg.
8921aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     */
8931aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.macro POP_REG_NE rReg, nReg, offset, rExclude
8941aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .ifnc \rReg, \rExclude
8951aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        ld \rReg, \offset($sp)      # restore rReg
8961aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        .cfi_restore \nReg
8971aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .endif
8981aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.endm
8991aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
9001aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    /*
9011aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * Macro to insert read barrier, only used in art_quick_aput_obj.
9021aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
9031aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
9041aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     */
9051aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.macro READ_BARRIER rDest, rObj, offset
9061aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#ifdef USE_READ_BARRIER
9071aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 16B-aligned.
9081aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    daddiu  $sp, $sp, -64
9091aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_adjust_cfa_offset 64
9101aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $ra, 56($sp)
9111aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 31, 56
9121aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $t9, 48($sp)
9131aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 25, 48
9141aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $t1, 40($sp)
9151aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 13, 40
9161aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $t0, 32($sp)
9171aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 12, 32
9181aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $a2, 16($sp)             # padding slot at offset 24 (padding can be any slot in the 64B)
9191aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 6, 16
9201aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $a1, 8($sp)
9211aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 5, 8
9221aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sd     $a0, 0($sp)
9231aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 4, 0
9241aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
9256306921722283d2b0f8aac01883ad83215d6e864Man Cao    # move $a0, \rRef               # pass ref in a0 (no-op for now since parameter ref is unused)
9261aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .ifnc \rObj, $a1
9271aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        move $a1, \rObj             # pass rObj
9281aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .endif
9291aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    daddiu $a2, $zero, \offset      # pass offset
9301aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    jal artReadBarrierSlow          # artReadBarrierSlow(ref, rObj, offset)
9311aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cpreturn                       # Restore gp from t8 in branch delay slot.
9321aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # t8 may be clobbered in artReadBarrierSlow.
9331aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
9341aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    move \rDest, $v0                # save return value in rDest
9351aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # (rDest cannot be v0 in art_quick_aput_obj)
9361aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
9371aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    ld     $a0, 0($sp)              # restore registers except rDest
9381aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # (rDest can only be t0 or t1 in art_quick_aput_obj)
9391aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 4
9401aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    ld     $a1, 8($sp)
9411aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 5
9421aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    ld     $a2, 16($sp)
9431aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 6
9441aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    POP_REG_NE $t0, 12, 32, \rDest
9451aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    POP_REG_NE $t1, 13, 40, \rDest
9461aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    ld     $t9, 48($sp)
9471aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 25
9481aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    ld     $ra, 56($sp)             # restore $ra
9491aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 31
9501aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    daddiu  $sp, $sp, 64
9511aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_adjust_cfa_offset -64
9521aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    SETUP_GP                        # set up gp because we are not returning
9531aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#else
9541aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lwu     \rDest, \offset(\rObj)
9551aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    UNPOISON_HEAP_REF \rDest
9561aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#endif  // USE_READ_BARRIER
9571aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.endm
9581aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
9596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
9606ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Entry from managed code for array put operations of objects where the value being stored
9616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * needs to be checked for compatibility.
9626ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * a0 = array, a1 = index, a2 = value
9636ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
9646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_aput_obj_with_null_and_bound_check
9656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    bne    $a0, $zero, .Lart_quick_aput_obj_with_bound_check_gp_set
9666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
9676ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    b .Lart_quick_throw_null_pointer_exception_gp_set
9686ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
9696ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_aput_obj_with_null_and_bound_check
9701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
9716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_aput_obj_with_bound_check
9726ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    lwu  $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
9736ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sltu $t1, $a1, $t0
9746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    bne  $t1, $zero, .Lart_quick_aput_obj_gp_set
9756ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
9766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a0, $a1
9776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    b .Lart_quick_throw_array_bounds_gp_set
9786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move $a1, $t0
9796ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_aput_obj_with_bound_check
9801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
9816ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_aput_obj
9826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    beq  $a2, $zero, .Ldo_aput_null
9836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
9841aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
9851aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
9861aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
9876ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    bne $t1, $t0, .Lcheck_assignability  # value's type == array's component type - trivial assignability
9886ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
9896ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Ldo_aput:
9906ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dsll  $a1, $a1, 2
9916ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddu $t0, $a0, $a1
992bfa5eb6e8d15ea73a36f8df449630f285a91e995Hiroshi Yamauchi    POISON_HEAP_REF $a2
9936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sw   $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
9946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld   $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
9956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dsrl  $t1, $a0, 7
9966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddu $t1, $t1, $t0
9976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sb   $t0, ($t1)
9986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $ra
99904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                       # Restore gp from t8 in branch delay slot.
10006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Ldo_aput_null:
10016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dsll  $a1, $a1, 2
10026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddu $t0, $a0, $a1
10036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sw   $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
10046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $ra
100504568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                       # Restore gp from t8 in branch delay slot.
10066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic.Lcheck_assignability:
10076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu $sp, $sp, -64
10086ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_adjust_cfa_offset 64
10096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $ra, 56($sp)
10106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_rel_offset 31, 56
10116ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $t9, 24($sp)
10126ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $a2, 16($sp)
10136ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $a1, 8($sp)
10146ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    sd     $a0, 0($sp)
10156ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a1, $t1
10166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a0, $t0
10176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artIsAssignableFromCode  # (Class*, Class*)
101804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                       # Restore gp from t8 in branch delay slot.
101904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic                                    # t8 may be clobbered in artIsAssignableFromCode.
10206ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $ra, 56($sp)
10216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $t9, 24($sp)
10226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $a2, 16($sp)
10236ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $a1, 8($sp)
10246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    ld     $a0, 0($sp)
10256ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu $sp, $sp, 64
10266ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .cfi_adjust_cfa_offset -64
102704568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    SETUP_GP
10286ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    bne    $v0, $zero, .Ldo_aput
10296ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    nop
10306ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
10316ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a1, $a2
10326ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    dla  $t9, artThrowArrayStoreException
10336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr $zero, $t9                 # artThrowArrayStoreException(Class*, Class*, Thread*)
10346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF               # pass Thread::Current
10356ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_aput_obj
10366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a boolean primitive value.
10396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
10406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetBooleanStaticFromCode
10416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_boolean_static
10426ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1043e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
10446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetBooleanStaticFromCode   # (uint32_t field_idx, const Method* referrer, Thread*)
10456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
10466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
10476ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_boolean_static
10486ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a byte primitive value.
10516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
10526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetByteStaticFromCode
10536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_byte_static
10546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1055e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
10566ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetByteStaticFromCode      # (uint32_t field_idx, const Method* referrer, Thread*)
10576ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
10586ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
10596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_byte_static
10606ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10626ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a char primitive value.
10636ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
10646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetCharStaticFromCode
10656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_char_static
10666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1067e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
10686ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetCharStaticFromCode      # (uint32_t field_idx, const Method* referrer, Thread*)
10696ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
10706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
10716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_char_static
10726ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10736ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a short primitive value.
10756ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
10766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetShortStaticFromCode
10776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_short_static
10786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1079e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
10806ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetShortStaticFromCode     # (uint32_t field_idx, const Method* referrer, Thread*)
10816ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
10826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
10836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_short_static
10846ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10856ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10866ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a 32-bit primitive value.
10876ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
10886ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGet32StaticFromCode
10896ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get32_static
10906ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1091e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
10926ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGet32StaticFromCode        # (uint32_t field_idx, const Method* referrer, Thread*)
10936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
10946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
10956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get32_static
10966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
10976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
10986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load a 64-bit primitive value.
10996ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGet64StaticFromCode
11016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get64_static
11026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1103e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGet64StaticFromCode        # (uint32_t field_idx, const Method* referrer, Thread*)
11056ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
11066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get64_static
11086ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and load an object reference.
11116ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11126ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetObjStaticFromCode
11136ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_obj_static
11146ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1115e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetObjStaticFromCode       # (uint32_t field_idx, const Method* referrer, Thread*)
11176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a2, rSELF                    # pass Thread::Current
11186ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11196ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_obj_static
11206ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a boolean primitive value.
11236ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetBooleanInstanceFromCode
11256ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_boolean_instance
11266ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1127e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11286ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*)
11296ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11306ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11316ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_boolean_instance
11326ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a byte primitive value.
11356ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetByteInstanceFromCode
11376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_byte_instance
11386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1139e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetByteInstanceFromCode    # (field_idx, Object*, referrer, Thread*)
11416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11426ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11436ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_byte_instance
11446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a char primitive value.
11476ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11486ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetCharInstanceFromCode
11496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_char_instance
11506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1151e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetCharInstanceFromCode    # (field_idx, Object*, referrer, Thread*)
11536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11556ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_char_instance
11566ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11576ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11586ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a short primitive value.
11596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11606ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetShortInstanceFromCode
11616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_short_instance
11626ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1163e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetShortInstanceFromCode   # (field_idx, Object*, referrer, Thread*)
11656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11676ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_short_instance
11686ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11696ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a 32-bit primitive value.
11716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11726ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGet32InstanceFromCode
11736ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get32_instance
11746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1175e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGet32InstanceFromCode      # (field_idx, Object*, referrer, Thread*)
11776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11796ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get32_instance
11806ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11816ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load a 64-bit primitive value.
11836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11846ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGet64InstanceFromCode
11856ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get64_instance
11866ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1187e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
11886ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGet64InstanceFromCode      # (field_idx, Object*, referrer, Thread*)
11896ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
11906ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
11916ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get64_instance
11926ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
11936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
11946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and load an object reference.
11956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
11966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artGetObjInstanceFromCode
11976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_get_obj_instance
11986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1199e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artGetObjInstanceFromCode     # (field_idx, Object*, referrer, Thread*)
12016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_NO_EXCEPTION
12036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_get_obj_instance
12046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12056ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and store a 8-bit primitive value.
12076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12086ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet8StaticFromCode
12096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set8_static
12106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1211e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12126ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet8StaticFromCode         # (field_idx, new_val, referrer, Thread*)
12136ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12146ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12156ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set8_static
12166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12186ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and store a 16-bit primitive value.
12196ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12206ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet16StaticFromCode
12216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set16_static
12226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1223e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet16StaticFromCode        # (field_idx, new_val, referrer, Thread*)
12256ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12266ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12276ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set16_static
12286ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12296ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12306ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and store a 32-bit primitive value.
12316ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12326ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet32StaticFromCode
12336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set32_static
12346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1235e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet32StaticFromCode        # (field_idx, new_val, referrer, Thread*)
12376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12386ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set32_static
12406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12426ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and store a 64-bit primitive value.
12436ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet64StaticFromCode
12456ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set64_static
12466ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1247e460d1df1f789c7c8bb97024a8efbd713ac175e9Calin Juravle                                         # a2 contains the new val
1248e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet64StaticFromCode        # (field_idx, referrer, new_val, Thread*)
12506ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set64_static
12536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12556ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve a static field and store an object reference.
12566ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12576ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSetObjStaticFromCode
12586ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set_obj_static
12596ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1260e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12616ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSetObjStaticFromCode       # (field_idx, new_val, referrer, Thread*)
12626ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a3, rSELF                    # pass Thread::Current
12636ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12646ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set_obj_static
12656ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12666ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12676ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and store a 8-bit primitive value.
12686ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12696ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet8InstanceFromCode
12706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set8_instance
12716ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1272e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12736ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet8InstanceFromCode       # (field_idx, Object*, new_val, referrer, Thread*)
12746ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a4, rSELF                    # pass Thread::Current
12756ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12766ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set8_instance
12776ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12786ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12796ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and store a 16-bit primitive value.
12806ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12816ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet16InstanceFromCode
12826ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set16_instance
12836ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1284e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12856ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet16InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
12866ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a4, rSELF                    # pass Thread::Current
12876ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
12886ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set16_instance
12896ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
12906ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
12916ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and store a 32-bit primitive value.
12926ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
12936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet32InstanceFromCode
12946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set32_instance
12956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1296e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
12976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet32InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
12986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a4, rSELF                    # pass Thread::Current
12996ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
13006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set32_instance
13016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
13026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
13036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and store a 64-bit primitive value.
13046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
13056ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSet64InstanceFromCode
13066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set64_instance
13076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1308e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
13096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSet64InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
13106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a4, rSELF                    # pass Thread::Current
13116ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
13126ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set64_instance
13136ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
13146ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
13156ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code to resolve an instance field and store an object reference.
13166ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
13176ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artSetObjInstanceFromCode
13186ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_set_obj_instance
13196ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1320e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld     $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp)  # pass referrer's Method*
13216ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artSetObjInstanceFromCode     # (field_idx, Object*, new_val, referrer, Thread*)
13226ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a4, rSELF                    # pass Thread::Current
13236ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RETURN_IF_ZERO
13246ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_set_obj_instance
13256ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
13265ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko// Macro to facilitate adding new allocation entrypoints.
13275ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.macro ONE_ARG_DOWNCALL name, entrypoint, return
13285ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    .extern \entrypoint
13295ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoENTRY \name
13306ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case of GC
13315ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    jal     \entrypoint
13325ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    move    $a1, rSELF                 # pass Thread::Current
13335ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    \return
13345ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoEND \name
13355ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.endm
13361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
13371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe// Macro to facilitate adding new allocation entrypoints.
13381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro TWO_ARG_DOWNCALL name, entrypoint, return
13396ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern \entrypoint
13401a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY \name
13416ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case of GC
13426ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal     \entrypoint
13436ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move    $a2, rSELF                 # pass Thread::Current
13446ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    \return
13451a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND \name
13461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
13471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
13481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.macro THREE_ARG_DOWNCALL name, entrypoint, return
13496ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern \entrypoint
13501a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY \name
13516ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case of GC
13526ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal     \entrypoint
13536ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move    $a3, rSELF                 # pass Thread::Current
13546ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    \return
13551a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND \name
13561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.endm
13571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
1358e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1359e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko    .extern \entrypoint
1360e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir MarkoENTRY \name
1361e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME  # save callee saves in case of GC
1362e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko    jal     \entrypoint
1363e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko    move    $a4, rSELF                 # pass Thread::Current
1364e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko    \return
1365e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir MarkoEND \name
1366e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko.endm
1367e85e123a2dff7d4b20266183a0583f9364a8b824Vladimir Marko
13681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe// Generate the allocation entrypoints for each allocator.
1369982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran JakovljevicGENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
1370982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran JakovljevicGENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB)
1371982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1372982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran JakovljevicENTRY art_quick_alloc_object_rosalloc
1373982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1374982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Fast path rosalloc allocation
1375982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # a0: type_idx
1376982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # a1: ArtMethod*
1377982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # s1: Thread::Current
1378982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # -----------------------------
1379982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # t0: class
1380982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # t1: object size
1381982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # t2: rosalloc run
1382982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # t3: thread stack top offset
1383982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # a4: thread stack bottom offset
1384982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # v0: free list head
1385982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    #
1386982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # a5, a6 : temps
1387982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1388982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_64($a1)   # Load dex cache resolved types array.
1389982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1390982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    dsll   $a5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT        # Shift the value.
1391982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    daddu  $a5, $t0, $a5                                    # Compute the index.
1392982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    lwu    $t0, 0($a5)                                      # Load class (t0).
1393982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    beqzc  $t0, .Lart_quick_alloc_object_rosalloc_slow_path
1394982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1395982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    li     $a6, MIRROR_CLASS_STATUS_INITIALIZED
1396982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    lwu    $a5, MIRROR_CLASS_STATUS_OFFSET($t0)             # Check class status.
1397982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    bnec   $a5, $a6, .Lart_quick_alloc_object_rosalloc_slow_path
1398982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1399982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Add a fake dependence from the following access flag and size loads to the status load. This
1400982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # is to prevent those loads from being reordered above the status load and reading wrong values.
1401982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    xor    $a5, $a5, $a5
1402982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    daddu  $t0, $t0, $a5
1403982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1404982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    lwu    $a5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0)       # Check if access flags has
1405982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    li     $a6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE           # kAccClassIsFinalizable.
1406982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    and    $a6, $a5, $a6
1407982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    bnezc  $a6, .Lart_quick_alloc_object_rosalloc_slow_path
1408982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1409982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)    # Check if thread local allocation stack
1410982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $a4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1)    # has any room left.
1411982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    bgeuc  $t3, $a4, .Lart_quick_alloc_object_rosalloc_slow_path
1412982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1413982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    lwu    $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0)        # Load object size (t1).
1414982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    li     $a5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE      # Check if size is for a thread local
1415982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic                                                            # allocation.
1416982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    bltuc  $a5, $t1, .Lart_quick_alloc_object_rosalloc_slow_path
1417982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1418982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket
1419982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # quantum size and divide by the quantum size and subtract by 1.
1420982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    daddiu $t1, $t1, -1                                     # Decrease obj size and shift right by
1421982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    dsrl   $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT    # quantum.
1422982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1423982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    dsll   $t2, $t1, POINTER_SIZE_SHIFT
1424982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    daddu  $t2, $t2, $s1
1425982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2)            # Load rosalloc run (t2).
1426982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1427982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Load the free list head (v0).
1428982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # NOTE: this will be the return val.
1429982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1430982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    beqzc  $v0, .Lart_quick_alloc_object_rosalloc_slow_path
1431982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1432982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Load the next pointer of the head and update the list head with the next pointer.
1433982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    ld     $a5, ROSALLOC_SLOT_NEXT_OFFSET($v0)
1434982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sd     $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1435982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1436982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Store the class pointer in the header. This also overwrites the first pointer. The offsets are
1437982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # asserted to match.
1438982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1439982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1440982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic#error "Class pointer needs to overwrite next pointer."
1441982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic#endif
1442982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1443982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    POISON_HEAP_REF $t0
1444982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sw     $t0, MIRROR_OBJECT_CLASS_OFFSET($v0)
1445982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1446982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Push the new object onto the thread local allocation stack and increment the thread local
1447982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # allocation stack top.
1448982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sd     $v0, 0($t3)
1449982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    daddiu $t3, $t3, COMPRESSED_REFERENCE_SIZE
1450982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sd     $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)
1451982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1452982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    # Decrement the size of the free list.
1453982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    lw     $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1454982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    addiu  $a5, $a5, -1
1455982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sw     $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1456982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1457982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    sync                                         # Fence.
1458982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1459982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    jalr   $zero, $ra
1460982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    .cpreturn                                    # Restore gp from t8 in branch delay slot.
1461982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1462982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic.Lart_quick_alloc_object_rosalloc_slow_path:
1463982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
1464982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    jal    artAllocObjectFromCodeRosAlloc
1465982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    move   $a2 ,$s1                              # Pass self as argument.
1466982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic    RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1467982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran Jakovljevic
1468982a9a818915a0a03a1b6ac6f05e01934d9d27e8Goran JakovljevicEND art_quick_alloc_object_rosalloc
14691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
14706ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
14715ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
14725ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * exception on error. On success the String is returned. A0 holds the string index. The fast
14735ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * path check for hit in strings cache has already been performed.
14745ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     */
14755ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
14765ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
14775ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    /*
14785ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * Entry from managed code when uninitialized static storage, this stub will run the class
14795ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * initializer and deliver the exception on error. On success the static storage base is
14805ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * returned.
14815ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     */
14825ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
14835ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
14845ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    /*
14855ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * Entry from managed code when dex cache misses for a type_idx.
14865ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     */
14875ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
14885ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
14895ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    /*
14905ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * Entry from managed code when type_idx needs to be checked for access and dex cache may also
14915ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * miss.
14925ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     */
14935ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
14945ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
14955ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    /*
14966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called by managed code when the value in rSUSPEND has been decremented to 0.
14976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
14986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artTestSuspendFromCode
14996ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_test_suspend
15006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    lh     $a0, THREAD_FLAGS_OFFSET(rSELF)
15016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    bne    $a0, $zero, 1f
15026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    daddiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL   # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
15036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jalr   $zero, $ra
150404568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                                 # Restore gp from t8 in branch delay slot.
15056ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic1:
15066ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME         # save callee saves for stack crawl
15076ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal    artTestSuspendFromCode             # (Thread*)
15086ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move   $a0, rSELF
15096ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
15106ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_test_suspend
15116461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung
15126461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    /*
15136461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung     * Called by managed code that is attempting to call a method on a proxy class. On entry
15146461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung     * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
15156461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung     */
15166461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    .extern artQuickProxyInvokeHandler
15176461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas LeungENTRY art_quick_proxy_invoke_handler
15188223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
15196461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    move    $a2, rSELF             # pass Thread::Current
15206461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    jal     artQuickProxyInvokeHandler  # (Method* proxy method, receiver, Thread*, SP)
15216461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    move    $a3, $sp               # pass $sp
15226461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    ld      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
15236461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    daddiu  $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE  # skip a0-a7 and f12-f19
15246461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
15256461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    bne     $t0, $zero, 1f
15266461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    dmtc1   $v0, $f0               # place return value to FP return value
15276461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    jalr    $zero, $ra
15286461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    dmtc1   $v1, $f1               # place return value to FP return value
15296461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung1:
15306461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung    DELIVER_PENDING_EXCEPTION
15316461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas LeungEND art_quick_proxy_invoke_handler
15326461d19fe1132ec25b92d008c1a7b57f5ecc134bDouglas Leung
15336ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
15346ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
15356ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * dex method index.
15366ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
15376ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_imt_conflict_trampoline
15388ea18d0f066f63fa4e5d154f14327468bf288e2bNicolas Geoffray    move    $a0, $t0
15393031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe    INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
15406ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_imt_conflict_trampoline
1541cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe
1542cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    .extern artQuickResolutionTrampoline
1543cc7c39d747f5802282adcc51ffe44405f116f84bAndreas GampeENTRY art_quick_resolution_trampoline
1544cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1545cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    move    $a2, rSELF             # pass Thread::Current
1546cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    jal     artQuickResolutionTrampoline  # (Method* called, receiver, Thread*, SP)
1547cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    move    $a3, $sp               # pass $sp
1548cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    beq     $v0, $zero, 1f
1549e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    ld      $a0, 0($sp)            # load resolved method in $a0
1550cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe                                   # artQuickResolutionTrampoline puts resolved method in *SP
1551cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1552cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    move    $t9, $v0               # code pointer must be in $t9 to generate the global pointer
1553cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    jalr    $zero, $t9             # tail call to method
1554cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    nop
1555cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe1:
1556cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1557cc7c39d747f5802282adcc51ffe44405f116f84bAndreas Gampe    DELIVER_PENDING_EXCEPTION
1558cc7c39d747f5802282adcc51ffe44405f116f84bAndreas GampeEND art_quick_resolution_trampoline
15591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
15601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artQuickGenericJniTrampoline
15611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artQuickGenericJniEndTrampoline
15621a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY art_quick_generic_jni_trampoline
15638223b809a527c15b68f7c5c462d4c55c1335c7a7Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
15641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $s8, $sp               # save $sp
15651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
15661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
15671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a0, rSELF             # pass Thread::Current
15681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a1, $sp               # pass $sp
15691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jal     artQuickGenericJniTrampoline   # (Thread*, SP)
15701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu  $sp, $sp, -5120        # reserve space on the stack
15711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
15721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # The C call will have registered the complete save-frame on success.
15731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # The result of the call is:
15741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # v0: ptr to native code, 0 on error.
15751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
15761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq     $v0, $zero, 1f         # check entry error
15771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $t9, $v0               # save the code ptr
15781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $sp, $v1               # release part of the alloca
15791a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
15801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # Load parameters from stack into registers
15811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a0,   0($sp)
15821a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a1,   8($sp)
15831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a2,  16($sp)
15841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a3,  24($sp)
15851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a4,  32($sp)
15861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a5,  40($sp)
15871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a6,  48($sp)
15881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $a7,  56($sp)
15891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
15901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f12,  0($sp)
15911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f13,  8($sp)
15921a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f14, 16($sp)
15931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f15, 24($sp)
15941a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f16, 32($sp)
15951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f17, 40($sp)
15961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f18, 48($sp)
15971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d     $f19, 56($sp)
15981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr    $t9                    # native call
15991a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu  $sp, $sp, 64
16001a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16011a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # result sign extension is handled in C code
16021a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
16031a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a0, rSELF             # pass Thread::Current
16041a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a1, $v0
16051a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jal     artQuickGenericJniEndTrampoline
16061a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dmfc1   $a2, $f0
16071a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16081a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1609126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    bne     $t0, $zero, 1f         # check for pending exceptions
16101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $sp, $s8               # tear down the alloca
16111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    # tear dpown the callee-save frame
16131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
16141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr    $zero, $ra
16161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dmtc1   $v0, $f0               # place return value to FP return value
16171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
1619126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    ld      $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1620126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    # This will create a new save-all frame, required by the runtime.
16211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    DELIVER_PENDING_EXCEPTION
16221a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_generic_jni_trampoline
16231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artQuickToInterpreterBridge
16251a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY art_quick_to_interpreter_bridge
16261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
16271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a1, rSELF             # pass Thread::Current
16281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jal     artQuickToInterpreterBridge    # (Method* method, Thread*, SP)
16291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move    $a2, $sp               # pass $sp
16301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
16311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu  $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE  # skip a0-a7 and f12-f19
16321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
16331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    bne     $t0, $zero, 1f
16341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dmtc1   $v0, $f0               # place return value to FP return value
16351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr    $zero, $ra
16361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    dmtc1   $v1, $f1               # place return value to FP return value
16371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe1:
16381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    DELIVER_PENDING_EXCEPTION
16391a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_to_interpreter_bridge
16401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
16421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Routine that intercepts method calls and returns.
16431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
16441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artInstrumentationMethodEntryFromCode
16451a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artInstrumentationMethodExitFromCode
16461a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY art_quick_instrumentation_entry
16471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
16481a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu   $sp, $sp, -16     # space for saving arg0
16491a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 16
16501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd       $a0, 0($sp)       # save arg0
16511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $a3, $ra          # pass $ra
16521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jal      artInstrumentationMethodEntryFromCode  # (Method*, Object*, Thread*, RA)
16531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $a2, rSELF        # pass Thread::Current
16541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $t9, $v0          # $t9 holds reference to code
16551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld       $a0, 0($sp)       # restore arg0
16561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu   $sp, $sp, 16      # remove args
16571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -16
16581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
16591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr     $t9               # call method
16601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
16611a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_instrumentation_entry
16621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /* intentional fallthrough */
16631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .global art_quick_instrumentation_exit
16641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampeart_quick_instrumentation_exit:
16651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_startproc
166604568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    SETUP_GP
16671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $ra, $zero        # link register is to here, so clobber with 0 for later checks
16681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
16691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $t0, $sp          # remember bottom of caller's frame
16701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu   $sp, $sp, -16     # save return values and set up args
16711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 16
16721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd       $v0, 0($sp)
16731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 2, 0
16741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    s.d      $f0, 8($sp)
16751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    mov.d    $f15, $f0         # pass fpr result
16761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $a2, $v0          # pass gpr result
16771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $a1, $t0          # pass $sp
16781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $a0, rSELF        # pass Thread::Current
167904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    jal      artInstrumentationMethodExitFromCode  # (Thread*, SP, gpr_res, fpr_res)
168004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                  # Restore gp from t8 in branch delay slot. gp is not used anymore,
168104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic                               # and t8 may be clobbered in artInstrumentationMethodExitFromCode.
168204568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic
1683f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    move     $t9, $v0          # set aside returned link register
16841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move     $ra, $v1          # set link register for deoptimization
16851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld       $v0, 0($sp)       # restore return values
16861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    l.d      $f0, 8($sp)
1687f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    jalr     $zero, $t9        # return
16881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu   $sp, $sp, 16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE  # 16 bytes of saved values + ref_only callee save frame
16891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -(16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE)
16901a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_quick_instrumentation_exit
16911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
16926ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    /*
16936ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
16946ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     * will long jump to the upcall with a special exception of -1.
16956ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic     */
16966ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artDeoptimize
16976ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    .extern artEnterInterpreterFromDeoptimize
16986ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicENTRY art_quick_deoptimize
16996ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
17006ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    jal      artDeoptimize     # artDeoptimize(Thread*, SP)
17016ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic                               # Returns caller method's frame size.
17026ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic    move     $a0, rSELF        # pass Thread::current
17036ea651f0f4c7de4580beb2e887d86802c1ae0738Maja GagicEND art_quick_deoptimize
17046ea651f0f4c7de4580beb2e887d86802c1ae0738Maja Gagic
17050747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    /*
17060747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
17070747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     * will long jump to the upcall with a special exception of -1.
17080747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     */
17090747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    .extern artDeoptimizeFromCompiledCode
17100747466fca310eedea5fc49e37d54f240a0b3c0fSebastien HertzENTRY art_quick_deoptimize_from_compiled_code
17110747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
17120747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    jal      artDeoptimizeFromCompiledCode    # artDeoptimizeFromCompiledCode(Thread*, SP)
17130747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz                                              # Returns caller method's frame size.
17140747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    move     $a0, rSELF                       # pass Thread::current
17150747466fca310eedea5fc49e37d54f240a0b3c0fSebastien HertzEND art_quick_deoptimize_from_compiled_code
17160747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz
17179701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  .set push
17189701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  .set noat
17199701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen/* java.lang.String.compareTo(String anotherString) */
17209701c2ee2dde033e2269dcfc592a09f21151e97eChris LarsenENTRY_NO_GP art_quick_string_compareto
17219701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen/* $a0 holds address of "this" */
17229701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen/* $a1 holds address of "anotherString" */
17239701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  beq    $a0,$a1,9f     # this and anotherString are the same object
17249701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  move   $v0,$zero
17259701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17269701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lw     $a2,MIRROR_STRING_COUNT_OFFSET($a0)    # this.length()
17279701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lw     $a3,MIRROR_STRING_COUNT_OFFSET($a1)    # anotherString.length()
1728cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  MINu   $t2, $a2, $a3
1729cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen# $t2 now holds min(this.length(),anotherString.length())
17309701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17319701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  beqz   $t2,9f         # while min(this.length(),anotherString.length())-i != 0
17329701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  subu   $v0,$a2,$a3    # if $t2==0 return
17339701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen                        #     (this.length() - anotherString.length())
17349701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen1:
17359701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lhu    $t0,MIRROR_STRING_VALUE_OFFSET($a0)    # while this.charAt(i) == anotherString.charAt(i)
17369701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lhu    $t1,MIRROR_STRING_VALUE_OFFSET($a1)
17379701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  bne    $t0,$t1,9f     # if this.charAt(i) != anotherString.charAt(i)
17389701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  subu   $v0,$t0,$t1    #     return (this.charAt(i) - anotherString.charAt(i))
17399701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  daddiu $a0,$a0,2      # point at this.charAt(i++)
17409701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  subu   $t2,$t2,1      # new value of
17419701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen                        # min(this.length(),anotherString.length())-i
17429701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  bnez   $t2,1b
17439701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  daddiu $a1,$a1,2      # point at anotherString.charAt(i++)
17449701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  subu   $v0,$a2,$a3
17459701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17469701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen9:
17479701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  j      $ra
17489701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  nop
17499701c2ee2dde033e2269dcfc592a09f21151e97eChris LarsenEND art_quick_string_compareto
17509701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17519701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen/* java.lang.String.indexOf(int ch, int fromIndex=0) */
17529701c2ee2dde033e2269dcfc592a09f21151e97eChris LarsenENTRY_NO_GP art_quick_indexof
17539701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen/* $a0 holds address of "this" */
1754cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a1 holds "ch" */
1755cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a2 holds "fromIndex" */
17569701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lw    $t0,MIRROR_STRING_COUNT_OFFSET($a0)     # this.length()
1757cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  slt   $at, $a2, $zero # if fromIndex < 0
1758cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  seleqz $a2, $a2, $at  #     fromIndex = 0;
1759cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu  $t0,$t0,$a2     # this.length() - fromIndex
1760cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  blez  $t0,6f          # if this.length()-fromIndex <= 0
17619701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  li    $v0,-1          #     return -1;
17629701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17639701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  sll   $v0,$a2,1       # $a0 += $a2 * 2
17649701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  daddu $a0,$a0,$v0     #  "  "   "  " "
1765cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  move  $v0,$a2         # Set i to fromIndex.
17669701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17679701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen1:
17689701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  lhu   $t3,MIRROR_STRING_VALUE_OFFSET($a0)     # if this.charAt(i) == ch
17699701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  beq   $t3,$a1,6f                              #     return i;
17709701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  daddu $a0,$a0,2       # i++
17719701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  subu  $t0,$t0,1       # this.length() - i
17729701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  bnez  $t0,1b          # while this.length() - i > 0
17739701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  addu  $v0,$v0,1       # i++
17749701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17759701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  li    $v0,-1          # if this.length() - i <= 0
17769701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen                        #     return -1;
17779701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17789701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen6:
17799701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  j     $ra
17809701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  nop
17819701c2ee2dde033e2269dcfc592a09f21151e97eChris LarsenEND art_quick_indexof
17829701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen
17839701c2ee2dde033e2269dcfc592a09f21151e97eChris Larsen  .set pop
1784