aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-01 16:20:48 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-01 16:20:48 -0200
commitb9e76be8a691ed83a716a85c6b85cb80f66cc480 (patch)
tree851df615f2cb00ba1bdf4042336a56b7c4609a40 /lvm.c
parentc5482468fde11c6c169da3b331a0653455f8fc94 (diff)
downloadlua-b9e76be8a691ed83a716a85c6b85cb80f66cc480.tar.gz
lua-b9e76be8a691ed83a716a85c6b85cb80f66cc480.tar.bz2
lua-b9e76be8a691ed83a716a85c6b85cb80f66cc480.zip
using 'L->func' when possible
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/lvm.c b/lvm.c
index 4fabd744..25b953a4 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.299 2017/10/04 21:56:32 roberto Exp roberto $ 2** $Id: lvm.c,v 2.300 2017/10/31 17:54:35 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*/
@@ -659,7 +659,7 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
659*/ 659*/
660void luaV_finishOp (lua_State *L) { 660void luaV_finishOp (lua_State *L) {
661 CallInfo *ci = L->ci; 661 CallInfo *ci = L->ci;
662 StkId base = ci->func + 1; 662 StkId base = L->func + 1;
663 Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ 663 Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
664 OpCode op = GET_OPCODE(inst); 664 OpCode op = GET_OPCODE(inst);
665 switch (op) { /* finish its execution */ 665 switch (op) { /* finish its execution */
@@ -699,7 +699,7 @@ void luaV_finishOp (lua_State *L) {
699 luaV_concat(L, total); /* concat them (may yield again) */ 699 luaV_concat(L, total); /* concat them (may yield again) */
700 } 700 }
701 /* move final result to final position */ 701 /* move final result to final position */
702 setobjs2s(L, ci->func + 1 + GETARG_A(inst), L->top - 1); 702 setobjs2s(L, L->func + 1 + GETARG_A(inst), L->top - 1);
703 L->top = ci->top; /* restore top */ 703 L->top = ci->top; /* restore top */
704 break; 704 break;
705 } 705 }
@@ -771,7 +771,7 @@ void luaV_finishOp (lua_State *L) {
771** stack, and change the hooks. 771** stack, and change the hooks.
772*/ 772*/
773#define Protect(code) \ 773#define Protect(code) \
774 { savepc(L); {code;}; base = ci->func + 1; updatemask(L); } 774 { savepc(L); {code;}; base = L->func + 1; updatemask(L); }
775 775
776 776
777#define checkGC(L,c) \ 777#define checkGC(L,c) \
@@ -796,23 +796,23 @@ void luaV_execute (lua_State *L) {
796 CallInfo *ci = L->ci; 796 CallInfo *ci = L->ci;
797 LClosure *cl; 797 LClosure *cl;
798 TValue *k; 798 TValue *k;
799 StkId base; /* local copy of 'ci->func + 1' */ 799 StkId base; /* local copy of 'L->func + 1' */
800 int mask; /* local copy of 'L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)' */ 800 int mask; /* local copy of 'L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)' */
801 const Instruction *pc; /* local copy of 'ci->u.l.savedpc' */ 801 const Instruction *pc; /* local copy of 'ci->u.l.savedpc' */
802 ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */ 802 ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */
803 newframe: /* reentry point when frame changes (call/return) */ 803 newframe: /* reentry point when frame changes (call/return) */
804 lua_assert(ci == L->ci); 804 lua_assert(ci == L->ci);
805 cl = clLvalue(s2v(ci->func)); /* local reference to function's closure */ 805 cl = clLvalue(s2v(L->func)); /* local reference to function's closure */
806 k = cl->p->k; /* local reference to function's constant table */ 806 k = cl->p->k; /* local reference to function's constant table */
807 updatemask(L); 807 updatemask(L);
808 base = ci->func + 1; 808 base = L->func + 1;
809 pc = ci->u.l.savedpc; 809 pc = ci->u.l.savedpc;
810 /* main loop of interpreter */ 810 /* main loop of interpreter */
811 for (;;) { 811 for (;;) {
812 Instruction i; 812 Instruction i;
813 StkId ra; 813 StkId ra;
814 vmfetch(); 814 vmfetch();
815 lua_assert(base == ci->func + 1); 815 lua_assert(base == L->func + 1);
816 lua_assert(base <= L->top && L->top < L->stack + L->stacksize); 816 lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
817 vmdispatch (GET_OPCODE(i)) { 817 vmdispatch (GET_OPCODE(i)) {
818 vmcase(OP_MOVE) { 818 vmcase(OP_MOVE) {
@@ -1377,12 +1377,12 @@ void luaV_execute (lua_State *L) {
1377 CallInfo *nci = L->ci; /* called frame (new) */ 1377 CallInfo *nci = L->ci; /* called frame (new) */
1378 CallInfo *oci = nci->previous; /* caller frame (old) */ 1378 CallInfo *oci = nci->previous; /* caller frame (old) */
1379 StkId nfunc = nci->func; /* called function */ 1379 StkId nfunc = nci->func; /* called function */
1380 StkId ofunc = oci->func; /* caller function */ 1380 StkId ofunc = nfunc - nfunc->stkci.previous; /* caller function */
1381 /* last stack slot filled by 'precall' */ 1381 /* last stack slot filled by 'precall' */
1382 StkId lim = nci->func + 1 + getproto(s2v(nfunc))->numparams; 1382 StkId lim = nfunc + 1 + getproto(s2v(nfunc))->numparams;
1383 int aux; 1383 int aux;
1384 /* close all upvalues from previous call */ 1384 /* close all upvalues from previous call */
1385 if (cl->p->sizep > 0) luaF_close(L, oci->func + 1); 1385 if (cl->p->sizep > 0) luaF_close(L, ofunc + 1);
1386 /* move new frame into old one */ 1386 /* move new frame into old one */
1387 for (aux = 0; nfunc + aux < lim; aux++) 1387 for (aux = 0; nfunc + aux < lim; aux++)
1388 setobjs2s(L, ofunc + aux, nfunc + aux); 1388 setobjs2s(L, ofunc + aux, nfunc + aux);
@@ -1391,8 +1391,7 @@ void luaV_execute (lua_State *L) {
1391 oci->callstatus |= CIST_TAIL; /* function was tail called */ 1391 oci->callstatus |= CIST_TAIL; /* function was tail called */
1392 ci = L->ci = oci; /* remove new frame */ 1392 ci = L->ci = oci; /* remove new frame */
1393 L->func = ofunc; 1393 L->func = ofunc;
1394 lua_assert(L->top == 1394 lua_assert(L->top == ofunc + 1 + getproto(s2v(ofunc))->maxstacksize);
1395 oci->func + 1 + getproto(s2v(ofunc))->maxstacksize);
1396 goto newframe; /* restart luaV_execute over new Lua function */ 1395 goto newframe; /* restart luaV_execute over new Lua function */
1397 } 1396 }
1398 vmbreak; 1397 vmbreak;