diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-13 10:54:47 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-13 10:54:47 -0300 |
| commit | 6d95de83c644da5f720cf468c38df9782f1c890d (patch) | |
| tree | 734170c5082ae1e44ad9fe69d85b167fd4d07207 /lvm.c | |
| parent | 5c8770f8969a73cf4ca503f54c2217f76de62e04 (diff) | |
| download | lua-6d95de83c644da5f720cf468c38df9782f1c890d.tar.gz lua-6d95de83c644da5f720cf468c38df9782f1c890d.tar.bz2 lua-6d95de83c644da5f720cf468c38df9782f1c890d.zip | |
no more field 'base' in CallInfo (base is always equal to 'func + 1',
with old/new vararg implementation)
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 23 |
1 files changed, 11 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.280 2017/05/11 18:57:46 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.281 2017/05/13 12:57:20 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 | */ |
| 660 | void luaV_finishOp (lua_State *L) { | 660 | void luaV_finishOp (lua_State *L) { |
| 661 | CallInfo *ci = L->ci; | 661 | CallInfo *ci = L->ci; |
| 662 | StkId base = ci->u.l.base; | 662 | StkId base = ci->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 */ |
| @@ -696,7 +696,7 @@ void luaV_finishOp (lua_State *L) { | |||
| 696 | luaV_concat(L, total); /* concat them (may yield again) */ | 696 | luaV_concat(L, total); /* concat them (may yield again) */ |
| 697 | } | 697 | } |
| 698 | /* move final result to final position */ | 698 | /* move final result to final position */ |
| 699 | setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); | 699 | setobj2s(L, ci->func + 1 + GETARG_A(inst), L->top - 1); |
| 700 | L->top = ci->top; /* restore top */ | 700 | L->top = ci->top; /* restore top */ |
| 701 | break; | 701 | break; |
| 702 | } | 702 | } |
| @@ -753,7 +753,7 @@ void luaV_finishOp (lua_State *L) { | |||
| 753 | */ | 753 | */ |
| 754 | #define dojump(ci,i,e) \ | 754 | #define dojump(ci,i,e) \ |
| 755 | { int a = GETARG_A(i); \ | 755 | { int a = GETARG_A(i); \ |
| 756 | if (a != 0) luaF_close(L, ci->u.l.base + a - 1); \ | 756 | if (a != 0) luaF_close(L, ci->func + a); \ |
| 757 | pc += GETARG_sBx(i) + e; updatemask(L); } | 757 | pc += GETARG_sBx(i) + e; updatemask(L); } |
| 758 | 758 | ||
| 759 | 759 | ||
| @@ -772,7 +772,7 @@ void luaV_finishOp (lua_State *L) { | |||
| 772 | ** stack, and change the hooks. | 772 | ** stack, and change the hooks. |
| 773 | */ | 773 | */ |
| 774 | #define Protect(code) \ | 774 | #define Protect(code) \ |
| 775 | { savepc(L); {code;}; base = ci->u.l.base; updatemask(L); } | 775 | { savepc(L); {code;}; base = ci->func + 1; updatemask(L); } |
| 776 | 776 | ||
| 777 | 777 | ||
| 778 | #define checkGC(L,c) \ | 778 | #define checkGC(L,c) \ |
| @@ -797,7 +797,7 @@ void luaV_execute (lua_State *L) { | |||
| 797 | CallInfo *ci = L->ci; | 797 | CallInfo *ci = L->ci; |
| 798 | LClosure *cl; | 798 | LClosure *cl; |
| 799 | TValue *k; | 799 | TValue *k; |
| 800 | StkId base; /* local copy of 'ci->u.l.base' */ | 800 | StkId base; /* local copy of 'ci->func + 1' */ |
| 801 | int mask; /* local copy of 'L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)' */ | 801 | int mask; /* local copy of 'L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)' */ |
| 802 | const Instruction *pc; /* local copy of 'ci->u.l.savedpc' */ | 802 | const Instruction *pc; /* local copy of 'ci->u.l.savedpc' */ |
| 803 | ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */ | 803 | ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */ |
| @@ -806,14 +806,14 @@ void luaV_execute (lua_State *L) { | |||
| 806 | cl = clLvalue(ci->func); /* local reference to function's closure */ | 806 | cl = clLvalue(ci->func); /* local reference to function's closure */ |
| 807 | k = cl->p->k; /* local reference to function's constant table */ | 807 | k = cl->p->k; /* local reference to function's constant table */ |
| 808 | updatemask(L); | 808 | updatemask(L); |
| 809 | base = ci->u.l.base; | 809 | base = ci->func + 1; |
| 810 | pc = ci->u.l.savedpc; | 810 | pc = ci->u.l.savedpc; |
| 811 | /* main loop of interpreter */ | 811 | /* main loop of interpreter */ |
| 812 | for (;;) { | 812 | for (;;) { |
| 813 | Instruction i; | 813 | Instruction i; |
| 814 | StkId ra; | 814 | StkId ra; |
| 815 | vmfetch(); | 815 | vmfetch(); |
| 816 | lua_assert(base == ci->u.l.base); | 816 | lua_assert(base == ci->func + 1); |
| 817 | lua_assert(base <= L->top && L->top < L->stack + L->stacksize); | 817 | lua_assert(base <= L->top && L->top < L->stack + L->stacksize); |
| 818 | vmdispatch (GET_OPCODE(i)) { | 818 | vmdispatch (GET_OPCODE(i)) { |
| 819 | vmcase(OP_MOVE) { | 819 | vmcase(OP_MOVE) { |
| @@ -1288,19 +1288,18 @@ void luaV_execute (lua_State *L) { | |||
| 1288 | StkId nfunc = nci->func; /* called function */ | 1288 | StkId nfunc = nci->func; /* called function */ |
| 1289 | StkId ofunc = oci->func; /* caller function */ | 1289 | StkId ofunc = oci->func; /* caller function */ |
| 1290 | /* last stack slot filled by 'precall' */ | 1290 | /* last stack slot filled by 'precall' */ |
| 1291 | StkId lim = nci->u.l.base + getproto(nfunc)->numparams; | 1291 | StkId lim = nci->func + 1 + getproto(nfunc)->numparams; |
| 1292 | int aux; | 1292 | int aux; |
| 1293 | /* close all upvalues from previous call */ | 1293 | /* close all upvalues from previous call */ |
| 1294 | if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); | 1294 | if (cl->p->sizep > 0) luaF_close(L, oci->func + 1); |
| 1295 | /* move new frame into old one */ | 1295 | /* move new frame into old one */ |
| 1296 | for (aux = 0; nfunc + aux < lim; aux++) | 1296 | for (aux = 0; nfunc + aux < lim; aux++) |
| 1297 | setobjs2s(L, ofunc + aux, nfunc + aux); | 1297 | setobjs2s(L, ofunc + aux, nfunc + aux); |
| 1298 | oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ | ||
| 1299 | oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ | 1298 | oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ |
| 1300 | oci->u.l.savedpc = nci->u.l.savedpc; | 1299 | oci->u.l.savedpc = nci->u.l.savedpc; |
| 1301 | oci->callstatus |= CIST_TAIL; /* function was tail called */ | 1300 | oci->callstatus |= CIST_TAIL; /* function was tail called */ |
| 1302 | ci = L->ci = oci; /* remove new frame */ | 1301 | ci = L->ci = oci; /* remove new frame */ |
| 1303 | lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); | 1302 | lua_assert(L->top == oci->func + 1 + getproto(ofunc)->maxstacksize); |
| 1304 | goto newframe; /* restart luaV_execute over new Lua function */ | 1303 | goto newframe; /* restart luaV_execute over new Lua function */ |
| 1305 | } | 1304 | } |
| 1306 | vmbreak; | 1305 | vmbreak; |
