status of inter-class inlining in Java?
Andrew Haley
aph@redhat.com
Fri Jul 16 09:42:00 GMT 2004
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.
More information about the Java
mailing list