30 #define GCSWEEPCOST ((sizeof(TString) + 4) / 4)
33 #define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4))
36 #define GCFINALIZENUM 4
43 #define STEPMULADJ 200
57 #define maskcolors (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS))
58 #define makewhite(g,x) \
59 (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g)))
61 #define white2gray(x) resetbits(gch(x)->marked, WHITEBITS)
62 #define black2gray(x) resetbit(gch(x)->marked, BLACKBIT)
65 #define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT)
67 #define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))
70 #define checkconsistency(obj) \
71 lua_longassert(!iscollectable(obj) || righttt(obj))
74 #define markvalue(g,o) { checkconsistency(o); \
75 if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
77 #define markobject(g,t) { if ((t) && iswhite(obj2gco(t))) \
78 reallymarkobject(g, obj2gco(t)); }
93 #define gnodelast(h) gnode(h, cast(size_t, sizenode(h)))
99 #define linktable(h,p) ((h)->gclist = *(p), *(p) = obj2gco(h))
174 if (p->
cache == NULL) {
220 gch(o)->next = *list;
245 switch (
gch(o)->tt) {
263 size =
sizeof(
UpVal);
434 const char *weakkey, *weakvalue;
438 ((weakkey = strchr(
svalue(mode),
'k')),
439 (weakvalue = strchr(
svalue(mode),
'v')),
440 (weakkey || weakvalue))) {
461 for (i = 0; i < f->
sizek; i++)
465 for (i = 0; i < f->
sizep; i++)
480 for (i = 0; i < cl->nupvalues; i++)
488 for (i = 0; i < cl->nupvalues; i++)
499 for (; o < th->
top; o++)
525 switch (
gch(o)->tt) {
534 g->
gray = cl->gclist;
540 g->
gray = cl->gclist;
600 while ((w = next) != NULL) {
601 next =
gco2t(w)->gclist;
625 for (; l !=
f; l =
gco2t(l)->gclist) {
643 for (; l !=
f; l =
gco2t(l)->gclist) {
663 switch (
gch(o)->tt) {
689 #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
698 if (L1->
stack == NULL)
return;
733 while (*p != NULL && count-- > 0) {
735 int marked =
gch(curr)->marked;
737 *p =
gch(curr)->next;
746 gch(curr)->marked =
cast_byte((marked & toclear) | toset);
747 p = &
gch(curr)->next;
750 return (*p == NULL) ? NULL :
p;
826 if (status !=
LUA_OK && propagateerrors) {
850 while (*lastnext != NULL)
851 lastnext = &
gch(*lastnext)->next;
852 while ((curr = *p) != NULL) {
856 p = &
gch(curr)->next;
859 *p =
gch(curr)->next;
860 gch(curr)->next = *lastnext;
862 lastnext = &
gch(curr)->next;
886 for (p = &g->
allgc; *p != o; p = &
gch(*p)->next) { }
913 l_mem debt, threshold;
923 #define sweepphases \
924 (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep))
953 if (mode == g->
gckind)
return;
977 GCTM(L, propagateerrors);
1142 if (stepmul < 40) stepmul = 40;
1190 int origkind = g->
gckind;
#define luaZ_freebuffer(L, buff)
void luaE_setdebt(global_State *g, l_mem debt)
void luaE_freethread(lua_State *L, lua_State *L1)
static int iscleared(global_State *g, const TValue *o)
static int traverseephemeron(global_State *g, Table *h)
static void traverseweakvalue(global_State *g, Table *h)
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
#define gfasttm(g, et, e)
static void dothecall(lua_State *L, void *ud)
void luaD_shrinkstack(lua_State *L)
void luaC_step(lua_State *L)
static void propagatelist(global_State *g, GCObject *l)
static void markbeingfnz(global_State *g)
#define setgcovalue(L, obj, x)
static void separatetobefnz(lua_State *L, int all)
static void sweepthread(lua_State *L, lua_State *L1)
static void callallpendingfinalizers(lua_State *L, int propagateerrors)
static void propagateall(global_State *g)
GCObject * luaC_newobj(lua_State *L, int tt, size_t sz, GCObject **list, int offset)
static void clearvalues(global_State *g, GCObject *l, GCObject *f)
void luaC_forcestep(lua_State *L)
unsigned LUA_INT32 lu_int32
static lu_mem singlestep(lua_State *L)
void luaC_freeallobjects(lua_State *L)
void luaE_freeCI(lua_State *L)
static lu_mem traversetable(global_State *g, Table *h)
static lu_mem traverseCclosure(global_State *g, CClosure *cl)
void luaC_runtilstate(lua_State *L, int statesmask)
void luaC_checkupvalcolor(global_State *g, UpVal *uv)
void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
static void setpause(global_State *g, l_mem estimate)
static void remarkupvals(global_State *g)
#define luaM_freemem(L, b, s)
void luaC_changemode(lua_State *L, int mode)
struct lua_State * mainthread
static void clearkeys(global_State *g, GCObject *l, GCObject *f)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
GLubyte GLubyte GLubyte GLubyte w
struct lua_State lua_State
#define luaM_newobject(L, tag, s)
static void restartcollection(global_State *g)
static lu_mem traverseLclosure(global_State *g, LClosure *cl)
LUAI_FUNC void luaC_barrierproto_(lua_State *L, Proto *p, Closure *c)
static void retraversegrays(global_State *g)
static void removeentry(Node *n)
struct Upvaldesc Upvaldesc
#define keepinvariantout(g)
static lu_mem traversestack(global_State *g, lua_State *th)
static GCObject * udata2finalize(global_State *g)
#define isgenerational(g)
static void markmt(global_State *g)
static void traversestrongtable(global_State *g, Table *h)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static void propagatemark(global_State *g)
static void convergeephemerons(global_State *g)
struct Table * mt[LUA_NUMTAGS]
GLuint GLuint GLsizei count
static void incstep(lua_State *L)
static void GCTM(lua_State *L, int propagateerrors)
l_noret luaD_throw(lua_State *L, int errcode)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
static void reallymarkobject(global_State *g, GCObject *o)
static l_mem atomic(lua_State *L)
void luaH_free(lua_State *L, Table *t)
GLfloat GLfloat GLfloat GLfloat h
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
static int traverseproto(global_State *g, Proto *f)
static map_location::DIRECTION sw
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
static void checkSizes(lua_State *L)
static GCObject ** sweeptolive(lua_State *L, GCObject **p, int *n)
void luaC_barrierback_(lua_State *L, GCObject *o)
#define sweepwholelist(L, p)
void luaS_resize(lua_State *L, int newsize)
void luaF_freeupval(lua_State *L, UpVal *uv)
static void generationalcollection(lua_State *L)
void luaD_call(lua_State *L, StkId func, int nResults, int allowyield)
static int entersweep(lua_State *L)
void luaC_fullgc(lua_State *L, int isemergency)
#define setdeadvalue(obj)
void luaF_freeproto(lua_State *L, Proto *f)
#define luaC_objbarrier(L, p, o)
static GCObject ** sweeplist(lua_State *L, GCObject **p, lu_mem count)
static void freeobj(lua_State *L, GCObject *o)