views:

346

answers:

2

The Java Virtual Machine Instruction Set page provides information about mnemonics such as aaload, aastore... etc.
However neither the cpu cycles that these mnemonics would take up is mentioned nor is there any info on the byte size or word size of these mnemonics.
Any idea where this information could be found?

+3  A: 

The spec is what a JVM needs to implement not how it does so. Different platforms and different JVM's from venders such as IBM and Sun will use different implementations so you can’t assume anything about byte size and processor cycles. If you really want to find more info you can download the Open JDK source and look through it but this is only one implementation and you can’t assume other implementations will have the exact same performance characteristics.

Jared
Wont there be any benchmarks available for a windows machine?
Kevin Boyd
There are multiple JVMs that run on Windows, so a simple benchmark of "a Windows machine" wouldn't be adequate. Such a benchmark would only give you information about a particular JVM in that environment.
Mike Daniels
Which version of Java, IBM's, Sun's, Open JDK, etc. There's no benchmark to compare all of them.
Jared
That's not a problem, I guess Sun may have made its own JVM, are the benchmarking results available online?
Kevin Boyd
@Kevin, the SPECjvm2008 benchmark is the closest I could get to an actual benchmark of Java's performance with respect to certain usage scenarios. The benchmark results are reported in operations per minute - operations in this context are not the atomic JVM instructions. It is available at http://www.spec.org/jvm2008/. Not many results are available though.
Vineet Reynolds
@Vineet: I can't mark a comment right! Thanks for the link!
Kevin Boyd
+6  A: 

As already mentioned, the information you seek is not there because it does not exist. Apart from the also mentioned fact that different JVMs can implement instructions (or combinations of instructions) differently, a single JVM can also implement it differently.

This is true both for different combinations of intstructions (it might be more efficient to implement instructions in different ways depending on how they are used together with other instructions) and for different occasions of execution. As the JVM is always in control of the execution of your program, it can (and does) monitor the behavior of your program and decide to reoptimize code that is run often (or code meeting some other criteria for that matter). This can result in, for example, your instruction being translated into a certain set of machine instructions the first thousand times a function is executed, and being translated to another set the rest of the executions.

This advanced optimization ability (and others) is why optimization of Java byte code is best left to the JVM and also why, in some cases, a Java program can be significantly faster than the equivalent C or C++ program (C and C++ is normally only optimized statically whereas Java is optimized dynamically).

Mikael Auno
All good, except for "significantly faster". I've yet to see this being the case anywhere but on paper.
Pavel Minaev
@Pavel Minaev: you could have a look at this link, http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/
Kevin Boyd