2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * JNI method invocation. This is used to call a C/C++ JNI method. The
18 * argument list has to be pushed onto the native stack according to
19 * local calling conventions.
21 * This version supports 32-bit x86
27 void dvmPlatformInvoke(void* pEnv, ClassObject* clazz, int argInfo, int argc,
28 const u4* argv, const char* signature, void* func, JValue* pReturn)
30 The method we are calling has the form:
32 return_type func(JNIEnv* pEnv, ClassObject* clazz, ...)
34 return_type func(JNIEnv* pEnv, Object* this, ...)
36 We receive a collection of 32-bit values which correspond to arguments from
37 the interpreter (e.g. float occupies one, double occupies two). It's up to
38 us to convert these into local calling conventions.
44 The native code expects arguments on the stack, pushed from right to left.
45 This matches what Dalvik is passing here.
47 EAX, EDX and ECX are scratch.
49 4-byte alignment is required for long long and double, so we won't pad
51 Non-FP return types <= 4 bytes come back in EAX
52 Non-FP return types of 8 bytes come back in EAX:EDX, with lsw in EAX.
53 Float and double returned on top of FP stack.
58 .global dvmPlatformInvoke
59 .type dvmPlatformInvoke, @function
63 * [ 8] arg0 JNIEnv (can be left alone)
64 * [12] arg1 clazz (NULL for virtual method calls, non-NULL for static)
68 * [28] arg5 short signature
72 * For a virtual method call, the "this" reference is in argv[0].
74 * argInfo (32-bit int) layout:
75 * SRRRZZZZ ZZZZZZZZ AAAAAAAA AAAAAAAA
78 * S - if set, argInfo hints are invalid
79 * R - return type enumeration (see jniInternal.h)
85 * A - size of the variable argument block in 32-bit words
89 /* Establish the frame pointer, spill & align to 16b */
96 /* For 386 ABI, argInfo hints should always be valid. Abort if not. */
100 /* Get the size of the variable region and grow (preserving alignment) */
102 leal 12(,%ecx,4),%ecx
103 andl $0x0003FFF0,%ecx
105 /* Handle this/class */
116 /* Now, copy the variable arguments region */
118 andl $0x0000FFFF,%ecx
123 /* Ready to go - call the native code */
125 /* Store the result. */
134 cmpl $4,%ebx /* smaller than 32-bits? */
137 /* Blindly storing 64-bits won't hurt 32-bit case */
142 cmpl $7,%ebx /* S1? */
148 cmpl $6,%eax /* U2? */
172 .size dvmPlatformInvoke, .-dvmPlatformInvoke
173 .section .note.GNU-stack,"",@progbits