java jsr命令_使用jsr指令进行Java递归

我使用Jasmin Java汇编程序编译玩具语言.但是当我使用jsr指令递归回子程序,并使用java运行Jasmin的输出时,我收到错误“递归调用jsr条目”.这是Jasmin代码(它是计算5!(我已经省略了类定义;所有这些都在主方法体中)):

f:

swap

istore 2

iload 2

ifeq label0

iload 2

iload 2

ldc 1

isub

jsr f

istore 1

istore 2

iload 1

iload 2

imul

goto label1

label0:

ldc 1

label1:

swap

astore 0

ret 0

main:

ldc 5

jsr f

istore 1

iload 1

解决方法:

No jsr or jsr_w instruction may be used to recursively call a subroutine if that subroutine is already present in the subroutine call chain. (Subroutines can be nested when using try-finally constructs from within a finally clause. For more information on Java virtual machine subroutines, see §4.9.6.)

这主要是为了简化字节码验证器的逻辑,以便确保在子例程中保存和恢复适当的状态.

标签:java,assembly,jvm,bytecode,jasmin

来源: https://codeday.me/bug/20190721/1496602.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值