aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-14 15:27:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-14 15:27:50 -0200
commitd2fb34ac8865b2a7ec944a449d90145739030a98 (patch)
treed96e1ceb7b853eb07dabc7cbdfd4b71c7cd458d3 /lvm.c
parentab0a851db438c4dd50b76bcf624c15623cc057e4 (diff)
downloadlua-d2fb34ac8865b2a7ec944a449d90145739030a98.tar.gz
lua-d2fb34ac8865b2a7ec944a449d90145739030a98.tar.bz2
lua-d2fb34ac8865b2a7ec944a449d90145739030a98.zip
'OP_TAILCALL' calling C functions finishes the call and returns
(instead of waiting for following 'OP_RETURN')
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lvm.c b/lvm.c
index bdea807f..12597eb4 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.332 2018/01/09 14:23:40 roberto Exp roberto $ 2** $Id: lvm.c,v 2.333 2018/01/10 19:19:27 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1504,13 +1504,18 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1504 ProtectNT(luaD_tryfuncTM(L, ra)); /* try '__call' metamethod */ 1504 ProtectNT(luaD_tryfuncTM(L, ra)); /* try '__call' metamethod */
1505 b++; /* there is now one extra argument */ 1505 b++; /* there is now one extra argument */
1506 } 1506 }
1507 if (TESTARG_k(i))
1508 luaF_close(L, base); /* close upvalues from current call */
1507 if (!ttisLclosure(vra)) { /* C function? */ 1509 if (!ttisLclosure(vra)) { /* C function? */
1508 ProtectNT(luaD_call(L, ra, LUA_MULTRET)); /* call it */ 1510 ProtectNT(luaD_call(L, ra, LUA_MULTRET)); /* call it */
1509 /* next instruction will do the return */ 1511 if (trap) {
1512 updatebase(ci);
1513 ra = RA(i);
1514 }
1515 luaD_poscall(L, ci, ra, cast_int(L->top - ra));
1516 return;
1510 } 1517 }
1511 else { /* tail call */ 1518 else { /* Lua tail call */
1512 if (TESTARG_k(i)) /* close upvalues from previous call */
1513 luaF_close(L, ci->func + 1);
1514 luaD_pretailcall(L, ci, ra, b); /* prepare call frame */ 1519 luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
1515 goto tailcall; 1520 goto tailcall;
1516 } 1521 }