Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top