I am using the Jasmin Java assembler to compile a toy language. But when I use the jsr instruction to recurse back into a subroutine, and run the output of Jasmin using java, I get the error "Recursive call to jsr entry". Here is the Jasmin code (it's computing 5! (I've left out the class definitions; all this is in the main method body)):
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
Recursive jsr's are explicitly forbidden by §4.8.2 of the JVM spec:
This is primarily to simplify the logic of the bytecode verifier so that it can ensure that appropriate state is saved and restored in a subroutine.