aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-22 09:02:36 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-22 09:02:36 -0300
commit02ed0b2c300e9db643454743a26537756dc90b67 (patch)
tree18aff13e3f254083772e240935054e6a64cbb999 /lvm.c
parentde53c2ec7ed5115ec78dd0c497d62dadb7eb2161 (diff)
downloadlua-02ed0b2c300e9db643454743a26537756dc90b67.tar.gz
lua-02ed0b2c300e9db643454743a26537756dc90b67.tar.bz2
lua-02ed0b2c300e9db643454743a26537756dc90b67.zip
in 'luaD_poscall', there is no need to compute 'firstResult' when 'nres==0'
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lvm.c b/lvm.c
index 347a8269..4406afb6 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.353 2018/04/04 14:23:41 roberto Exp roberto $ 2** $Id: lvm.c,v 2.354 2018/05/02 18:17:59 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*/
@@ -1591,7 +1591,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1591 ra = RA(i); 1591 ra = RA(i);
1592 } 1592 }
1593 ci->func -= delta; 1593 ci->func -= delta;
1594 luaD_poscall(L, ci, ra, cast_int(L->top - ra)); 1594 luaD_poscall(L, ci, cast_int(L->top - ra));
1595 return; 1595 return;
1596 } 1596 }
1597 else { /* Lua tail call */ 1597 else { /* Lua tail call */
@@ -1602,20 +1602,25 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1602 vmbreak; 1602 vmbreak;
1603 } 1603 }
1604 vmcase(OP_RETURN) { 1604 vmcase(OP_RETURN) {
1605 int b = GETARG_B(i); 1605 int n = GETARG_B(i) - 1; /* number of results */
1606 int n = (b != 0 ? b - 1 : cast_int(L->top - ra)); 1606 if (n < 0) /* not fixed? */
1607 n = cast_int(L->top - ra); /* get what is available */
1608 else
1609 L->top = ra + n; /* set call for 'luaD_poscall' */
1607 if (TESTARG_k(i)) { 1610 if (TESTARG_k(i)) {
1608 int nparams1 = GETARG_C(i); 1611 int nparams1 = GETARG_C(i);
1609 if (nparams1) /* vararg function? */ 1612 if (nparams1) /* vararg function? */
1610 ci->func -= ci->u.l.nextraargs + nparams1; 1613 ci->func -= ci->u.l.nextraargs + nparams1;
1611 luaF_close(L, base); /* there may be open upvalues */ 1614 luaF_close(L, base); /* there may be open upvalues */
1612 } 1615 }
1613 halfProtect(luaD_poscall(L, ci, ra, n)); 1616 halfProtect(luaD_poscall(L, ci, n));
1614 return; 1617 return;
1615 } 1618 }
1616 vmcase(OP_RETURN0) { 1619 vmcase(OP_RETURN0) {
1617 if (L->hookmask) 1620 if (L->hookmask) {
1618 halfProtect(luaD_poscall(L, ci, ra, 0)); /* no hurry... */ 1621 L->top = ra;
1622 halfProtect(luaD_poscall(L, ci, 0)); /* no hurry... */
1623 }
1619 else { 1624 else {
1620 int nres = ci->nresults; 1625 int nres = ci->nresults;
1621 L->ci = ci->previous; /* back to caller */ 1626 L->ci = ci->previous; /* back to caller */
@@ -1626,8 +1631,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1626 return; 1631 return;
1627 } 1632 }
1628 vmcase(OP_RETURN1) { 1633 vmcase(OP_RETURN1) {
1629 if (L->hookmask) 1634 if (L->hookmask) {
1630 halfProtect(luaD_poscall(L, ci, ra, 1)); /* no hurry... */ 1635 L->top = ra + 1;
1636 halfProtect(luaD_poscall(L, ci, 1)); /* no hurry... */
1637 }
1631 else { 1638 else {
1632 int nres = ci->nresults; 1639 int nres = ci->nresults;
1633 L->ci = ci->previous; /* back to caller */ 1640 L->ci = ci->previous; /* back to caller */