summaryrefslogtreecommitdiff
path: root/src/lvm.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/lvm.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/lvm.js')
-rw-r--r--src/lvm.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lvm.js b/src/lvm.js
index 0f184a1..908125f 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -225,11 +225,11 @@ const luaV_execute = function(L) {
}
case OP_GETUPVAL: {
let b = i.B;
- lobject.setobj2s(L, ra, cl.upvals[b].v);
+ lobject.setobj2s(L, ra, cl.upvals[b]);
break;
}
case OP_GETTABUP: {
- let upval = cl.upvals[i.B].v;
+ let upval = cl.upvals[i.B];
let rc = RKC(L, base, k, i);
luaV_gettable(L, upval, rc, ra);
break;
@@ -241,7 +241,7 @@ const luaV_execute = function(L) {
break;
}
case OP_SETTABUP: {
- let upval = cl.upvals[i.A].v;
+ let upval = cl.upvals[i.A];
let rb = RKB(L, base, k, i);
let rc = RKC(L, base, k, i);
settable(L, upval, rb, rc);
@@ -249,7 +249,7 @@ const luaV_execute = function(L) {
}
case OP_SETUPVAL: {
let uv = cl.upvals[i.B];
- uv.v.setfrom(L.stack[ra]);
+ uv.setfrom(L.stack[ra]);
break;
}
case OP_SETTABLE: {
@@ -973,8 +973,8 @@ const getcached = function(p, encup, stack, base) {
let uv = p.upvalues;
let nup = uv.length;
for (let i = 0; i < nup; i++) { /* check whether it has right upvalues */
- let v = uv[i].instack ? stack[base + uv[i].idx] : encup[uv[i].idx].v;
- if (c.upvals[i].v !== v)
+ let v = uv[i].instack ? stack[base + uv[i].idx] : encup[uv[i].idx];
+ if (c.upvals[i] !== v)
return null; /* wrong upvalue; cannot reuse closure */
}
}
@@ -996,7 +996,6 @@ const pushclosure = function(L, p, encup, base, ra) {
ncl.upvals[i] = lfunc.luaF_findupval(L, base + uv[i].idx);
else
ncl.upvals[i] = encup[uv[i].idx];
- ncl.upvals[i].refcount++;
}
p.cache = ncl; /* save it on cache for reuse */
};