JVM中的指令数 [英] Number of instructions in JVM

查看:127
本文介绍了JVM中的指令数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天在考试中有人问我以下问题.我仍然不知道答案.

I was asked the following question in an exam today. I still don't know the answer.

Java将堆栈用于JVM中的字节码.每个指令只有一个字节,因此在一个操作系统中可以有多少个这样的指令(每个字节代码).

Java uses stack for byte code in JVM. Each instruction is of one byte, so how many such instructions (per byte code) are possible in an operating system.

我所知道的是堆栈为32位宽.有人可以帮助我吗(我是JVM的初学者)?

All I know is that the stack is 32 bits wide. Can anybody help me (I am a beginner in JVM)?

推荐答案

预期的答案几乎肯定是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.

这篇关于JVM中的指令数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆