summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-02 14:09:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-02 14:09:30 -0200
commit8c1fb918027eea52c229907e3c3e371c7c14923a (patch)
tree8b853acd641ff9c8a8f5cc7b6c5e83cbe1d51c17
parent33b366ec321646890780b96df96eacb558b82f6d (diff)
downloadlua-8c1fb918027eea52c229907e3c3e371c7c14923a.tar.gz
lua-8c1fb918027eea52c229907e3c3e371c7c14923a.tar.bz2
lua-8c1fb918027eea52c229907e3c3e371c7c14923a.zip
macro 'incr_top' replaced by function 'luaD_inctop'. (It is not used
in critical time pathes, can save a few bytes without the macro)
-rw-r--r--ldo.c15
-rw-r--r--ldo.h4
-rw-r--r--lobject.c6
-rw-r--r--lparser.c6
-rw-r--r--lundump.c4
5 files changed, 24 insertions, 11 deletions
diff --git a/ldo.c b/ldo.c
index 524c1e57..beb77bcb 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.145 2015/11/02 11:48:59 roberto Exp roberto $ 2** $Id: ldo.c,v 2.146 2015/11/02 14:06:01 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*/
@@ -150,6 +150,11 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
150/* }====================================================== */ 150/* }====================================================== */
151 151
152 152
153/*
154** {==================================================================
155** Stack reallocation
156** ===================================================================
157*/
153static void correctstack (lua_State *L, TValue *oldstack) { 158static void correctstack (lua_State *L, TValue *oldstack) {
154 CallInfo *ci; 159 CallInfo *ci;
155 UpVal *up; 160 UpVal *up;
@@ -229,6 +234,14 @@ void luaD_shrinkstack (lua_State *L) {
229} 234}
230 235
231 236
237void luaD_inctop (lua_State *L) {
238 luaD_checkstack(L, 1);
239 L->top++;
240}
241
242/* }================================================================== */
243
244
232void luaD_hook (lua_State *L, int event, int line) { 245void luaD_hook (lua_State *L, int event, int line) {
233 lua_Hook hook = L->hook; 246 lua_Hook hook = L->hook;
234 if (hook && L->allowhook) { 247 if (hook && L->allowhook) {
diff --git a/ldo.h b/ldo.h
index 41f437cb..31986dc0 100644
--- a/ldo.h
+++ b/ldo.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.h,v 2.22 2015/05/22 17:48:19 roberto Exp roberto $ 2** $Id: ldo.h,v 2.23 2015/10/21 18:40:47 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*/
@@ -28,7 +28,6 @@
28#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,) 28#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,)
29 29
30 30
31#define incr_top(L) {L->top++; luaD_checkstack(L,0);}
32 31
33#define savestack(L,p) ((char *)(p) - (char *)L->stack) 32#define savestack(L,p) ((char *)(p) - (char *)L->stack)
34#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 33#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
@@ -49,6 +48,7 @@ LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres);
49LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 48LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
50LUAI_FUNC void luaD_growstack (lua_State *L, int n); 49LUAI_FUNC void luaD_growstack (lua_State *L, int n);
51LUAI_FUNC void luaD_shrinkstack (lua_State *L); 50LUAI_FUNC void luaD_shrinkstack (lua_State *L);
51LUAI_FUNC void luaD_inctop (lua_State *L);
52 52
53LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 53LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
54LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 54LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
diff --git a/lobject.c b/lobject.c
index 6b80c0ed..93dba050 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.106 2015/06/26 19:32:07 roberto Exp roberto $ 2** $Id: lobject.c,v 2.107 2015/11/02 14:02:35 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -347,7 +347,7 @@ void luaO_tostring (lua_State *L, StkId obj) {
347 347
348static void pushstr (lua_State *L, const char *str, size_t l) { 348static void pushstr (lua_State *L, const char *str, size_t l) {
349 setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); 349 setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
350 incr_top(L); 350 luaD_inctop(L);
351} 351}
352 352
353 353
@@ -385,7 +385,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
385 case 'f': { 385 case 'f': {
386 setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); 386 setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
387 top2str: 387 top2str:
388 incr_top(L); 388 luaD_inctop(L);
389 luaO_tostring(L, L->top - 1); 389 luaO_tostring(L, L->top - 1);
390 break; 390 break;
391 } 391 }
diff --git a/lparser.c b/lparser.c
index e621f680..9a5bcf37 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp roberto $ 2** $Id: lparser.c,v 2.148 2015/10/28 17:28:40 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1627,10 +1627,10 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
1627 FuncState funcstate; 1627 FuncState funcstate;
1628 LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ 1628 LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */
1629 setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ 1629 setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */
1630 incr_top(L); 1630 luaD_inctop(L);
1631 lexstate.h = luaH_new(L); /* create table for scanner */ 1631 lexstate.h = luaH_new(L); /* create table for scanner */
1632 sethvalue(L, L->top, lexstate.h); /* anchor it */ 1632 sethvalue(L, L->top, lexstate.h); /* anchor it */
1633 incr_top(L); 1633 luaD_inctop(L);
1634 funcstate.f = cl->p = luaF_newproto(L); 1634 funcstate.f = cl->p = luaF_newproto(L);
1635 funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ 1635 funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
1636 lua_assert(iswhite(funcstate.f)); /* do not need barrier here */ 1636 lua_assert(iswhite(funcstate.f)); /* do not need barrier here */
diff --git a/lundump.c b/lundump.c
index 469308d7..13916bc1 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 2.42 2015/09/08 15:41:05 roberto Exp roberto $ 2** $Id: lundump.c,v 2.43 2015/09/17 15:51:05 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -269,7 +269,7 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {
269 checkHeader(&S); 269 checkHeader(&S);
270 cl = luaF_newLclosure(L, LoadByte(&S)); 270 cl = luaF_newLclosure(L, LoadByte(&S));
271 setclLvalue(L, L->top, cl); 271 setclLvalue(L, L->top, cl);
272 incr_top(L); 272 luaD_inctop(L);
273 cl->p = luaF_newproto(L); 273 cl->p = luaF_newproto(L);
274 LoadFunction(&S, cl->p, NULL); 274 LoadFunction(&S, cl->p, NULL);
275 lua_assert(cl->nupvalues == cl->p->sizeupvalues); 275 lua_assert(cl->nupvalues == cl->p->sizeupvalues);