John Cowan wrote: > On Tue, Feb 24, 2009 at 9:03 AM, Robert Fischer > <[email protected]> wrote: > >> What optimizing efforts are worthwhile on generated bytecode given the >> optimizing capabilities of >> the JIT? I'm having trouble finding an explicit or definitive list of >> optimizations, but trying to >> be clever about method inlining is pretty clearly wasted effort. I can't >> find any documentation on >> it, but I'm assuming the JIT also takes care of constant folding, strength >> reduction, and dead code >> removal, since they're so straightforward. Or am I wrong, and the JIT >> assumes the compiler author >> applied those filters already? > > Other people can probably give you nitty-gritty details. The main > rule, I think, is "Generate dumb code: specifically, generate what a > fairly unclever Java programmer would write, as compiled by a > straightforward and unclever Java compiler." That's what the JIT will > have been mostly tested on. The cleverer you or your compiler are, > the more likely you are to hit a case the JIT can't handle well.
Looking at this same statement from a different angle: write bytecode you'd like to maintain if it had started out as Java code. And as far as the "clever" thing goes, I can promise you that's true. A number of languages (including JRuby) have tried to work around "finally" being inlined everywhere by jumping to it. Unfortunately it turns out that the clever version is really hard to optimize in the best case (exceptional and non-exceptional paths sharing the same code) and can crash some JITs in the worst case (we saw crashes on both Java 5 and Java 6 client compilers until we fixed this). Since javac never emits this "clever" version, JVMs aren't tested or optimized for it. - Charlie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---
