asm学习笔记之栈映射帧



    其实正常来说,应该是每个字节码指令都有一个栈状态的,但是为了节省空间,在实际生成的字节码中,只有在进行了跳转时(比如GOTO IFLT等指令时)才保存了栈的状态,其他帧的状态都可以通过它们算出来,而且一个方法的初始帧状态是不保存的,因为初始的状态可以通过方法中的签名算出来.而且为了进一步减少空间,又对栈映射帧进行一些类型的划分,因为有可能两个栈映射帧的状态是一样,或者说有一些类似,接下来我就介绍一下,具体有哪些类型.打开org.objectweb.asm.Opcodes类的源码,我们可以看到如下定义:

    代码

    /**
     * Represents a compressed frame with complete frame data.
     */
    int F_FULL = 0;

    /**
     * Represents a compressed frame where locals are the same as the locals in
     * the previous frame, except that additional 1-3 locals are defined, and
     * with an empty stack.
     */
    int F_APPEND = 1;

    /**
     * Represents a compressed frame where locals are the same as the locals in
     * the previous frame, except that the last 1-3 locals are absent and with
     * an empty stack.
     */
    int F_CHOP = 2;

    /**
     * Represents a compressed frame with exactly the same locals as the
     * previous frame and with an empty stack.
     */
    int F_SAME = 3;

    /**
     * Represents a compressed frame with exactly the same locals as the
     * previous frame and with a single value on the stack.
     */
    int F_SAME1 = 4;
 
它已经对每个状态做出解释了,我这里就不说了,要理解这里的话不难,只要你对java字节码指令执行以及栈结构了解就行

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值