blob: fca6d777ab3c70a406d64f69e9dcdce8d67ba311 [file] [log] [blame]
Ian Rogers7655f292013-07-29 11:07:13 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "asm_support_mips.S"
18
19 .set noreorder
20 .balign 4
21
22 /*
23 * Jni dlsym lookup stub.
24 */
25 .extern artFindNativeMethod
26ENTRY art_jni_dlsym_lookup_stub
27 GENERATE_GLOBAL_POINTER
28 addiu $sp, $sp, -32 # leave room for $a0, $a1, $a2, $a3, and $ra
29 .cfi_adjust_cfa_offset 32
30 sw $ra, 16($sp)
31 .cfi_rel_offset 31, 16
32 sw $a3, 12($sp)
33 .cfi_rel_offset 7, 12
34 sw $a2, 8($sp)
35 .cfi_rel_offset 6, 8
36 sw $a1, 4($sp)
37 .cfi_rel_offset 5, 4
38 sw $a0, 0($sp)
39 .cfi_rel_offset 4, 0
40 jal artFindNativeMethod # (Thread*)
41 move $a0, $s1 # pass Thread::Current()
42 lw $a0, 0($sp) # restore registers from stack
43 lw $a1, 4($sp)
44 lw $a2, 8($sp)
45 lw $a3, 12($sp)
46 lw $ra, 16($sp)
47 beq $v0, $zero, no_native_code_found
48 addiu $sp, $sp, 32 # restore the stack
49 .cfi_adjust_cfa_offset -32
50 move $t9, $v0 # put method code result in $t9
51 jr $t9 # leaf call to method's code
52 nop
53no_native_code_found:
54 jr $ra
55 nop
56END art_jni_dlsym_lookup_stub
57
58 /*
59 * Entry point of native methods when JNI bug compatibility is enabled.
60 */
61 .extern artWorkAroundAppJniBugs
62ENTRY art_quick_work_around_app_jni_bugs
63 GENERATE_GLOBAL_POINTER
64 # save registers that may contain arguments and LR that will be crushed by a call
65 addiu $sp, $sp, -32
66 .cfi_adjust_cfa_offset 32
67 sw $ra, 28($sp)
68 .cfi_rel_offset 31, 28
69 sw $a3, 24($sp)
70 .cfi_rel_offset 7, 28
71 sw $a2, 20($sp)
72 .cfi_rel_offset 6, 28
73 sw $a1, 16($sp)
74 .cfi_rel_offset 5, 28
75 sw $a0, 12($sp)
76 .cfi_rel_offset 4, 28
77 move $a0, rSELF # pass Thread::Current
78 jal artWorkAroundAppJniBugs # (Thread*, $sp)
79 move $a1, $sp # pass $sp
80 move $t9, $v0 # save target address
81 lw $a0, 12($sp)
82 lw $a1, 16($sp)
83 lw $a2, 20($sp)
84 lw $a3, 24($sp)
85 lw $ra, 28($sp)
86 jr $t9 # tail call into JNI routine
87 addiu $sp, $sp, 32
88 .cfi_adjust_cfa_offset -32
89END art_quick_work_around_app_jni_bugs