jvm stack 个数

文章来源  https://www.yqfy.net/texts/bin/

1、stack=1,只有一个返回值 int 0,

本来stack=本地变量+操作堆栈+frame data,但是参数没有使用,

所以根据实际指令来分配堆栈的个数。


public class ret
{
public static int main(String[] args)
{
return 0;
}javap -c -verbose ret.class
public static int main(java.lang.String[]);
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=1, args_size=1
0: iconst_0
1: ireturn

2、int 32位,下面数太大,只能当成常量看,所以只需要一个堆栈。

 

public class ret
{
 public static int main(String[] args)
 {
  return 12345678;
 }}
public static int main(java.lang.String[]);
flags: ACC_PUBLIC, ACC_STATI
Code:
stack=1, locals=1, args_size=1
0: ldc #2 // int 12345678
2: ireturn

3、Values of type int, float, reference, and returnValue occupy one entry in the local variables array,

  Values of type byte, short, and char are converted to int before being stored into the local variables
  上面两个表示只占一个横条,即stack=1;
  Values of type long and double occupy two consecutive entries in the array
  上面两个表示只占两个横条,即stack=2;    
 




 




 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值