This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
status of inter-class inlining in Java?
- From: Andrew Haley <aph at redhat dot com>
- To: neroden at twcny dot rr dot com (Nathanael Nerode)
- Cc: java at gcc dot gnu dot org
- Date: Fri, 16 Jul 2004 10:42:11 +0100
- Subject: status of inter-class inlining in Java?
- References: <20040716080831.GA29283@twcny.rr.com>
Nathanael Nerode writes:
> Consider the following sort of potential situation in libgcj:
>
> class System {
> public static final foo() {
> B.foo();
> }
> }
>
> class VMSystem {
> static final foo() {
> ...
> }
> }
>
> Preferably VMSystem.foo should be inlined into System.foo during compilation.
> (This would make it reasonable to merge a bunch more with Classpath, and
> would more generally help with the indirection penalty caused by the rampant
> forwarding methods used in much of Java.)
>
> >From what I can tell, however, this doesn't seem to happen.
It works for me.
public class b
{
public static int vvalue()
{
return 25;
}
}
import b;
public class a
{
public static void main (String[] argv)
{
System.out.println (b.vvalue());
}
}
gcj a.java b.java -o bar -O3
Results in
a.main(java.lang.String[]):
.LFB4:
pushl %ebp
.LCFI9:
movl %esp, %ebp
.LCFI10:
pushl %ebx
.LCFI11:
subl 20, %esp
.LCFI12:
movl a.class$, (%esp)
call _Jv_InitClass
movl java.lang.System.class$, (%esp)
call _Jv_InitClass
movl java.lang.System.out, %ebx
movl b.class$, (%esp)
call _Jv_InitClass
movl 25, %edx
movl (%ebx), %eax
movl %edx, 4(%esp)
movl %ebx, (%esp)
call *100(%eax)
addl 20, %esp
popl %ebx
popl %ebp
ret
Andrew.