且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JVM中的指令数

更新时间:2023-02-26 17:21:14

预期的答案几乎肯定是256,因为一个字节可能有256个值.

The expected answer was almost certainly 256, because there are 256 possible values of a byte.

这当然与实际的JVM指令集无关.可能的指令数量可能会有所不同,从几十到几千不等,具体取决于您的计数方式.

This of course has nothing to do with the actual JVM instruction set. The number of possible instructions can vary anywhere from a couple dozen to an exponentially large number depending on how you count.

实际的JVM指令集有许多未使用的操作码,一个操作码在概念上代表多个指令,并且许多指令可以用多种不同的操作码以大量不同的方式进行编码.许多指令多于一个字节,一对指令的最大长度可达64kb.甚至还没有涉及到如何计算宽前缀的事情.

The actual JVM instruction set has many unused opcodes, one opcode that conceptually represent more than one instruction, and many instructions that can be encoded in tons of different ways with multiple different opcodes. Many instructions are more than one byte, with a couple that can be up to 64kb long. And that isn't even getting into stuff like how you count the wide prefix.