阿里云Java 杂谈

java字节码

2018-09-03  本文已影响5人  良辰美景TT

  我们都知道Java字节码是JVM所使用的指令集。java字节码可以分为如下几类:

操作数栈

  Java 方法的栈桢分为操作数栈和局部变量区。通常来说,程序需要将变量从局部变量区加载至操作数栈中,进行一番运算之后再存储回局部变量区中。操作数栈的指令有如下:

指令 类型 范围
iconst int(boolean, byte, char, short) [-1, 5]
lconst long 0, 1
fconst float 0, 1,2
dconst double 0, 1
dconst reference null
bipush int(boolean, byte, char, short) [-128,127]
sipush int(boolean, byte, char, short) [-32768,32767]
代码与指令的对应关系如下图所示: 指令对应图
类型 加载指令 存储指令
int(boolean, byte, char, short) iload istore
long lload lstore
float fload fstore
double dload dstore
reference aload astore
局部变量表的字节码
Java 相关指令
数组相关指令
类型 加载指令 存储指令
byte(boolean) baload bastore
char caload castore
short saload sastore
int iaload iastore
long laload lastore
float faload fastore
double daload dastore
reference aaload aastore
image.png
返回值相关指令

根据不同的返回类型,有不同的指令。如下表所示:

返回类型 返回指令
void return
int(boolean, byte, char, short) ireturn
long lreturn
float freturn
double dreturn
reference areturn
其它
上一篇 下一篇

猜你喜欢

热点阅读