Fixed bug in tail-call optimization

This commit is contained in:
Dmitry Boulytchev 2020-04-10 03:15:18 +03:00
parent b7ec1c2e63
commit 7748144a8f
4 changed files with 19 additions and 3 deletions

View file

@ -179,7 +179,7 @@ let compile cmd env imports code =
)
in
let call env f n tail =
let tail = tail && env#nargs = n && f.[0] <> '.' in
let tail = tail && env#nargs = n && f.[0] <> '.' in
let f =
match f.[0] with '.' -> "B" ^ String.sub f 1 (String.length f - 1) | _ -> f
in
@ -194,7 +194,7 @@ let compile cmd env imports code =
in
let env, pushs = push_args env [] n in
let y, env = env#allocate in
env, pushs @ [Mov (ebp, esp); Pop (ebp); Jmp f]
env, pushs @ [Mov (ebp, esp); Pop (ebp)] @ (if env#has_closure then [Pop ebx] else []) @ [Jmp f]
)
else (
let pushr, popr =

View file

@ -1 +1 @@
let version = "Version 1.00, eeab48ed3, Sun Mar 22 21:58:11 2020 +0300"
let version = "Version 1.00, b7ec1c2e6, Mon Mar 23 00:51:00 2020 +0300"