This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: very slow jni code callbacks
- From: Bryce McKinlay <bmckinlay at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Herman ten Brugge <hermantenbrugge at home dot nl>, java at gcc dot gnu dot org, Tom Tromey <tromey at redhat dot com>
- Date: Mon, 28 Sep 2009 13:10:17 +0100
- Subject: Re: very slow jni code callbacks
- References: <4ABF6753.20507@home.nl> <4AC0A614.2040108@redhat.com>
On Mon, Sep 28, 2009 at 1:03 PM, Andrew Haley <aph@redhat.com> wrote:
>> When I use oprofile I see at lot of calls to execute_cfa_program
>> and _Unwind_IteratePhdrCallback.
>
> I think this is a bug. ?I've had a look at the code, and it's in
> jni.cc: _Jv_JNI_CallAnyVoidMethodV
>
> This calls _Jv_GetTypesFromSignature, which in turn iterates though
> all the class loaders looking up the types of all the arguments.
> But as far as I can see this is a pointless waste of time: the only
> use of the type of each argument is to determine whether it's a
> primitive type or not, and we could certainly have done that when
> we created the jmethodID. ?There is a field in the method struct called
> ffi_arg_types, but I think it isn't used when calling C to Java via JNI.
I think the underlying issue is that jMethodID is typedef'ed to
libgcj's internal _Jv_Method. It really needs to use something more
like the interpreter's _Jv_ResolvedMethod or _Jv_JNIMethod so that the
arg types and return type (and, in fact, the ffi_cif itself) can be
resolved once and reused.
Bryce