17655f29fabc0a12765de828914a18314382e5a35Ian Rogers/*
27655f29fabc0a12765de828914a18314382e5a35Ian Rogers * Copyright (C) 2012 The Android Open Source Project
37655f29fabc0a12765de828914a18314382e5a35Ian Rogers *
47655f29fabc0a12765de828914a18314382e5a35Ian Rogers * Licensed under the Apache License, Version 2.0 (the "License");
57655f29fabc0a12765de828914a18314382e5a35Ian Rogers * you may not use this file except in compliance with the License.
67655f29fabc0a12765de828914a18314382e5a35Ian Rogers * You may obtain a copy of the License at
77655f29fabc0a12765de828914a18314382e5a35Ian Rogers *
87655f29fabc0a12765de828914a18314382e5a35Ian Rogers *      http://www.apache.org/licenses/LICENSE-2.0
97655f29fabc0a12765de828914a18314382e5a35Ian Rogers *
107655f29fabc0a12765de828914a18314382e5a35Ian Rogers * Unless required by applicable law or agreed to in writing, software
117655f29fabc0a12765de828914a18314382e5a35Ian Rogers * distributed under the License is distributed on an "AS IS" BASIS,
127655f29fabc0a12765de828914a18314382e5a35Ian Rogers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137655f29fabc0a12765de828914a18314382e5a35Ian Rogers * See the License for the specific language governing permissions and
147655f29fabc0a12765de828914a18314382e5a35Ian Rogers * limitations under the License.
157655f29fabc0a12765de828914a18314382e5a35Ian Rogers */
167655f29fabc0a12765de828914a18314382e5a35Ian Rogers
177655f29fabc0a12765de828914a18314382e5a35Ian Rogers#include "asm_support_x86.S"
187655f29fabc0a12765de828914a18314382e5a35Ian Rogers
197655f29fabc0a12765de828914a18314382e5a35Ian Rogers    /*
20ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers     * Jni dlsym lookup stub.
217655f29fabc0a12765de828914a18314382e5a35Ian Rogers     */
227655f29fabc0a12765de828914a18314382e5a35Ian RogersDEFINE_FUNCTION art_jni_dlsym_lookup_stub
238d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    subl LITERAL(8), %esp         // align stack
248d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    CFI_ADJUST_CFA_OFFSET(8)
257655f29fabc0a12765de828914a18314382e5a35Ian Rogers    pushl %fs:THREAD_SELF_OFFSET  // pass Thread::Current()
269f66589f3ca6055501c99333a19b69349b8f8568Christopher Ferris    CFI_ADJUST_CFA_OFFSET(4)
278d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    call SYMBOL(artFindNativeMethod)  // (Thread*)
288d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    addl LITERAL(12), %esp        // remove argument & padding
298d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    CFI_ADJUST_CFA_OFFSET(-12)
308d98ac61fca47c13f8586ab635c37ef5460b3749Andreas Gampe    testl %eax, %eax              // check if returned method code is null
31bf6b92a158053c98b15f4393abb3b86344ec9a20Andreas Gampe    jz .Lno_native_code_found     // if null, jump to return to handle
327655f29fabc0a12765de828914a18314382e5a35Ian Rogers    jmp *%eax                     // otherwise, tail call to intended method
338016a12a5f9c2ea70b52e353a0169ba836ee9402Ian Rogers.Lno_native_code_found:
347655f29fabc0a12765de828914a18314382e5a35Ian Rogers    ret
357655f29fabc0a12765de828914a18314382e5a35Ian RogersEND_FUNCTION art_jni_dlsym_lookup_stub
36