diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-02-11 08:53:10 +0100 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-02-11 15:23:04 +0100 |
commit | a7b98a2e62c49a6c0ced2b57ddcea9bb6bab108e (patch) | |
tree | 1420dfdb17660fd5ca243f25d279dbd308263f7e /src/lvm.js | |
parent | 219d7cf24902b53385a1b6999e8bbf2c8512cf0b (diff) | |
download | fengari-a7b98a2e62c49a6c0ced2b57ddcea9bb6bab108e.tar.gz fengari-a7b98a2e62c49a6c0ced2b57ddcea9bb6bab108e.tar.bz2 fengari-a7b98a2e62c49a6c0ced2b57ddcea9bb6bab108e.zip |
Fixed bad tailcall, _ENV is a closed upvalue
Diffstat (limited to 'src/lvm.js')
-rw-r--r-- | src/lvm.js | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -431,7 +431,7 @@ class LuaVM { } case "OP_TAILCALL": { if (i.B !== 0) L.top = ra + i.B; - if (this.precall(ra, L.stack[ra], LUA_MULTRET)) { + if (this.precall(ra, L.stack[ra], LUA_MULTRET)) { // JS function base = ci.u.l.base; } else { /* tail call: put called frame (n) in place of caller one (o) */ @@ -445,7 +445,7 @@ class LuaVM { if (cl.p.p.length > 0) this.closeupvals(oci.u.l.base); for (let aux = 0; nfuncOff + aux < lim; aux++) L.stack[ofuncOff + aux] = L.stack[nfuncOff + aux]; - + oci.func = nci.func; oci.u.l.base = ofuncOff + (nci.u.l.base - nfuncOff); L.top = ofuncOff + (L.top - nfuncOff); oci.top = L.top; @@ -718,6 +718,7 @@ class LuaVM { } closeupvals(level) { + let L = this.L; while (L.openupval !== null && L.openupval.v >= level) { let uv = L.openupval; assert(uv.isopen()); |