summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-22 18:06:40 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-22 18:46:30 +1000
commit91e09ea32148c34965809b8d69987d439d389870 (patch)
tree216ca00cad9be1eb1f85c2bdca90ad99f1a28c12 /src/ldo.js
parent6646bebd474b95a2d4cbb8558c0d1cb5b5353de0 (diff)
downloadfengari-91e09ea32148c34965809b8d69987d439d389870.tar.gz
fengari-91e09ea32148c34965809b8d69987d439d389870.tar.bz2
fengari-91e09ea32148c34965809b8d69987d439d389870.zip
Compare allowed stack indices to stack_last
Not L.stack.length which is more equivalent to C's L->stacksize
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ldo.js b/src/ldo.js
index 10be56a..7154a7f 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -43,6 +43,7 @@ const ERRORSTACKSIZE = luaconf.LUAI_MAXSTACK + 200;
const luaD_reallocstack = function(L, newsize) {
L.stack.length = newsize;
+ L.stack_last = newsize - lstate.EXTRA_STACK;
};
const luaD_growstack = function(L, n) {
@@ -64,7 +65,7 @@ const luaD_growstack = function(L, n) {
};
const luaD_checkstack = function(L, n) {
- if (L.stack.length - L.top <= n)
+ if (L.stack_last - L.top <= n)
luaD_growstack(L, n);
};
@@ -73,7 +74,7 @@ const stackinuse = function(L) {
for (let ci = L.ci; ci !== null; ci = ci.previous) {
if (lim < ci.top) lim = ci.top;
}
- assert(lim <= L.stack.length);
+ assert(lim <= L.stack_last);
return lim + 1; /* part of stack in use */
};
@@ -107,7 +108,7 @@ const luaD_precall = function(L, off, nresults) {
ci.nresults = nresults;
ci.func = func;
ci.top = L.top + defs.LUA_MINSTACK;
- assert(ci.top <= L.stack.length);
+ assert(ci.top <= L.stack_last);
ci.callstatus = 0;
if (L.hookmask & defs.LUA_MASKCALL)
luaD_hook(L, defs.LUA_HOOKCALL, -1);
@@ -219,6 +220,7 @@ const luaD_hook = function(L, event, line) {
ar.currentline = line;
ar.i_ci = ci;
ci.top = L.top + defs.LUA_MINSTACK;
+ assert(ci.top <= L.stack_last);
L.allowhook = 0; /* cannot call hooks inside a hook */
ci.callstatus |= lstate.CIST_HOOKED;
hook(L, ar);