常量入

aconst_nullnull对象入栈
iconst_m1   int常量-1入栈
iconst_0      int常量0入栈
iconst_5
lconst_1      long常量1入栈
fconst_1      float 1.0入栈
dconst_1     double 1.0 入栈
bipush        8位带符号整数入栈
sipush         16带符号整数入

ldc               常量池中的项入

ldc index

indexu1为指向常量池的有效无符号8位索引


局部变量压栈

xload(xil f d a)
分别表示intlongfloatdoubleobjectref
xload_n(n01 2 3)
xaload(xil f d a b c s)
分别表示int,long, float, double, objref ,byte,char,short
从数组中取得给定索引的值,将该值压栈
iaload
执行前,栈:...,arrayref,index
它取得arrayref所在数组的index的值,并将值压栈
执行后,栈:...,value

出栈装载入局部变量

xstore(xil f d a)
栈,存入局部变量
xstore_n(n0 1 2 3)
栈,将值存入第n个局部变量
xastore(xil f d a b c s)
将值存入数组中
iastore
执行前,栈:...,arrayref,index, value
执行后,栈:...
value存入arrayref[index]


通用栈操作(无类型)

nop
pop
出栈顶1个字长
dup
复制栈顶1个字长,复制内容压入栈

类型转化


常用的字节码



整数运算
iadd
ladd
isub
lsub
idiv
ldiv
imul
lmul
iinc

浮点运算

fadd

dadd

fsub

dsub

fdiv

ddiv

fmul

dmul

基本工作流程都是,弹出栈顶2个数,做运算,结果入栈

对象操作指令

new
getfield
putfield
getstatic
putstatic

条件控制

ifeq  如果为0,则跳转
ifne  如果不为0,则跳转
iflt   如果小于0,则跳转
ifge  如果大于0,则跳转
if_icmpeq如果两个int相同,则跳转


ifeq

参数byte1,byte2

value出栈,如果栈顶value0则跳转到(byte1<<8)|byte2

执行前,栈:...,value

执行后,栈:...


方法调用

invokevirtual
invokespecial
invokestatic
invokeinterface
xreturn(xil f d a 或为空)


invokespecial通常根据引用的类型选择方法,而不是对象的类来选择!即它使用静态绑定而不是动态绑定。

invokespecial对私有方法超类方法 实例初始化方法

xreturn x为空,表示返回void







相关文章:

  • 2022-12-23
  • 2021-07-10
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-04-16
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-01-16
相关资源
相似解决方案