inlining methods
Per Bothner
per@bothner.com
Tue Oct 26 15:24:00 GMT 1999
Matt Welsh <mdw@cs.berkeley.edu> writes:
> As far as I can tell, GCJ isn't inlining methods at all, which is really
> unfortunate. I'm rather surprised, as well, since it should be possible to
> do this!
If I remember correctly, either -O3 or -O2 -finline-functions should
cause "promising" functions to be inlined, even if they are not
explicitly marked as inlineable. I believe this is a function of the
Gcc backend, and nothing that gcj needs to do specifically.
In addition, Gcc should inline functions specifically marked
as inlineable at -O2, maybe even -O1. This is the case for C++,
which (I believe) sets the DECL_INLINE flag if the "inline"
specified is seen (or implied). A grep through gcc/java/*.[chy]
for DECL_INLINE fail to find a match. It should be easy to
fix gcj so that final, private, or static methods are
given the DEC_INLINE attribute. It might be better, but slightly
more difficult to only do so for "short" methods. However, I'm
not sure; I don't think gcc will inline really long functions
even if they are marked with DECL_INLINE.
So I suggest:
(1) Experiment with -O3.
(2) Set DECL_INLINE on all methods that are final, private, or static.
(Look for where METHOD_FINAL, METHOD_STATIC, or METHOD_PRIVATE
are set in *.[cy].)
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list