> Is there any peephole optimizer for Java, be it for .class files
> or assembly files (e.g., Jasmin or Oolong)?
>
> Thanks.
>
> Napi
The Bytecode Engineering Library (BCEL, now part of
http://jakarta.apache.org/ ) had an example of a peephole optmizer that
improved the bytecode generated for boolean expressions by early
compilers (although I believe later versions of javac generate improved
code). You may want to have a look at this as it could be easily
extended for other optimisations - in any case I would recommend BCEL
as a useful package for the manipulation of class files.
By the way, do you mind me asking why you want an optimizer? In most
cirumstances a JVM will "JIT" the bytecode to native code, performing
its own optimizations - so optimising the bytecode may not be
beneficial.
I've heard rumours that optimising bytecode could cause a performance
degredation as the JIT might miss opportunities to do its own
optimisation. I hope and suspect this rumour is not true, as it would
imply that a JVM implementation might not optimise code compiled with a
competitor's compiler.
Paul
Mohd Hanafiah Abdullah - 25 May 2005 09:58 GMT
>> Is there any peephole optimizer for Java, be it for .class files
>> or assembly files (e.g., Jasmin or Oolong)?
[quoted text clipped - 21 lines]
>imply that a JVM implementation might not optimise code compiled with a
>competitor's compiler.
I would like to use it on .class files produced by a C compiler that generates
Java bytecode. The peephole optimizer should help improve the code.
Thanks.
Napi

Signature
http://www.axiomsol.com
http://www.cs.indiana.edu/hyplan/napi.html
Paul Cager - 31 May 2005 10:01 GMT
Yes, the peephole optimiser should certainly improve the bytecode. But
unless you are running on a JVM without a JIT I think it is unlikely to
improve the performance of the program you are running - the JITing
process performs some aggressive optimisation.