summaryrefslogtreecommitdiff
path: root/src/lvm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-11 07:44:15 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-11 07:44:15 +0200
commitc8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a (patch)
tree7b6dbe3fd789efd73ce202bd5b3b03644e28f50f /src/lvm.js
parent7f8be9d514af9d5038a2a5e70d0c64592f4d3838 (diff)
downloadfengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.tar.gz
fengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.tar.bz2
fengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.zip
Constant must be copied !
This fixes an issue where a single constant reference was used in several stack slot resulting in some rather funny things in the VM loop.
Diffstat (limited to 'src/lvm.js')
-rw-r--r--src/lvm.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lvm.js b/src/lvm.js
index 3697008..ad1e807 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -137,12 +137,14 @@ const luaV_execute = function(L) {
break;
}
case OCi.OP_LOADK: {
- L.stack[ra] = k[i.Bx];
+ let konst = k[i.Bx];
+ L.stack[ra] = new TValue(konst.type, konst.value);
break;
}
case OCi.OP_LOADKX: {
assert(ci.u.l.savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG);
- L.stack[ra] = k[ci.u.l.savedpc[ci.pcOff++].Ax];
+ let konst = k[ci.u.l.savedpc[ci.pcOff++].Ax];
+ L.stack[ra] = new TValue(konst.type, konst.value);
break;
}
case OCi.OP_LOADBOOL: {