您当前的位置: 首页 >  Java

小志的博客

暂无认证

  • 1浏览

    0关注

    1217博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

小志的博客 发布时间:2022-03-06 20:45:00 ,浏览量:1

目录
    • 一、加载和存储指令的概述
    • 二、加载和存储指令的内容
    • 三、加载和存储指令的示例

一、加载和存储指令的概述
  • 加载和存储指令用于将数据在栈帧中的局部变量表和操作数栈之间来回传输。
二、加载和存储指令的内容
  • 将一个局部变量加载到操作数栈 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字节码文件

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

关注
打赏
1661269038
查看更多评论
立即登录/注册

微信扫码登录

0.0432s