diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-02-04 20:49:27 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-02-04 20:49:27 +0000 |
commit | facc279fc19a31c23323ce3eeac869eb14d07bda (patch) | |
tree | f2e35a2ea96bcecfa7499a5ec8161bd2528c22d5 /libjava/resolve.cc | |
parent | a89608cbebb11969af54ba5a5354302fab2a0b4b (diff) | |
download | gcc-facc279fc19a31c23323ce3eeac869eb14d07bda.zip gcc-facc279fc19a31c23323ce3eeac869eb14d07bda.tar.gz gcc-facc279fc19a31c23323ce3eeac869eb14d07bda.tar.bz2 |
defineclass.cc (handleMethodsBegin): Allocate _Jv_MethodBase pointers.
* defineclass.cc (handleMethodsBegin): Allocate _Jv_MethodBase
pointers.
(handleMethodsEnd): Fixed error messages. Create a _Jv_JNIMethod
if the method is native.
* resolve.cc (ncode): Don't handle native methods.
(_Jv_JNIMethod::ncode): New method.
(_Jv_PrepareClass): Handle native methods.
* jni.cc (call): Renamed from _Jv_JNI_conversion_call.
Include AbstractMethodError.h.
(add_char): New function.
(mangled_name): Likewise.
* include/java-interp.h (class _Jv_JNIMethod): New class.
(class _Jv_MethodBase): New class.
(class _Jv_InterpMethod): Derive from _Jv_MethodBase.
(_Jv_InterpClass): Changed `interpreted_methods' field to type
`_Jv_MethodBase'.
* include/jvm.h (_Jv_FindSymbolInExecutable): Declare.
* java/lang/natRuntime.cc (libraries_size, libraries_count,
libraries): New globals.
(add_library): New function.
(_Jv_FindSymbolInExecutable): New function.
* java/lang/natClassLoader.cc (initiated_classes, loaded_classes):
Now static.
From-SVN: r31790
Diffstat (limited to 'libjava/resolve.cc')
-rw-r--r-- | libjava/resolve.cc | 84 |
1 files changed, 56 insertions, 28 deletions
diff --git a/libjava/resolve.cc b/libjava/resolve.cc index 0bf6f8c..eb9a371 100644 --- a/libjava/resolve.cc +++ b/libjava/resolve.cc @@ -563,21 +563,21 @@ _Jv_PrepareClass(jclass klass) have code -- for static constructors. */ for (int i = 0; i < clz->method_count; i++) { - _Jv_InterpMethod *imeth = clz->interpreted_methods[i]; + _Jv_MethodBase *imeth = clz->interpreted_methods[i]; - if (imeth != 0) // it could be abstract or native + if ((clz->methods[i].accflags & Modifier::NATIVE) != 0) { - clz->methods[i].ncode = imeth->ncode (); + // You might think we could use a virtual `ncode' method in + // the _Jv_MethodBase and unify the native and non-native + // cases. Well, we can't, because we don't allocate these + // objects using `new', and thus they don't get a vtable. + _Jv_JNIMethod *jnim = reinterpret_cast<_Jv_JNIMethod *> (imeth); + clz->methods[i].ncode = jnim->ncode (); } - else + else if (imeth != 0) // it could be abstract { - if ((clz->methods[i].accflags & Modifier::NATIVE) != 0) - { - JvThrow - (new java::lang::VirtualMachineError - (JvNewStringLatin1 - ("the interpreter does not support native methods"))); - } + _Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (im); + clz->methods[i].ncode = im->ncode (); } } @@ -588,13 +588,6 @@ _Jv_PrepareClass(jclass klass) return; } - /* FIXME: native methods for interpreted classes should be handled, I - * dunno exactly how, but it seems that we should try to find them at - * this point, and if we fail, try again after <clinit>, since it - * could have caused additional code to be loaded. Interfaces cannot - * have native methods (not even for static initialization). */ - - /* Now onto the actual job: vtable layout. First, count how many new methods we have */ int new_method_count = 0; @@ -1022,13 +1015,9 @@ _Jv_InterpMethod::ncode () args_raw_size = ffi_raw_size (&closure->cif); - 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) + JvAssert ((self->accflags & Modifier::NATIVE) == 0); + + if ((self->accflags & Modifier::SYNCHRONIZED) != 0) { if (staticp) fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class; @@ -1041,9 +1030,48 @@ _Jv_InterpMethod::ncode () } ffi_prep_raw_closure (&closure->closure, - &closure->cif, - fun, - (void*)this); + &closure->cif, + fun, + (void*) this); + + self->ncode = (void*)closure; + return self->ncode; +} + + +void * +_Jv_JNIMethod::ncode () +{ + using namespace java::lang::reflect; + + if (self->ncode != 0) + return self->ncode; + + jboolean staticp = (self->accflags & Modifier::STATIC) != 0; + int arg_count = count_arguments (self->signature, staticp); + + ncode_closure *closure = + (ncode_closure*)_Jv_AllocBytesChecked (sizeof (ncode_closure) + + arg_count * sizeof (ffi_type*)); + + init_cif (self->signature, + arg_count, + staticp, + &closure->cif, + &closure->arg_types[0]); + + ffi_closure_fun fun; + + JvAssert ((self->accflags & Modifier::NATIVE) != 0); + + // FIXME: for now we assume that all native methods for + // interpreted code use JNI. + fun = (ffi_closure_fun) &_Jv_JNIMethod::call; + + ffi_prep_raw_closure (&closure->closure, + &closure->cif, + fun, + (void*) this); self->ncode = (void*)closure; return self->ncode; |