常用的字节码

常量入

aconst_null null 对象入栈
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 (x i l f d a)
分别表示 int long float double objectref
xload_n (n 01 2 3)
xaload (x i l f d a b c s)
分别表示 int ,long, float, double, obj ref , byte,char,short
从数组中取得给定索引的值,将该值压栈
iaload
执行前,栈: ..., arrayref ,index
它取得 arrayref 所在数组的 index 的值,并将值压栈
执行后,栈: ...,value

出栈装载入局部变量

xstore (x i l f d a)
栈,存入局部变量
xstore_n (n0 1 2 3)
栈,将值存入第 n 个局部变量
xastore (x i l 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 (x i l f d a 或为空 )


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

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

xreturn x为空,表示返回void







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值