summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-29 19:01:22 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-29 22:07:00 +1100
commit313f55905253697fe4966f979865296aeaa7a801 (patch)
treea8f060a377d45943952ade62507951cd4555a21b /src/lapi.js
parent62b07567d9f39fa746ea35d9c08cd1dcf37dc67a (diff)
downloadfengari-313f55905253697fe4966f979865296aeaa7a801.tar.gz
fengari-313f55905253697fe4966f979865296aeaa7a801.tar.bz2
fengari-313f55905253697fe4966f979865296aeaa7a801.zip
src/: Upvalues are now just TValues (possibly referencing on-stack)
- Removes `Upval` class - closing over upvalues is now done by creating new on-stack TValue objects - No more `openupval` linked list With this fix, upvalues from collected coroutines will no longer keep other values alive Closes #44
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/lapi.js b/src/lapi.js
index ec643b3..8ed67f5 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -32,10 +32,7 @@ const {
from_userstring,
to_luastring,
} = require('./defs.js');
-const {
- api_check,
- lua_assert
-} = require('./llimits.js');
+const { api_check } = require('./llimits.js');
const ldebug = require('./ldebug.js');
const ldo = require('./ldo.js');
const { luaU_dump } = require('./ldump.js');
@@ -555,7 +552,7 @@ const aux_upvalue = function(L, fi, n) {
let name = p.upvalues[n-1].name;
return {
name: name ? name.getstr() : to_luastring("(*no name)", true),
- val: f.upvals[n-1].v
+ val: f.upvals[n-1]
};
}
default: return null; /* not a closure */
@@ -930,7 +927,7 @@ const lua_load = function(L, reader, data, chunkname, mode) {
/* get global table from registry */
let gt = ltable.luaH_getint(L.l_G.l_registry.value, LUA_RIDX_GLOBALS);
/* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
- f.upvals[0].v.setfrom(gt);
+ f.upvals[0].setfrom(gt);
}
}
return status;
@@ -1111,13 +1108,9 @@ const lua_upvalueid = function(L, fidx, n) {
const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) {
let ref1 = getupvalref(L, fidx1, n1);
let ref2 = getupvalref(L, fidx2, n2);
- let up1 = ref1.upval;
let up2 = ref2.upval;
let f1 = ref1.closure;
- lua_assert(up1.refcount > 0);
- up1.refcount--;
f1.upvals[ref1.upvalOff] = up2;
- up2.refcount++;
};
// This functions are only there for compatibility purposes