美文网首页
基于栈的解释器执行过程

基于栈的解释器执行过程

作者: Cuccci | 来源:发表于2019-07-25 23:30 被阅读0次
  1. Java 代码
public int calc(){
  int a=100;
  int b=200;
  int c=300;
  return(a+b)*c;
}

  1. 字节码指令
public int calc();
Code:
Stack=2, Locals=4, Args_size=1
0:bipush 100
2:istore_1
3:sipush 200
6:istore_2
7:sipush 300
10:istore_3
11:iload_1
12:iload_2
13:iadd
14:iload_3
15:imul
16:ireturn
}
  1. 执行过程
    字节码指令中表明了这段代码需要深度为2的操作数栈和4个Slot的局部变量空间
  • 图1.png
  • 图2.png
  • 图3.png
  • 图4.png
  • 图5.png
  • 图6.png
  • 图7.png

相关文章

网友评论

      本文标题:基于栈的解释器执行过程

      本文链接:https://www.haomeiwen.com/subject/tyklrctx.html