aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-27 14:56:33 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-27 14:56:33 -0200
commit5bd8d388de6704cc7f0eb60de33636a4dfcd61bd (patch)
treeb0d226562331d8667847908dc957a4e01f811dd5 /lvm.c
parent28f215ecf8b8d987f0bf64f3154b0e2fbc5e5168 (diff)
downloadlua-5bd8d388de6704cc7f0eb60de33636a4dfcd61bd.tar.gz
lua-5bd8d388de6704cc7f0eb60de33636a4dfcd61bd.tar.bz2
lua-5bd8d388de6704cc7f0eb60de33636a4dfcd61bd.zip
OP_CONCAT does not move its result (to simplify its execution)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/lvm.c b/lvm.c
index 12597eb4..73256267 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.333 2018/01/10 19:19:27 roberto Exp roberto $ 2** $Id: lvm.c,v 2.334 2018/01/14 17:27:50 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*/
@@ -717,15 +717,13 @@ void luaV_finishOp (lua_State *L) {
717 } 717 }
718 case OP_CONCAT: { 718 case OP_CONCAT: {
719 StkId top = L->top - 1; /* top when 'luaT_trybinTM' was called */ 719 StkId top = L->top - 1; /* top when 'luaT_trybinTM' was called */
720 int b = GETARG_B(inst); /* first element to concatenate */ 720 int a = GETARG_A(inst); /* first element to concatenate */
721 int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ 721 int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */
722 setobjs2s(L, top - 2, top); /* put TM result in proper position */ 722 setobjs2s(L, top - 2, top); /* put TM result in proper position */
723 if (total > 1) { /* are there elements to concat? */ 723 if (total > 1) { /* are there elements to concat? */
724 L->top = top - 1; /* top is one after last element (at top-2) */ 724 L->top = top - 1; /* top is one after last element (at top-2) */
725 luaV_concat(L, total); /* concat them (may yield again) */ 725 luaV_concat(L, total); /* concat them (may yield again) */
726 } 726 }
727 /* move final result to final position */
728 setobjs2s(L, ci->func + 1 + GETARG_A(inst), L->top - 1);
729 break; 727 break;
730 } 728 }
731 case OP_TFORCALL: case OP_CALL: case OP_TAILCALL: 729 case OP_TFORCALL: case OP_CALL: case OP_TAILCALL:
@@ -1376,18 +1374,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1376 vmbreak; 1374 vmbreak;
1377 } 1375 }
1378 vmcase(OP_CONCAT) { 1376 vmcase(OP_CONCAT) {
1379 int b = GETARG_B(i); 1377 int n = GETARG_B(i); /* number of elements to concatenate */
1380 int c = GETARG_C(i); 1378 L->top = ra + n; /* mark the end of concat operands */
1381 StkId rb; 1379 ProtectNT(luaV_concat(L, n));
1382 L->top = base + c + 1; /* mark the end of concat operands */ 1380 checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
1383 ProtectNT(luaV_concat(L, c - b + 1));
1384 if (trap) { /* 'luaV_concat' may move the stack */
1385 updatebase(ci);
1386 ra = RA(i);
1387 }
1388 rb = base + b;
1389 setobjs2s(L, ra, rb);
1390 checkGC(L, (ra >= rb ? ra + 1 : rb));
1391 vmbreak; 1381 vmbreak;
1392 } 1382 }
1393 vmcase(OP_CLOSE) { 1383 vmcase(OP_CLOSE) {