This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj optimization situation?
- To: Adam Megacz <gcj at lists dot megacz dot com>
- Subject: Re: gcj optimization situation?
- From: Jeff Sturm <jsturm at one-point dot com>
- Date: Fri, 9 Nov 2001 00:31:19 -0500 (EST)
- cc: java at gcc dot gnu dot org
On 8 Nov 2001, Adam Megacz wrote:
> - I read somewhere that gcj ignores the -O option -- does that mean
> that all gcj output (.class and .o) is unoptimized?
No. For compiling .java -> .o or .class -> .o all the standard gcc
optimization switches are available (-O, -O2, -funroll-loops, etc.).
Class files are unaffected however, so -O would be meaningless together
with -C.
> - Is there any way I can get gcj to do intra-class (not inter-class)
> inlining? I have a lot of one-liner private methods that really
> should be inlined -- I've been using javago, but it has a tendency
> to corrupt bytecodes, so it's a huge pain to use.
These should be handled now by the rtl inliner. You may find it more
effective if the private methods are ordered first in the java source.
In the future gcj will use a tree-based inliner that will not be sensitive
to the order of rtl generation.
> - Will I get better optimizations by running gcj on .java files
> (outputting .o files) than if I use javac to compile .java -> .class
> and gcj to compile .class -> .o?
Potentially, yes. Both class files and sources generate
intermediate trees, but the latter convey more information to the backend
that may be helpful for optimization.
> - Also, I've noticed that despite being written in native C code, gcj
> compiles .java -> .class way slower than javac (w/ HotSpot). Is this
> because it's doing more analysis on my code?
I don't see that at all. For a single run, gcj is significantly faster
than javac. It could be that javac is using fewer invocations than gcj to
build your code because it writes out classes for each source it parses,
whereas gcj only writes classes for those sources you ask it to compile.
Try multiple sources (i.e. gcj -C *.java) for comparison.
Jeff