Does the HotSpot JIT compiler optimize ... ?
I often encounter code that I think HotSpot should be able to optimize, but I have no way of easily finding out (short of trying to write a benchmark). For example:
- are native calls (like java.nio.ByteBuffer.put() and get() methods) candidates for inline optimization?
- to get a list of enumerations for a particular enum, you call getEnumConstants() which evidently returns a clone of the original enum constant array [a late addition to 1.5 to prevent the original array from possibly being changed]. If you only want to read a value out of the array, the clone is wasted effort, since the only reference to the cloned array is immediately discarded. Is the JIT compiler smart enough to see that the cloned array is only used to access one element, so it can discard the call to clone() and just use the original? [Apparently not, according to a performance talk I heard at 2005 JavaOne.]
My bigger question is, is there a document, FAQ, mailing list, or forum for finding out if a particular JIT (on a particular platform) performs a certain optimization such as the examples above? Or, is it possible to see the optimized code generated by a JIT?