0
点赞
收藏
分享

微信扫一扫

深入理解Java虚拟机——加载和存储指令

看山远兮 2022-03-11 阅读 83
java

目录

一、加载和存储指令的概述

  • 加载和存储指令用于将数据在栈帧中的局部变量表和操作数栈之间来回传输。

二、加载和存储指令的内容

  • 将一个局部变量加载到操作数栈
    iload、iload< n>、lload、lload< n>、fload、fload< n>、dload、dload< n>、aload、aload< n>;

  • 将一个数值从操作数栈存储到局部变量表
    istore、istore_< n>、lstore、lstore_ < n> 、fstore、fstore_< n>、dstore、dstore_< n>、astore、astore_< n>;

  • 将一个常量加载到操作数栈
    bipush、sipush、ldc、ldc_w、ldc2_w、aconst_null、iconst_ml、iconst_< i>、lconst_< l>、fconst< f>、dconst_< d>;

  • 扩充局部变量表的访问索引的指令
    wide

三、加载和存储指令的示例

  • 代码

    public class Test1{
    	public int add(int a,int b){
    		int c= a + b;
    		return 1+1;
    	}
    }
    
  • 执行javac命令,生成.class文件
    在这里插入图片描述

  • 执行javap命令,分析.class字节码文件

    在这里插入图片描述在这里插入图片描述

举报

相关推荐

0 条评论