aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-10-31 15:54:35 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-10-31 15:54:35 -0200
commitc5482468fde11c6c169da3b331a0653455f8fc94 (patch)
tree2a48592c73f5a94f1615793d66cb7fcf1c5b8946 /ldo.c
parentad5dcdcf0f1e139c8cc5b1aafd11db69f54010de (diff)
downloadlua-c5482468fde11c6c169da3b331a0653455f8fc94.tar.gz
lua-c5482468fde11c6c169da3b331a0653455f8fc94.tar.bz2
lua-c5482468fde11c6c169da3b331a0653455f8fc94.zip
baby steps to remove 'CallInfo': keeping 'L->func' correct
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ldo.c b/ldo.c
index 0c0bb0bc..4d2b3c76 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.161 2017/06/29 15:06:44 roberto Exp roberto $ 2** $Id: ldo.c,v 2.162 2017/07/27 13:50:16 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -160,6 +160,7 @@ static void correctstack (lua_State *L, StkId oldstack) {
160 CallInfo *ci; 160 CallInfo *ci;
161 UpVal *up; 161 UpVal *up;
162 L->top = (L->top - oldstack) + L->stack; 162 L->top = (L->top - oldstack) + L->stack;
163 L->func = (L->func - oldstack) + L->stack;
163 for (up = L->openupval; up != NULL; up = up->u.open.next) 164 for (up = L->openupval; up != NULL; up = up->u.open.next)
164 up->v = s2v((uplevel(up) - oldstack) + L->stack); 165 up->v = s2v((uplevel(up) - oldstack) + L->stack);
165 for (ci = L->ci; ci != NULL; ci = ci->previous) { 166 for (ci = L->ci; ci != NULL; ci = ci->previous) {
@@ -369,6 +370,8 @@ int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
369 } 370 }
370 res = ci->func; /* res == final position of 1st result */ 371 res = ci->func; /* res == final position of 1st result */
371 L->ci = ci->previous; /* back to caller */ 372 L->ci = ci->previous; /* back to caller */
373 L->func -= L->func->stkci.previous;
374 lua_assert(L->func == L->ci->func);
372 /* move results to proper place */ 375 /* move results to proper place */
373 return moveresults(L, firstResult, res, nres, wanted); 376 return moveresults(L, firstResult, res, nres, wanted);
374} 377}
@@ -400,7 +403,8 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
400 checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ 403 checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
401 ci = next_ci(L); /* now 'enter' new function */ 404 ci = next_ci(L); /* now 'enter' new function */
402 ci->nresults = nresults; 405 ci->nresults = nresults;
403 ci->func = func; 406 func->stkci.previous = func - L->func;
407 L->func = ci->func = func;
404 ci->top = L->top + LUA_MINSTACK; 408 ci->top = L->top + LUA_MINSTACK;
405 lua_assert(ci->top <= L->stack_last); 409 lua_assert(ci->top <= L->stack_last);
406 ci->callstatus = 0; 410 ci->callstatus = 0;
@@ -424,7 +428,8 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
424 luaT_adjustvarargs(L, p, n); 428 luaT_adjustvarargs(L, p, n);
425 ci = next_ci(L); /* now 'enter' new function */ 429 ci = next_ci(L); /* now 'enter' new function */
426 ci->nresults = nresults; 430 ci->nresults = nresults;
427 ci->func = func; 431 func->stkci.previous = func - L->func;
432 L->func = ci->func = func;
428 L->top = ci->top = func + 1 + fsize; 433 L->top = ci->top = func + 1 + fsize;
429 lua_assert(ci->top <= L->stack_last); 434 lua_assert(ci->top <= L->stack_last);
430 ci->u.l.savedpc = p->code; /* starting point */ 435 ci->u.l.savedpc = p->code; /* starting point */
@@ -558,6 +563,7 @@ static int recover (lua_State *L, int status) {
558 luaF_close(L, oldtop); 563 luaF_close(L, oldtop);
559 seterrorobj(L, status, oldtop); 564 seterrorobj(L, status, oldtop);
560 L->ci = ci; 565 L->ci = ci;
566 L->func = ci->func;
561 L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ 567 L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */
562 L->nny = 0; /* should be zero to be yieldable */ 568 L->nny = 0; /* should be zero to be yieldable */
563 luaD_shrinkstack(L); 569 luaD_shrinkstack(L);
@@ -693,6 +699,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
693 ptrdiff_t old_top, ptrdiff_t ef) { 699 ptrdiff_t old_top, ptrdiff_t ef) {
694 int status; 700 int status;
695 CallInfo *old_ci = L->ci; 701 CallInfo *old_ci = L->ci;
702 ptrdiff_t oldfunc = savestack(L, L->func);
696 lu_byte old_allowhooks = L->allowhook; 703 lu_byte old_allowhooks = L->allowhook;
697 unsigned short old_nny = L->nny; 704 unsigned short old_nny = L->nny;
698 ptrdiff_t old_errfunc = L->errfunc; 705 ptrdiff_t old_errfunc = L->errfunc;
@@ -703,6 +710,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
703 luaF_close(L, oldtop); /* close possible pending closures */ 710 luaF_close(L, oldtop); /* close possible pending closures */
704 seterrorobj(L, status, oldtop); 711 seterrorobj(L, status, oldtop);
705 L->ci = old_ci; 712 L->ci = old_ci;
713 L->func = restorestack(L, oldfunc);
706 L->allowhook = old_allowhooks; 714 L->allowhook = old_allowhooks;
707 L->nny = old_nny; 715 L->nny = old_nny;
708 luaD_shrinkstack(L); 716 luaD_shrinkstack(L);