commit f8d677f94c3b4309be94698d33aeb0590a51eabc
parent 094a7d0290bbbe248d9d29b28c2567283d5ad0ba
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Feb 2011 10:28:03 -0200
no more 'OP_CLOSE' instructions (use jumps to close upvalues)
Diffstat:
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/lopcodes.c b/lopcodes.c
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.c,v 1.43 2010/03/12 19:14:06 roberto Exp roberto $
+** $Id: lopcodes.c,v 1.44 2010/10/13 16:45:54 roberto Exp roberto $
** See Copyright Notice in lua.h
*/
@@ -50,7 +50,6 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"TFORCALL",
"TFORLOOP",
"SETLIST",
- "CLOSE",
"CLOSURE",
"VARARG",
"EXTRAARG",
@@ -98,7 +97,6 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
- ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
diff --git a/lopcodes.h b/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.137 2010/10/25 12:24:55 roberto Exp roberto $
+** $Id: lopcodes.h,v 1.138 2011/02/01 18:03:10 roberto Exp roberto $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -216,7 +216,6 @@ OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
-OP_CLOSE,/* A close all upvalues >= R(A) */
OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.96 2011/02/01 18:03:10 roberto Exp roberto $
+** $Id: lparser.c,v 2.97 2011/02/04 17:34:43 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -429,8 +429,12 @@ static void leaveblock (FuncState *fs) {
removevars(fs, bl->nactvar);
fs->ls->labell->nlabel = bl->firstlabel; /* remove local labels */
movegotosout(fs, bl);
- if (bl->upval)
- luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
+ if (bl->upval) {
+ /* create a 'jump to here' to close upvalues */
+ int j = luaK_jump(fs);
+ luaK_patchclose(fs, j, bl->nactvar);
+ luaK_patchtohere(fs, j);
+ }
/* a block either controls scope or breaks (never both) */
lua_assert(!bl->isbreakable || !bl->upval);
lua_assert(bl->nactvar == fs->nactvar);
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.128 2011/02/01 18:03:10 roberto Exp roberto $
+** $Id: lvm.c,v 2.129 2011/02/01 18:32:55 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -793,9 +793,6 @@ void luaV_execute (lua_State *L) {
}
L->top = ci->top; /* correct top (in case of previous open call) */
)
- vmcase(OP_CLOSE,
- luaF_close(L, ra);
- )
vmcase(OP_CLOSURE,
Proto *p = cl->p->p[GETARG_Bx(i)];
Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */