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    .set noreorder
201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .balign 16
211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe
221a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    /*
231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     * Jni dlsym lookup stub.
241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe     */
251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .extern artFindNativeMethod
261a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeENTRY art_jni_dlsym_lookup_stub
271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, -80        # save a0-a7 and $ra
281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset 80
291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    sd     $ra, 64($sp)
301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 31, 64
3175c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a7, 56($sp)
321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 11, 56
3375c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a6, 48($sp)
341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 10, 48
3575c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a5, 40($sp)
361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 9, 40
3775c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a4, 32($sp)
381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 8, 32
3975c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a3, 24($sp)
401a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 7, 24
4175c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a2, 16($sp)
421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 6, 16
4375c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a1, 8($sp)
441a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 5, 8
4575c40d419b621342ac834e5b61abcdcd84537063Goran Jakovljevic    sd     $a0, 0($sp)
461a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_rel_offset 4, 0
471a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $a0, $s1             # pass Thread::Current()
4804568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    jal    artFindNativeMethod  # (Thread*)
4904568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic    .cpreturn                   # Restore gp from t8 in branch delay slot. gp is not used
5004568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic                                # anymore, and t8 may be clobbered in artFindNativeMethod.
5104568815cbfa18f0fa8b8d751fb83a1089909660Goran Jakovljevic
521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a0, 0($sp)          # restore registers from stack
531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 4
541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a1, 8($sp)
551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 5
561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a2, 16($sp)
571a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 6
581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a3, 24($sp)
591a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 7
601a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a4, 32($sp)
611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 8
621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a5, 40($sp)
631a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 9
641a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a6, 48($sp)
651a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 10
661a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $a7, 56($sp)
671a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 11
681a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    ld     $ra, 64($sp)
691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_restore 31
701a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    beq    $v0, $zero, .Lno_native_code_found
711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    daddiu $sp, $sp, 80         # restore the stack
721a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    .cfi_adjust_cfa_offset -80
731a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    move   $t9, $v0             # put method code result in $t9
741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $t9           # leaf call to method's code
751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
761a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe.Lno_native_code_found:
771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    jalr   $zero, $ra
781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe    nop
791a5c40672783fac98aca5a04ac798a0a0014de65Andreas GampeEND art_jni_dlsym_lookup_stub
80