This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: Patch: Make Method.invoke() and JNI_CallAnyMethod use vtables


On Oct 28, 2003, at 12:18 PM, Tom Tromey wrote:

Suppose the method or class is final.  Might  we not wind up making a
virtual-style call where meth->index == -1?

I think final methods should always get vtable entries, even if they are not used for "internal" dispatch in a binary. Thats because removing the "final" modifier does not break pre-existing binaries according to the BC rules, so external calls must use the vtable.


The runtime layout code in libgcj certainly does this, I was under the impression the compiler does as well but this would be worth checking.

Bryce> Incidentally, JNI calls seem to be at least 10X
Bryce> slower than the JRE (for java->native calls, which this patch doesn't
Bryce> effect). I imagine that speeding JNI up would help SWT and AWT
Bryce> significantly.


I assume you mean a call from java code to a native method implemented
as JNI.  How did you measure this?  I'd guess that the first such call
to a given method would be very slow, then faster on the second call,
after we look up and cache the pointer.

Right. This is just a simple benchmark that measures JNI and non-JNI calls in a loop, the test is attached below.


[bryce@hokkaido invbench]$ java Bench
no call:           26ms [5ns / call]
local:             23ms [4ns / call]
private:           18ms [3ns / call]
interface:         97ms [19ns / call]
i/f after cast:   101ms [20ns / call]
abstract:          95ms [19ns / call]
abstract w/cast:   94ms [18ns / call]
native:           317ms [63ns / call]
140000028

[bryce@hokkaido invbench]$ ./invbench
no call:           10ms [2ns / call]
local:             65ms [13ns / call]
private:           10ms [2ns / call]
interface:        134ms [26ns / call]
i/f after cast:    55ms [11ns / call]
abstract:          65ms [13ns / call]
abstract w/cast:   57ms [11ns / call]
native:          3193ms [638ns / call]
140000028

Regards

Bryce.


Attachment: invbench.tar.gz
Description: GNU Zip compressed data



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]