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?
2 回答
如前所述,您寻求的信息不存在,因为它不存在。除了同样提到的事实,不同的 JVM 可以不同地实现指令(或指令组合),单个 JVM 也可以不同地实现它。
这适用于不同的指令组合(根据指令与其他指令一起使用的方式,以不同的方式实现指令可能更有效)和不同的执行场合。由于 JVM 始终控制您的程序的执行,它可以(并且确实)监视您的程序的行为并决定重新优化经常运行的代码(或满足某些其他标准的代码)。例如,这可能导致您的指令在函数执行的前一千次被翻译成特定的机器指令集,而在其余的执行中被翻译成另一组机器指令。
这种高级优化能力(和其他)是 Java 字节码优化最好留给 JVM 的原因,也是为什么在某些情况下,Java 程序可以比等效的 C 或 C++ 程序(C 和 C++ 通常只静态优化,而 Java 动态优化)。
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.