small changes to allow 'precall' to spend time preserving 'func'

only when needed (that is, when stack actually changes)
This commit is contained in:
Roberto Ierusalimschy
2015-10-21 16:40:47 -02:00
parent 48098c42ff
commit 5bdee4f810
3 changed files with 42 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: llimits.h,v 1.138 2015/09/22 14:18:24 roberto Exp roberto $
** $Id: llimits.h,v 1.139 2015/10/06 14:29:49 roberto Exp roberto $
** Limits, basic types, and some other 'installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -306,17 +306,18 @@ typedef unsigned long Instruction;
** macro to control inclusion of some hard tests on stack reallocation
*/
#if !defined(HARDSTACKTESTS)
#define condmovestack(L) ((void)0)
#define condmovestack(L,pre,pos) ((void)0)
#else
/* realloc stack keeping its size */
#define condmovestack(L) luaD_reallocstack((L), (L)->stacksize)
#define condmovestack(L,pre,pos) \
{ int sz_ = (L)->stacksize; pre; luaD_reallocstack((L), sz_); pos; }
#endif
#if !defined(HARDMEMTESTS)
#define condchangemem(L) condmovestack(L)
#define condchangemem(L,pre,pos) ((void)0)
#else
#define condchangemem(L) \
((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1)))
#define condchangemem(L,pre,pos) \
{ if (G(L)->gcrunning) { pre; luaC_fullgc(L, 0); pos; } }
#endif
#endif