Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lgc.h File Reference
#include "lobject.h"
#include "lstate.h"

Go to the source code of this file.

Macros

#define GCSpropagate   0
 
#define GCSenteratomic   1
 
#define GCSatomic   2
 
#define GCSswpallgc   3
 
#define GCSswpfinobj   4
 
#define GCSswptobefnz   5
 
#define GCSswpend   6
 
#define GCScallfin   7
 
#define GCSpause   8
 
#define issweepphase(g)    (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
 
#define keepinvariant(g)   ((g)->gcstate <= GCSatomic)
 
#define resetbits(x, m)   ((x) &= cast_byte(~(m)))
 
#define setbits(x, m)   ((x) |= (m))
 
#define testbits(x, m)   ((x) & (m))
 
#define bitmask(b)   (1<<(b))
 
#define bit2mask(b1, b2)   (bitmask(b1) | bitmask(b2))
 
#define l_setbit(x, b)   setbits(x, bitmask(b))
 
#define resetbit(x, b)   resetbits(x, bitmask(b))
 
#define testbit(x, b)   testbits(x, bitmask(b))
 
#define WHITE0BIT   3 /* object is white (type 0) */
 
#define WHITE1BIT   4 /* object is white (type 1) */
 
#define BLACKBIT   5 /* object is black */
 
#define FINALIZEDBIT   6 /* object has been marked for finalization */
 
#define TESTBIT   7
 
#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)
 
#define iswhite(x)   testbits((x)->marked, WHITEBITS)
 
#define isblack(x)   testbit((x)->marked, BLACKBIT)
 
#define isgray(x)
 
#define tofinalize(x)   testbit((x)->marked, FINALIZEDBIT)
 
#define otherwhite(g)   ((g)->currentwhite ^ WHITEBITS)
 
#define isdeadm(ow, m)   ((m) & (ow))
 
#define isdead(g, v)   isdeadm(otherwhite(g), (v)->marked)
 
#define changewhite(x)   ((x)->marked ^= WHITEBITS)
 
#define nw2black(x)    check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT))
 
#define luaC_white(g)   cast_byte((g)->currentwhite & WHITEBITS)
 
#define G_NEW   0 /* created in current cycle */
 
#define G_SURVIVAL   1 /* created in previous cycle */
 
#define G_OLD0   2 /* marked old by frw. barrier in this cycle */
 
#define G_OLD1   3 /* first full cycle as old */
 
#define G_OLD   4 /* really old object (not to be visited) */
 
#define G_TOUCHED1   5 /* old object touched this cycle */
 
#define G_TOUCHED2   6 /* old object touched in previous cycle */
 
#define AGEBITS   7 /* all age bits (111) */
 
#define getage(o)   ((o)->marked & AGEBITS)
 
#define setage(o, a)   ((o)->marked = cast_byte(((o)->marked & (~AGEBITS)) | a))
 
#define isold(o)   (getage(o) > G_SURVIVAL)
 
#define changeage(o, f, t)    check_exp(getage(o) == (f), (o)->marked ^= ((f)^(t)))
 
#define LUAI_GENMAJORMUL   100
 
#define LUAI_GENMINORMUL   20
 
#define LUAI_GCPAUSE   200
 
#define getgcparam(p)   ((p) * 4)
 
#define setgcparam(p, v)   ((p) = (v) / 4)
 
#define LUAI_GCMUL   100
 
#define LUAI_GCSTEPSIZE   13 /* 8 KB */
 
#define isdecGCmodegen(g)   (g->gckind == KGC_GEN || g->lastatomic != 0)
 
#define luaC_condGC(L, pre, pos)
 
#define luaC_checkGC(L)   luaC_condGC(L,(void)0,(void)0)
 
#define luaC_barrier(L, p, v)
 
#define luaC_barrierback(L, p, v)
 
#define luaC_objbarrier(L, p, o)
 

Functions

LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o)
 
LUAI_FUNC void luaC_freeallobjects (lua_State *L)
 
LUAI_FUNC void luaC_step (lua_State *L)
 
LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask)
 
LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency)
 
LUAI_FUNC GCObjectluaC_newobj (lua_State *L, int tt, size_t sz)
 
LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v)
 
LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o)
 
LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt)
 
LUAI_FUNC void luaC_changemode (lua_State *L, int newmode)
 

Macro Definition Documentation

◆ AGEBITS

#define AGEBITS   7 /* all age bits (111) */

Definition at line 114 of file lua-5.4.3/src/lgc.h.

◆ bit2mask

#define bit2mask ( b1,
b2 )   (bitmask(b1) | bitmask(b2))

Definition at line 64 of file lua-5.4.3/src/lgc.h.

◆ bitmask

#define bitmask ( b)    (1<<(b))

Definition at line 63 of file lua-5.4.3/src/lgc.h.

◆ BLACKBIT

#define BLACKBIT   5 /* object is black */

Definition at line 77 of file lua-5.4.3/src/lgc.h.

◆ changeage

#define changeage ( o,
f,
t )    check_exp(getage(o) == (f), (o)->marked ^= ((f)^(t)))

Definition at line 120 of file lua-5.4.3/src/lgc.h.

120#define changeage(o,f,t) \
121 check_exp(getage(o) == (f), (o)->marked ^= ((f)^(t)))

Referenced by correctgraylist(), genlink(), and markold().

◆ changewhite

#define changewhite ( x)    ((x)->marked ^= WHITEBITS)

Definition at line 98 of file lua-5.4.3/src/lgc.h.

◆ FINALIZEDBIT

#define FINALIZEDBIT   6 /* object has been marked for finalization */

Definition at line 78 of file lua-5.4.3/src/lgc.h.

◆ G_NEW

#define G_NEW   0 /* created in current cycle */

Definition at line 106 of file lua-5.4.3/src/lgc.h.

Referenced by sweepgen().

◆ G_OLD

#define G_OLD   4 /* really old object (not to be visited) */

Definition at line 110 of file lua-5.4.3/src/lgc.h.

Referenced by correctgraylist(), genlink(), luaC_fix(), markold(), sweep2old(), and sweepgen().

◆ G_OLD0

#define G_OLD0   2 /* marked old by frw. barrier in this cycle */

Definition at line 108 of file lua-5.4.3/src/lgc.h.

Referenced by luaC_barrier_().

◆ G_OLD1

#define G_OLD1   3 /* first full cycle as old */

Definition at line 109 of file lua-5.4.3/src/lgc.h.

Referenced by markold(), sweepgen(), and udata2finalize().

◆ G_SURVIVAL

#define G_SURVIVAL   1 /* created in previous cycle */

Definition at line 107 of file lua-5.4.3/src/lgc.h.

Referenced by sweepgen().

◆ G_TOUCHED1

#define G_TOUCHED1   5 /* old object touched this cycle */

Definition at line 111 of file lua-5.4.3/src/lgc.h.

Referenced by correctgraylist(), genlink(), luaC_barrierback_(), and sweepgen().

◆ G_TOUCHED2

#define G_TOUCHED2   6 /* old object touched in previous cycle */

Definition at line 112 of file lua-5.4.3/src/lgc.h.

Referenced by correctgraylist(), genlink(), luaC_barrierback_(), and sweepgen().

◆ GCSatomic

#define GCSatomic   2

Definition at line 33 of file lua-5.4.3/src/lgc.h.

◆ GCScallfin

#define GCScallfin   7

Definition at line 38 of file lua-5.4.3/src/lgc.h.

◆ GCSenteratomic

#define GCSenteratomic   1

Definition at line 32 of file lua-5.4.3/src/lgc.h.

Referenced by singlestep().

◆ GCSpause

#define GCSpause   8

Definition at line 39 of file lua-5.4.3/src/lgc.h.

◆ GCSpropagate

#define GCSpropagate   0

Definition at line 31 of file lua-5.4.3/src/lgc.h.

◆ GCSswpallgc

#define GCSswpallgc   3

Definition at line 34 of file lua-5.4.3/src/lgc.h.

◆ GCSswpend

#define GCSswpend   6

Definition at line 37 of file lua-5.4.3/src/lgc.h.

◆ GCSswpfinobj

#define GCSswpfinobj   4

Definition at line 35 of file lua-5.4.3/src/lgc.h.

◆ GCSswptobefnz

#define GCSswptobefnz   5

Definition at line 36 of file lua-5.4.3/src/lgc.h.

◆ getage

#define getage ( o)    ((o)->marked & AGEBITS)

◆ getgcparam

#define getgcparam ( p)    ((p) * 4)

Definition at line 135 of file lua-5.4.3/src/lgc.h.

Referenced by genstep(), incstep(), lua_gc(), and setpause().

◆ isblack

#define isblack ( x)    testbit((x)->marked, BLACKBIT)

Definition at line 88 of file lua-5.4.3/src/lgc.h.

◆ isdead

#define isdead ( g,
v )   isdeadm(otherwhite(g), (v)->marked)

Definition at line 96 of file lua-5.4.3/src/lgc.h.

◆ isdeadm

#define isdeadm ( ow,
m )   ((m) & (ow))

Definition at line 95 of file lua-5.4.3/src/lgc.h.

◆ isdecGCmodegen

#define isdecGCmodegen ( g)    (g->gckind == KGC_GEN || g->lastatomic != 0)

Definition at line 149 of file lua-5.4.3/src/lgc.h.

Referenced by genstep(), lua_gc(), and luaC_step().

◆ isgray

#define isgray ( x)
Value:
/* neither white nor black */ \
(!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT)))
#define WHITEBITS
#define testbits(x, m)
#define BLACKBIT
#define bitmask(b)

Definition at line 89 of file lua-5.4.3/src/lgc.h.

89#define isgray(x) /* neither white nor black */ \
90 (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT)))

◆ isold

#define isold ( o)    (getage(o) > G_SURVIVAL)

Definition at line 118 of file lua-5.4.3/src/lgc.h.

◆ issweepphase

#define issweepphase ( g)     (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)

Definition at line 42 of file lua-5.4.3/src/lgc.h.

42#define issweepphase(g) \
43 (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)

◆ iswhite

#define iswhite ( x)    testbits((x)->marked, WHITEBITS)

Definition at line 87 of file lua-5.4.3/src/lgc.h.

◆ keepinvariant

#define keepinvariant ( g)    ((g)->gcstate <= GCSatomic)

Definition at line 54 of file lua-5.4.3/src/lgc.h.

◆ l_setbit

#define l_setbit ( x,
b )   setbits(x, bitmask(b))

Definition at line 65 of file lua-5.4.3/src/lgc.h.

◆ luaC_barrier

#define luaC_barrier ( L,
p,
v )
Value:
( \
(iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
#define gcvalue(o)
#define iscollectable(o)
#define obj2gco(v)
#define cast_void(i)
#define iswhite(x)
#define isblack(x)
LUAI_FUNC void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)

Definition at line 165 of file lua-5.4.3/src/lgc.h.

165#define luaC_barrier(L,p,v) ( \
166 (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
167 luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0))

◆ luaC_barrierback

#define luaC_barrierback ( L,
p,
v )
Value:
( \
(iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
LUAI_FUNC void luaC_barrierback_(lua_State *L, GCObject *o)

Definition at line 169 of file lua-5.4.3/src/lgc.h.

169#define luaC_barrierback(L,p,v) ( \
170 (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
171 luaC_barrierback_(L,p) : cast_void(0))

◆ luaC_checkGC

#define luaC_checkGC ( L)    luaC_condGC(L,(void)0,(void)0)

Definition at line 162 of file lua-5.4.3/src/lgc.h.

◆ luaC_condGC

#define luaC_condGC ( L,
pre,
pos )
Value:
{ if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \
condchangemem(L,pre,pos); }
#define G(L)
LUAI_FUNC void luaC_step(lua_State *L)

Definition at line 157 of file lua-5.4.3/src/lgc.h.

157#define luaC_condGC(L,pre,pos) \
158 { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \
159 condchangemem(L,pre,pos); }

◆ luaC_objbarrier

#define luaC_objbarrier ( L,
p,
o )
Value:
( \
(isblack(p) && iswhite(o)) ? \

Definition at line 173 of file lua-5.4.3/src/lgc.h.

173#define luaC_objbarrier(L,p,o) ( \
174 (isblack(p) && iswhite(o)) ? \
175 luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))

◆ luaC_white

#define luaC_white ( g)    cast_byte((g)->currentwhite & WHITEBITS)

Definition at line 102 of file lua-5.4.3/src/lgc.h.

◆ LUAI_GCMUL

#define LUAI_GCMUL   100

Definition at line 138 of file lua-5.4.3/src/lgc.h.

◆ LUAI_GCPAUSE

#define LUAI_GCPAUSE   200

Definition at line 129 of file lua-5.4.3/src/lgc.h.

◆ LUAI_GCSTEPSIZE

#define LUAI_GCSTEPSIZE   13 /* 8 KB */

Definition at line 141 of file lua-5.4.3/src/lgc.h.

Referenced by lua_newstate().

◆ LUAI_GENMAJORMUL

#define LUAI_GENMAJORMUL   100

Definition at line 125 of file lua-5.4.3/src/lgc.h.

Referenced by lua_newstate().

◆ LUAI_GENMINORMUL

#define LUAI_GENMINORMUL   20

Definition at line 126 of file lua-5.4.3/src/lgc.h.

Referenced by lua_newstate().

◆ nw2black

#define nw2black ( x)     check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT))

Definition at line 99 of file lua-5.4.3/src/lgc.h.

99#define nw2black(x) \
100 check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT))

Referenced by convergeephemerons(), correctgraylist(), luaF_closeupval(), propagatemark(), and sweep2old().

◆ otherwhite

#define otherwhite ( g)    ((g)->currentwhite ^ WHITEBITS)

Definition at line 94 of file lua-5.4.3/src/lgc.h.

◆ resetbit

#define resetbit ( x,
b )   resetbits(x, bitmask(b))

Definition at line 66 of file lua-5.4.3/src/lgc.h.

◆ resetbits

#define resetbits ( x,
m )   ((x) &= cast_byte(~(m)))

Definition at line 60 of file lua-5.4.3/src/lgc.h.

◆ setage

#define setage ( o,
a )   ((o)->marked = cast_byte(((o)->marked & (~AGEBITS)) | a))

Definition at line 117 of file lua-5.4.3/src/lgc.h.

Referenced by luaC_barrier_(), luaC_barrierback_(), luaC_fix(), sweep2old(), and sweepgen().

◆ setbits

#define setbits ( x,
m )   ((x) |= (m))

Definition at line 61 of file lua-5.4.3/src/lgc.h.

◆ setgcparam

#define setgcparam ( p,
v )   ((p) = (v) / 4)

Definition at line 136 of file lua-5.4.3/src/lgc.h.

Referenced by lua_gc(), and lua_newstate().

◆ testbit

#define testbit ( x,
b )   testbits(x, bitmask(b))

Definition at line 67 of file lua-5.4.3/src/lgc.h.

◆ TESTBIT

#define TESTBIT   7

Definition at line 80 of file lua-5.4.3/src/lgc.h.

◆ testbits

#define testbits ( x,
m )   ((x) & (m))

Definition at line 62 of file lua-5.4.3/src/lgc.h.

◆ tofinalize

#define tofinalize ( x)    testbit((x)->marked, FINALIZEDBIT)

Definition at line 92 of file lua-5.4.3/src/lgc.h.

◆ WHITE0BIT

#define WHITE0BIT   3 /* object is white (type 0) */

Definition at line 75 of file lua-5.4.3/src/lgc.h.

◆ WHITE1BIT

#define WHITE1BIT   4 /* object is white (type 1) */

Definition at line 76 of file lua-5.4.3/src/lgc.h.

◆ WHITEBITS

#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)

Definition at line 84 of file lua-5.4.3/src/lgc.h.

Function Documentation

◆ luaC_barrier_()

LUAI_FUNC void luaC_barrier_ ( lua_State * L,
GCObject * o,
GCObject * v )

Definition at line 135 of file lua-5.2.4/src/lgc.c.

135 {
136 global_State *g = G(L);
137 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
139 lua_assert(gch(o)->tt != LUA_TTABLE);
140 if (keepinvariantout(g)) /* must keep invariant? */
141 reallymarkobject(g, v); /* restore invariant */
142 else { /* sweep phase */
144 makewhite(g, o); /* mark main obj. as white to avoid other barriers */
145 }
146}
#define iswhite(x)
#define GCSpause
#define isblack(x)
#define isdead(g, v)
#define lua_assert(c)
#define LUA_TTABLE
static void reallymarkobject(global_State *g, GCObject *o)
#define makewhite(g, x)
#define issweepphase(g)
#define keepinvariantout(g)
#define gch(o)

References G, G_OLD0, gch, global_State::gckind, GCSpause, global_State::gcstate, isblack, isdead, isold, issweepphase, iswhite, keepinvariant, keepinvariantout, KGC_INC, lua_assert, LUA_TTABLE, makewhite, reallymarkobject(), reallymarkobject(), reallymarkobject(), and setage.

◆ luaC_barrierback_()

LUAI_FUNC void luaC_barrierback_ ( lua_State * L,
GCObject * o )

Definition at line 155 of file lua-5.2.4/src/lgc.c.

155 {
156 global_State *g = G(L);
157 lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE);
158 black2gray(o); /* make object gray (again) */
159 gco2t(o)->gclist = g->grayagain;
160 g->grayagain = o;
161}
#define black2gray(x)
#define gco2t(o)

References black2gray, G, G_TOUCHED1, G_TOUCHED2, gch, global_State::gckind, gco2t, getage, global_State::grayagain, isblack, isdead, isold, KGC_GEN, linkobjgclist, lua_assert, LUA_TTABLE, set2gray, and setage.

◆ luaC_changemode()

LUAI_FUNC void luaC_changemode ( lua_State * L,
int newmode )

Definition at line 952 of file lua-5.2.4/src/lgc.c.

952 {
953 global_State *g = G(L);
954 if (mode == g->gckind) return; /* nothing to change */
955 if (mode == KGC_GEN) { /* change to generational mode */
956 /* make sure gray lists are consistent */
959 g->gckind = KGC_GEN;
960 }
961 else { /* change to incremental mode */
962 /* sweep all objects to turn them back to white
963 (as white has not changed, nothing extra will be collected) */
964 g->gckind = KGC_NORMAL;
965 entersweep(L);
967 }
968}
#define GCSpropagate
#define bitmask(b)
static int entersweep(lua_State *L)
#define sweepphases
void luaC_runtilstate(lua_State *L, int statesmask)
#define gettotalbytes(g)
#define KGC_GEN
#define KGC_NORMAL

References bitmask, entergen(), enterinc(), entersweep(), G, global_State::GCestimate, global_State::gckind, GCSpropagate, gettotalbytes, KGC_GEN, KGC_NORMAL, global_State::lastatomic, luaC_runtilstate(), and sweepphases.

Referenced by lua_gc(), lua_gc(), and luaC_freeallobjects().

◆ luaC_checkfinalizer()

LUAI_FUNC void luaC_checkfinalizer ( lua_State * L,
GCObject * o,
Table * mt )

Definition at line 873 of file lua-5.2.4/src/lgc.c.

873 {
874 global_State *g = G(L);
875 if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */
876 isfinalized(o) || /* ... or is finalized... */
877 gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
878 return; /* nothing to be done */
879 else { /* move 'o' to 'finobj' list */
880 GCObject **p;
881 GCheader *ho = gch(o);
882 if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */
884 g->sweepgc = sweeptolive(L, g->sweepgc, NULL);
885 }
886 /* search for pointer pointing to 'o' */
887 for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ }
888 *p = ho->next; /* remove 'o' from root list */
889 ho->next = g->finobj; /* link it in list 'finobj' */
890 g->finobj = o;
891 l_setbit(ho->marked, SEPARATED); /* mark it as such */
892 if (!keepinvariantout(g)) /* not keeping invariant? */
893 makewhite(g, o); /* "sweep" object */
894 else
895 resetoldbit(o); /* see MOVE OLD rule */
896 }
897}
#define NULL
Definition gmacros.h:924
#define testbit(x, b)
#define l_setbit(x, b)
@ TM_GC
#define gfasttm(g, et, e)
#define isfinalized(x)
static GCObject ** sweeptolive(lua_State *L, GCObject **p, int *n)
#define resetoldbit(o)
#define SEPARATED

References global_State::allgc, correctpointers(), FINALIZEDBIT, global_State::finobj, G, gch, gfasttm, isfinalized, issweepphase, keepinvariantout, l_setbit, lua_assert, makewhite, NULL, resetoldbit, SEPARATED, global_State::sweepgc, sweeptolive(), sweeptolive(), sweeptolive(), testbit, TM_GC, and tofinalize.

Referenced by lua_setmetatable().

◆ luaC_fix()

LUAI_FUNC void luaC_fix ( lua_State * L,
GCObject * o )

Definition at line 194 of file lua-5.3.6/src/lgc.c.

194 {
195 global_State *g = G(L);
196 lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */
197 white2gray(o); /* they will be gray forever */
198 g->allgc = o->next; /* remove object from 'allgc' list */
199 o->next = g->fixedgc; /* link it to 'fixedgc' list */
200 g->fixedgc = o;
201}
#define white2gray(x)

References global_State::allgc, global_State::fixedgc, G, G_OLD, lua_assert, set2gray, setage, and white2gray.

Referenced by luaS_init(), luaT_init(), and luaX_init().

◆ luaC_freeallobjects()

LUAI_FUNC void luaC_freeallobjects ( lua_State * L)

Definition at line 983 of file lua-5.2.4/src/lgc.c.

983 {
984 global_State *g = G(L);
985 int i;
986 separatetobefnz(L, 1); /* separate all objects with finalizers */
987 lua_assert(g->finobj == NULL);
989 g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
990 g->gckind = KGC_NORMAL;
991 sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */
992 sweepwholelist(L, &g->allgc);
993 for (i = 0; i < g->strt.size; i++) /* free all string lists */
994 sweepwholelist(L, &g->strt.hash[i]);
995 lua_assert(g->strt.nuse == 0);
996}
#define WHITEBITS
#define sweepwholelist(L, p)
static void callallpendingfinalizers(lua_State *L, int propagateerrors)
static void separatetobefnz(lua_State *L, int all)

References global_State::allgc, callallpendingfinalizers(), callallpendingfinalizers(), callallpendingfinalizers(), global_State::currentwhite, deletelist(), global_State::finobj, global_State::fixedgc, G, global_State::gckind, stringtable::hash, KGC_INC, KGC_NORMAL, lua_assert, luaC_changemode(), global_State::mainthread, NULL, stringtable::nuse, obj2gco, separatetobefnz(), separatetobefnz(), separatetobefnz(), stringtable::size, global_State::strt, sweepwholelist, global_State::tobefnz, and WHITEBITS.

Referenced by close_state(), close_state(), and close_state().

◆ luaC_fullgc()

LUAI_FUNC void luaC_fullgc ( lua_State * L,
int isemergency )

Definition at line 1189 of file lua-5.2.4/src/lgc.c.

1189 {
1190 global_State *g = G(L);
1191 int origkind = g->gckind;
1192 lua_assert(origkind != KGC_EMERGENCY);
1193 if (isemergency) /* do not run finalizers during emergency GC */
1194 g->gckind = KGC_EMERGENCY;
1195 else {
1196 g->gckind = KGC_NORMAL;
1198 }
1199 if (keepinvariant(g)) { /* may there be some black objects? */
1200 /* must sweep all objects to turn them back to white
1201 (as white has not changed, nothing will be collected) */
1202 entersweep(L);
1203 }
1204 /* finish any pending sweep phase to start a new cycle */
1206 luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */
1207 luaC_runtilstate(L, bitmask(GCSpause)); /* run entire collection */
1208 if (origkind == KGC_GEN) { /* generational mode? */
1209 /* generational mode must be kept in propagate phase */
1211 }
1212 g->gckind = origkind;
1213 setpause(g, gettotalbytes(g));
1214 if (!isemergency) /* do not run finalizers during emergency GC */
1216}
static void setpause(global_State *g, l_mem estimate)
#define keepinvariant(g)
#define KGC_EMERGENCY

References bitmask, callallpendingfinalizers(), entersweep(), entersweep(), fullgen(), fullinc(), G, global_State::gcemergency, global_State::GCestimate, global_State::gckind, GCScallfin, GCSpause, GCSpropagate, gettotalbytes, keepinvariant, KGC_EMERGENCY, KGC_GEN, KGC_INC, KGC_NORMAL, lua_assert, luaC_runtilstate(), setpause(), and setpause().

Referenced by generationalcollection().

◆ luaC_newobj()

LUAI_FUNC GCObject * luaC_newobj ( lua_State * L,
int tt,
size_t sz )

Definition at line 208 of file lua-5.3.6/src/lgc.c.

208 {
209 global_State *g = G(L);
210 GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz));
211 o->marked = luaC_white(g);
212 o->tt = tt;
213 o->next = g->allgc;
214 g->allgc = o;
215 return o;
216}
#define luaC_white(g)
#define cast(t, exp)
#define luaM_newobject(L, tag, s)
#define novariant(x)

References global_State::allgc, cast, G, luaC_white, luaM_newobject, and novariant.

◆ luaC_runtilstate()

LUAI_FUNC void luaC_runtilstate ( lua_State * L,
int statesmask )

Definition at line 1110 of file lua-5.2.4/src/lgc.c.

1110 {
1111 global_State *g = G(L);
1112 while (!testbit(statesmask, g->gcstate))
1113 singlestep(L);
1114}
static lu_mem singlestep(lua_State *L)

References G, global_State::gcstate, singlestep(), singlestep(), singlestep(), and testbit.

Referenced by entergen(), fullinc(), generationalcollection(), luaC_changemode(), luaC_fullgc(), luaS_resize(), and stepgenfull().

◆ luaC_step()

LUAI_FUNC void luaC_step ( lua_State * L)

Definition at line 610 of file lua-5.1.5/src/lgc.c.

610 {
611 global_State *g = G(L);
612 l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
613 if (lim == 0)
614 lim = (MAX_LUMEM-1)/2; /* no limit */
615 g->gcdept += g->totalbytes - g->GCthreshold;
616 do {
617 lim -= singlestep(L);
618 if (g->gcstate == GCSpause)
619 break;
620 } while (lim > 0);
621 if (g->gcstate != GCSpause) {
622 if (g->gcdept < GCSTEPSIZE)
623 g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
624 else {
625 g->gcdept -= GCSTEPSIZE;
626 g->GCthreshold = g->totalbytes;
627 }
628 }
629 else {
630 setthreshold(g);
631 }
632}
static l_mem singlestep(lua_State *L)
#define setthreshold(g)
#define GCSTEPSIZE
#define MAX_LUMEM
LUAI_MEM l_mem

References G, global_State::gcdept, global_State::gcemergency, global_State::gcrunning, GCSpause, global_State::gcstate, global_State::gcstepmul, GCSTEPSIZE, global_State::GCthreshold, genstep(), getdebt(), incstep(), isdecGCmodegen, lua_assert, luaC_forcestep(), luaE_setdebt(), MAX_LUMEM, runafewfinalizers(), setpause(), setthreshold, singlestep(), singlestep(), STEPMULADJ, and global_State::totalbytes.

Referenced by lua_gc(), and lua_gc().