diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-02-02 01:55:03 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-02-02 01:55:03 +0000 |
commit | ee6713e782d582a0fa150ed53842df0e258c028e (patch) | |
tree | 8cea920cda9b81eaa6f6464de2909e0016f6ec15 /libjava | |
parent | 8928191114d5e13d4649a79dea5ca0328285fb8c (diff) | |
download | gcc-ee6713e782d582a0fa150ed53842df0e258c028e.zip gcc-ee6713e782d582a0fa150ed53842df0e258c028e.tar.gz gcc-ee6713e782d582a0fa150ed53842df0e258c028e.tar.bz2 |
java-interp.h (_Jv_JNI_conversion_call): Declare.
* include/java-interp.h (_Jv_JNI_conversion_call): Declare.
* resolve.cc (ncode): Use _Jv_JNI_conversion_call when
constructing the closure if the function is native.
* jni.cc (_Jv_JNI_conversion_call): Now returns `void'. No longer
a template function, #if'd out, or static.
Include <java-interp.h>.
From-SVN: r31746
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 7 | ||||
-rw-r--r-- | libjava/include/java-interp.h | 5 | ||||
-rw-r--r-- | libjava/include/jvm.h | 1 | ||||
-rw-r--r-- | libjava/jni.cc | 29 | ||||
-rw-r--r-- | libjava/resolve.cc | 8 |
5 files changed, 37 insertions, 13 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index b9e6123..2723767 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,12 @@ 2000-02-01 Tom Tromey <tromey@cygnus.com> + * include/java-interp.h (_Jv_JNI_conversion_call): Declare. + * resolve.cc (ncode): Use _Jv_JNI_conversion_call when + constructing the closure if the function is native. + * jni.cc (_Jv_JNI_conversion_call): Now returns `void'. No longer + a template function, #if'd out, or static. + Include <java-interp.h>. + * include/jni.h (class _Jv_JNIEnv): Corrected calls using `...'. * include/jni.h (class _Jv_JNIEnv): Added all C++ inline methods. diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h index 8225455..0feab21 100644 --- a/libjava/include/java-interp.h +++ b/libjava/include/java-interp.h @@ -1,6 +1,6 @@ // java-interp.h - Header file for the bytecode interpreter. -*- c++ -*- -/* Copyright (C) 1999 Red Hat, Inc. +/* Copyright (C) 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -121,6 +121,9 @@ class _Jv_InterpMethod { friend class gnu::gcj::runtime::MethodInvocation; friend void _Jv_PrepareClass(jclass); + + // This function is used when making a JNI call from the interpreter. + friend void _Jv_JNI_conversion_call (ffi_cif *, void *, ffi_raw *, void *); }; class _Jv_InterpMethodInvocation { diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index c9eb1b95..ccf552a 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -204,5 +204,4 @@ extern void _Jv_ThisExecutable (const char *); /* Initialize JNI. */ extern void _Jv_JNI_Init (void); - #endif /* __JAVA_JVM_H__ */ diff --git a/libjava/jni.cc b/libjava/jni.cc index 1d8ee55..cb72261 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -45,6 +45,8 @@ details. */ #include <gcj/method.h> #include <gcj/field.h> +#include <java-interp.h> + #define ClassClass _CL_Q34java4lang5Class extern java::lang::Class ClassClass; #define ObjectClass _CL_Q34java4lang6Object @@ -1204,11 +1206,14 @@ _Jv_JNI_FromReflectedMethod (JNIEnv *, jobject method) // This function is the stub which is used to turn an ordinary (CNI) // method call into a JNI call. -#if 0 -template<typename T> -static T -_Jv_JNI_conversion_call (fixme) +void +_Jv_JNI_conversion_call (ffi_cif *cif, + void *ret, + ffi_raw *args, + void *__this) { + _Jv_InterpMethod* _this = (_Jv_InterpMethod*)__this; + JNIEnv env; _Jv_JNI_LocalFrame *frame = (_Jv_JNI_LocalFrame *) alloca (sizeof (_Jv_JNI_LocalFrame) @@ -1216,7 +1221,7 @@ _Jv_JNI_conversion_call (fixme) env.p = &_Jv_JNIFunctions; env.ex = NULL; - env.klass = FIXME; + env.klass = _this->defining_class; env.locals = frame; frame->marker = true; @@ -1225,20 +1230,24 @@ _Jv_JNI_conversion_call (fixme) for (int i = 0; i < frame->size; ++i) frame->vec[i] = NULL; - T result = FIXME_ffi_call (args); + // FIXME: we should mark every reference parameter as a local. For + // now we assume a conservative GC, and we assume that the + // references are on the stack somewhere. + + ffi_raw_call (cif, + NULL, // FIXME: function pointer. + ret, + args); do { - _Jv_JNI_PopLocalFrame (&env, result); + _Jv_JNI_PopLocalFrame (&env, NULL); } while (env.locals != frame); if (env.ex) JvThrow (env.ex); - - return T; } -#endif diff --git a/libjava/resolve.cc b/libjava/resolve.cc index 92d66c2..0bf6f8c 100644 --- a/libjava/resolve.cc +++ b/libjava/resolve.cc @@ -1022,7 +1022,13 @@ _Jv_InterpMethod::ncode () args_raw_size = ffi_raw_size (&closure->cif); - if ((self->accflags & Modifier::SYNCHRONIZED) != 0) + if ((self->accflags & Modifier::NATIVE) != 0) + { + // FIXME: for now we assume that all native methods for + // interpreted code use JNI. + fun = (ffi_closure_fun) &_Jv_JNI_conversion_call; + } + else if ((self->accflags & Modifier::SYNCHRONIZED) != 0) { if (staticp) fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class; |