常用字节码指令

常量入栈(操作数栈)指令

  • bipush[1]
  • sipush[2]
  • aconst_null
  • iconst_m1[3]
  • iconst_x[4]
  • lconst_0
  • lconst_1
  • fconst_0
  • fconst_1
  • fconst_2
  • dconst_0
  • dconst_1
  • ldc[5]
  • ldc_w[6]
  • ldc2_w[7]

局部变量压栈(操作数栈)指令

  • xload (x={i, f, l, d, a})
  • xload_n (x={i, f, l, d, a} n={0, 1, 2, 3})[8]
  • xaload (x={i, f, l, d, a, b, c, s})

出栈(操作数栈)装入局部变量表指令

  • xstore
  • xstore_x
  • xastore

通用型操作

  • NOP
  • dup
  • dup2
  • pop
  • pop2

类型转换指令

  • x2y (x={i, f, l, d}, y={i, f, l, d, c, s, b})[9]

运算指令

  • 加法指令:iadd, ladd, fadd, dadd
  • 减法指令:isub, lsub, fsub, dsub
  • 乘法指令:imul, lmul, fmul, dmul
  • 除法指令:idiv, ldiv, fdiv, ddiv
  • 取余指令:irem, lrem, frem, drem
  • 数值取反:ineg, lneg, fneg, dneg
  • 自增指令:iinc[10]
  • 位运算指令
    • 位移指令:ishl, ishr, iushr, lshl, lshr, lushr
    • 按位或指令:ior, lor
    • 按位与指令:iand, land
    • 按位异或指令:ixor, lxor

对象/数组操作指令

  • 创建指令:new, newarray, anewarray, multianewarray
  • 字段访问指令:getfield, putfield, getstatic, putstatic
  • 类型检查指令:checkcast, instanceof
  • 数组操作指令:xastore, xaload, arraylength

比较控制指令

  • 比较指令:dcmpg, dcmpl, fcmpg, fcmpl, lcmp
  • 条件跳转指令:ifeq, iflt, ifle, ifne, ifgt, ifge, ifnull, ifnonnull
  • 比较条件跳转指令:if_icmpeq, if_icmpne, if_icmplt, if_icmpgt, if_icmple, if_icmpge, if_acmpeq, if_acmpne
  • 多条件分支跳转:tableswitch, lookupswitch
  • 无条件跳转:goto, goto_w

函数调用与返回指令

  • invokevirtual[11]
  • invokeinterface
  • invokespecial[12]
  • invokestatic
  • invokedynamic
  • xreturn

同步控制

  • monitorenter
  • monitorexit

  1. 接收8位整数作为参数

  2. 接收16位整数作为参数

  3. 将-1压入操作数栈

  4. 将x压入操作数栈,x为0~5

  5. 接收一个8位参数,该参数指向常量池中的int、float或String

  6. 接收两个8位参数,能支持的索引范围大于ldc

  7. 要压入的元素是long或double

  8. n表示第n个局部变量

  9. x取不到c,s和b,是因为在局部变量表中每个槽位是32位,char,short和byte在局部变量表中也占32位,也就是将它们视为int

  10. 少数几个完全不修改操作数栈的指令,需要2个操作数:第1个为局部变量表的位置,第2个为累加数;

  11. 对象的实例方法

  12. 构造函数,类的私有方法,父类方法,这些方法都是静态绑定的

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值