summaryrefslogtreecommitdiff
path: root/libjava/resolve.cc
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-02-16 00:07:34 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-02-16 00:07:34 +0000
commita82244f012d6c61bc27634963b5e7c25c72a16ed (patch)
treefd8526541777f72d0a207a77149193b5171b7e75 /libjava/resolve.cc
parent82eb11029e6a84cc342178e50b15827facb5f23f (diff)
downloadgcc-a82244f012d6c61bc27634963b5e7c25c72a16ed.tar.gz
* resolve.cc (ncode): Set args_raw_size. Compute jni_cif and
jni_arg_types. (init_cif): Added `rtype_p' argument. * include/java-interp.h (class _Jv_MethodBase): Added args_raw_size. (class _Jv_InterpMethod): Removed args_raw_size. (class _Jv_JNIMethod): Added jni_cif and jni_arg_types fields. * jni.cc (call): Pass JNIEnv and (for static methods only) the class pointer as well as the ordinary arguments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31995 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/resolve.cc')
-rw-r--r--libjava/resolve.cc39
1 files changed, 34 insertions, 5 deletions
diff --git a/libjava/resolve.cc b/libjava/resolve.cc
index 0d39de1ee6a..634c08fa11e 100644
--- a/libjava/resolve.cc
+++ b/libjava/resolve.cc
@@ -941,7 +941,8 @@ init_cif (_Jv_Utf8Const* signature,
int arg_count,
jboolean staticp,
ffi_cif *cif,
- ffi_type **arg_types)
+ ffi_type **arg_types,
+ ffi_type **rtype_p)
{
unsigned char *ptr = (unsigned char*) signature->data;
@@ -983,6 +984,9 @@ init_cif (_Jv_Utf8Const* signature,
arg_count, rtype, arg_types) != FFI_OK)
throw_internal_error ("ffi_prep_cif failed");
+ if (rtype_p != NULL)
+ *rtype_p = rtype;
+
return item_count;
}
@@ -1019,7 +1023,8 @@ _Jv_InterpMethod::ncode ()
arg_count,
staticp,
&closure->cif,
- &closure->arg_types[0]);
+ &closure->arg_types[0],
+ NULL);
ffi_closure_fun fun;
@@ -1064,14 +1069,37 @@ _Jv_JNIMethod::ncode ()
(ncode_closure*)_Jv_AllocBytesChecked (sizeof (ncode_closure)
+ arg_count * sizeof (ffi_type*));
+ ffi_type *rtype;
init_cif (self->signature,
arg_count,
staticp,
&closure->cif,
- &closure->arg_types[0]);
+ &closure->arg_types[0],
+ &rtype);
ffi_closure_fun fun;
+ args_raw_size = ffi_raw_size (&closure->cif);
+
+ // Initialize the argument types and CIF that represent the actual
+ // underlying JNI function.
+ int extra_args = 1;
+ if ((self->accflags & Modifier::STATIC))
+ ++extra_args;
+ jni_arg_types = (ffi_type **) _Jv_Malloc ((extra_args + arg_count)
+ * sizeof (ffi_type *));
+ int offset = 0;
+ jni_arg_types[offset++] = &ffi_type_pointer;
+ if ((self->accflags & Modifier::STATIC))
+ jni_arg_types[offset++] = &ffi_type_pointer;
+ memcpy (&jni_arg_types[offset], &closure->arg_types[0],
+ arg_count * sizeof (ffi_type *));
+
+ if (ffi_prep_cif (&jni_cif, FFI_DEFAULT_ABI,
+ extra_args + arg_count, rtype,
+ jni_arg_types) != FFI_OK)
+ throw_internal_error ("ffi_prep_cif failed for JNI function");
+
JvAssert ((self->accflags & Modifier::NATIVE) != 0);
// FIXME: for now we assume that all native methods for
@@ -1083,7 +1111,7 @@ _Jv_JNIMethod::ncode ()
fun,
(void*) this);
- self->ncode = (void*)closure;
+ self->ncode = (void *) closure;
return self->ncode;
}
@@ -1107,7 +1135,8 @@ _Jv_BuildResolvedMethod (_Jv_Method* method,
arg_count,
staticp,
&result->cif,
- &result->arg_types[0]);
+ &result->arg_types[0],
+ NULL);
result->vtable_index = vtable_index;
result->method = method;