diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-05-05 15:46:17 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-05-05 15:46:17 +0200 |
commit | d4aa8fa4e548ef348753ef765f2680f1a188d145 (patch) | |
tree | 92663657a52eb529ccc5c64ff70622ae2412deff | |
parent | 7ef345bee73f6cc843b0d82866d036a3ac5829ca (diff) | |
parent | c7b6fa63459d411cd7b20ea0de3dc2f4cf7e2a2f (diff) | |
download | fengari-d4aa8fa4e548ef348753ef765f2680f1a188d145.tar.gz fengari-d4aa8fa4e548ef348753ef765f2680f1a188d145.tar.bz2 fengari-d4aa8fa4e548ef348753ef765f2680f1a188d145.zip |
Merge remote-tracking branch 'daurnimator/fix-errors'
-rw-r--r-- | src/lparser.js | 4 | ||||
-rw-r--r-- | src/lundump.js | 2 | ||||
-rw-r--r-- | src/lvm.js | 37 |
3 files changed, 17 insertions, 26 deletions
diff --git a/src/lparser.js b/src/lparser.js index f0f1d87..566576a 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -504,8 +504,8 @@ const undefgoto = function(ls, gt) { ** adds a new prototype into list of prototypes */ const addprototype = function(ls) { - let clp = new Proto(); let L = ls.L; + let clp = new Proto(L); let fs = ls.fs; let f = fs.f; /* prototype of current function */ f.p[fs.np++] = clp; @@ -536,7 +536,7 @@ const open_func = function(ls, fs, bl) { fs.nactvar = 0; fs.firstlocal = ls.dyd.actvar.n; fs.bl = null; - let f = new Proto(); + let f = new Proto(ls.L); f = fs.f; f.source = ls.source; f.maxstacksize = 2; /* registers 0/1 are always valid */ diff --git a/src/lundump.js b/src/lundump.js index 26405d6..1c0d4c7 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -285,7 +285,7 @@ class BytecodeParser { this.L.stack[this.L.top] = new lobject.TValue(defs.CT.LUA_TLCL, cl); this.L.top++; - cl.p = new lfunc.Proto(); + cl.p = new lfunc.Proto(this.L); this.readFunction(cl.p); @@ -98,36 +98,27 @@ const RKC = function(L, base, k, i) { }; const luaV_execute = function(L) { - let OCi = OC.OpCodesI; + const OCi = OC.OpCodesI; let ci = L.ci; - let specialCase = null; // To enable jump to specific opcode without reading current op/ra - let opcode, k, base, i, ra; - var cl; ci.callstatus |= lstate.CIST_FRESH; newframe: for (;;) { - if (specialCase) { - opcode = specialCase; - specialCase = null; - } else { - ci = L.ci; - cl = ci.func.value; - k = cl.p.k; - base = ci.l_base; - - i = ci.l_savedpc[ci.pcOff++]; - - if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) { - ldebug.luaG_traceexec(L); - base = ci.l_base; - } + assert(ci === L.ci); + let cl = ci.func.value; + let k = cl.p.k; + let base = ci.l_base; + let i = ci.l_savedpc[ci.pcOff++]; - ra = RA(L, base, i); - opcode = i.opcode; + if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) { + ldebug.luaG_traceexec(L); + base = ci.l_base; } + let ra = RA(L, base, i); + let opcode = i.opcode; + if (i.breakpoint) // TODO: remove, used until lapi return; @@ -628,13 +619,13 @@ const luaV_execute = function(L) { L.stack[cb] = L.stack[ra]; L.top = cb + 3; /* func. + 2 args (state and index) */ ldo.luaD_call(L, cb, i.C); + /* go straight to OP_TFORLOOP */ base = ci.l_base; L.top = ci.top; i = ci.l_savedpc[ci.pcOff++]; ra = RA(L, base, i); assert(i.opcode === OCi.OP_TFORLOOP); - specialCase = OCi.OP_TFORLOOP; - break; + /* fall through */ } case OCi.OP_TFORLOOP: { if (!L.stack[ra + 1].ttisnil()) { /* continue loop? */ |