From 7ca3c40b50b385ead6b8bc4c54de97b61d11a12a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 10 Jan 2025 13:54:51 -0300 Subject: Another way to compile goto's The compilation of a goto or a label just create an entry and generate boilerplate code for the gotos. As we don't know yet whether it needs a CLOSE, we code a jump followed by a CLOSE, which is then dead code. When a block ends (and then we know for sure whether there are variables that need to be closed), we check the goto's against the labels of that block. When closing a goto against a label, if it needs a CLOSE, the compiler swaps the order of the jump and the CLOSE, making the CLOSE active. --- lvm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lvm.c') diff --git a/lvm.c b/lvm.c index 73d7ee43..074ee718 100644 --- a/lvm.c +++ b/lvm.c @@ -1590,6 +1590,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { } vmcase(OP_CLOSE) { StkId ra = RA(i); + lua_assert(!GETARG_B(i)); /* 'close must be alive */ Protect(luaF_close(L, ra, LUA_OK, 1)); vmbreak; } -- cgit v1.2.3-55-g6feb