1 /* 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_x86_64.S" 18 19 /* 20 * Jni dlsym lookup stub. 21 */ 22 DEFINE_FUNCTION art_jni_dlsym_lookup_stub 23 // Save callee and GPR args, mixed together to agree with core spills bitmap. 24 PUSH r9 // Arg. 25 PUSH r8 // Arg. 26 PUSH rdi // JniEnv. 27 PUSH rsi // Arg. 28 PUSH rdx // Arg. 29 PUSH rcx // Arg. 30 // Create space for FPR args, plus padding for alignment 31 subq LITERAL(72 + 4 * 8), %rsp 32 CFI_ADJUST_CFA_OFFSET(72 + 4 * 8) 33 // Save FPRs. 34 movq %xmm0, 0(%rsp) 35 movq %xmm1, 8(%rsp) 36 movq %xmm2, 16(%rsp) 37 movq %xmm3, 24(%rsp) 38 movq %xmm4, 32(%rsp) 39 movq %xmm5, 40(%rsp) 40 movq %xmm6, 48(%rsp) 41 movq %xmm7, 56(%rsp) 42 movq %xmm12, 64(%rsp) 43 movq %xmm13, 72(%rsp) 44 movq %xmm14, 80(%rsp) 45 movq %xmm15, 88(%rsp) 46 // prepare call 47 movq %gs:THREAD_SELF_OFFSET, %rdi // RDI := Thread::Current() 48 // call 49 call PLT_SYMBOL(artFindNativeMethod) // (Thread*) 50 // restore arguments 51 movq 0(%rsp), %xmm0 52 movq 8(%rsp), %xmm1 53 movq 16(%rsp), %xmm2 54 movq 24(%rsp), %xmm3 55 movq 32(%rsp), %xmm4 56 movq 40(%rsp), %xmm5 57 movq 48(%rsp), %xmm6 58 movq 56(%rsp), %xmm7 59 movq 64(%rsp), %xmm12 60 movq 72(%rsp), %xmm13 61 movq 80(%rsp), %xmm14 62 movq 88(%rsp), %xmm15 63 addq LITERAL(72 + 4 * 8), %rsp 64 CFI_ADJUST_CFA_OFFSET(-72 - 4 * 8) 65 POP rcx // Arg. 66 POP rdx // Arg. 67 POP rsi // Arg. 68 POP rdi // JniEnv. 69 POP r8 // Arg. 70 POP r9 // Arg. 71 testq %rax, %rax // check if returned method code is null 72 jz .Lno_native_code_found // if null, jump to return to handle 73 jmp *%rax // otherwise, tail call to intended method 74 .Lno_native_code_found: 75 ret 76 END_FUNCTION art_jni_dlsym_lookup_stub 77