The Battle for Wesnoth  1.15.11+dev
Macros | Functions
lgc.h File Reference
#include "lobject.h"
#include "lstate.h"
Include dependency graph for lgc.h:
This graph shows which files directly or indirectly include this file:

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 lgc.h.

◆ bit2mask

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

Definition at line 64 of file lgc.h.

◆ bitmask

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

Definition at line 63 of file lgc.h.

Referenced by entergen(), fullinc(), lua_newstate(), and stepgenfull().

◆ BLACKBIT

#define BLACKBIT   5 /* object is black */

Definition at line 77 of file lgc.h.

◆ changeage

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

Definition at line 120 of file lgc.h.

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

◆ changewhite

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

Definition at line 98 of file lgc.h.

Referenced by internshrstr().

◆ FINALIZEDBIT

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

Definition at line 78 of file lgc.h.

Referenced by luaC_checkfinalizer(), and udata2finalize().

◆ G_NEW

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

Definition at line 106 of file lgc.h.

Referenced by sweepgen().

◆ G_OLD

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

Definition at line 110 of file 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 lgc.h.

Referenced by luaC_barrier_().

◆ G_OLD1

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

Definition at line 109 of file lgc.h.

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

◆ G_SURVIVAL

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

Definition at line 107 of file lgc.h.

Referenced by sweepgen().

◆ G_TOUCHED1

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

Definition at line 111 of file 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 lgc.h.

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

◆ GCSatomic

#define GCSatomic   2

Definition at line 33 of file lgc.h.

Referenced by atomic(), traversethread(), and traverseweakvalue().

◆ GCScallfin

#define GCScallfin   7

Definition at line 38 of file lgc.h.

Referenced by fullinc(), and singlestep().

◆ GCSenteratomic

#define GCSenteratomic   1

Definition at line 32 of file lgc.h.

Referenced by singlestep().

◆ GCSpause

#define GCSpause   8

Definition at line 39 of file lgc.h.

Referenced by entergen(), enterinc(), fullinc(), incstep(), lua_gc(), lua_newstate(), singlestep(), and stepgenfull().

◆ GCSpropagate

#define GCSpropagate   0

◆ GCSswpallgc

#define GCSswpallgc   3

Definition at line 34 of file lgc.h.

Referenced by atomic2gen(), entersweep(), singlestep(), and youngcollection().

◆ GCSswpend

#define GCSswpend   6

Definition at line 37 of file lgc.h.

Referenced by singlestep().

◆ GCSswpfinobj

#define GCSswpfinobj   4

Definition at line 35 of file lgc.h.

Referenced by singlestep().

◆ GCSswptobefnz

#define GCSswptobefnz   5

Definition at line 36 of file lgc.h.

Referenced by singlestep().

◆ getage

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

◆ getgcparam

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

Definition at line 135 of file lgc.h.

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

◆ isblack

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

Definition at line 88 of file lgc.h.

Referenced by genlink(), luaC_barrier_(), luaC_barrierback_(), and markold().

◆ isdead

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

◆ isdeadm

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

Definition at line 95 of file lgc.h.

Referenced by sweeplist().

◆ isdecGCmodegen

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

Definition at line 149 of file 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
Definition: lgc.h:84
#define bitmask(b)
Definition: lgc.h:63
#define BLACKBIT
Definition: lgc.h:77
#define testbits(x, m)
Definition: lgc.h:62

Definition at line 89 of file lgc.h.

Referenced by correctgraylist(), linkgclist_(), and remarkupvals().

◆ isold

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

◆ issweepphase

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

Definition at line 42 of file lgc.h.

Referenced by luaC_barrier_(), luaC_checkfinalizer(), and udata2finalize().

◆ iswhite

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

◆ keepinvariant

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

Definition at line 54 of file lgc.h.

Referenced by fullinc(), and luaC_barrier_().

◆ l_setbit

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

Definition at line 65 of file lgc.h.

Referenced by luaC_checkfinalizer().

◆ luaC_barrier

#define luaC_barrier (   L,
  p,
 
)
Value:
( \
(iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
#define gcvalue(o)
Definition: lobject.h:283
#define obj2gco(v)
Definition: lstate.h:347
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:125
mock_party p
#define isblack(x)
Definition: lgc.h:88
#define iscollectable(o)
Definition: lobject.h:278
LUAI_FUNC void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
Definition: lgc.cpp:208

Definition at line 165 of file lgc.h.

Referenced by addk(), lua_copy(), lua_load(), lua_setupvalue(), luaF_close(), and luaV_execute().

◆ luaC_barrierback

#define luaC_barrierback (   L,
  p,
 
)
Value:
( \
(iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
#define gcvalue(o)
Definition: lobject.h:283
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:125
mock_party p
LUAI_FUNC void luaC_barrierback_(lua_State *L, GCObject *o)
Definition: lgc.cpp:230
#define isblack(x)
Definition: lgc.h:88
#define iscollectable(o)
Definition: lobject.h:278

Definition at line 169 of file lgc.h.

Referenced by aux_rawset(), lua_rawseti(), lua_setiuservalue(), luaH_newkey(), luaV_execute(), and luaV_finishset().

◆ luaC_checkGC

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

◆ 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)
Definition: lstate.h:298
LUAI_FUNC void luaC_step(lua_State *L)
Definition: lgc.cpp:1666

Definition at line 157 of file lgc.h.

◆ luaC_objbarrier

#define luaC_objbarrier (   L,
  p,
 
)
Value:
( \
(isblack(p) && iswhite(o)) ? \
#define obj2gco(v)
Definition: lstate.h:347
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:125
mock_party p
#define isblack(x)
Definition: lgc.h:88
LUAI_FUNC void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
Definition: lgc.cpp:208

Definition at line 173 of file lgc.h.

Referenced by addprototype(), loadProtos(), loadStringN(), lua_setmetatable(), lua_upvaluejoin(), luaF_initupvals(), luaU_undump(), luaY_parser(), mainfunc(), newupvalue(), open_func(), pushclosure(), and registerlocalvar().

◆ luaC_white

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

Definition at line 102 of file lgc.h.

Referenced by lua_newstate(), lua_newthread(), luaC_newobj(), sweepgen(), sweeplist(), and whitelist().

◆ LUAI_GCMUL

#define LUAI_GCMUL   100

Definition at line 138 of file lgc.h.

Referenced by lua_newstate().

◆ LUAI_GCPAUSE

#define LUAI_GCPAUSE   200

Definition at line 129 of file lgc.h.

Referenced by lua_newstate().

◆ LUAI_GCSTEPSIZE

#define LUAI_GCSTEPSIZE   13 /* 8 KB */

Definition at line 141 of file lgc.h.

Referenced by lua_newstate().

◆ LUAI_GENMAJORMUL

#define LUAI_GENMAJORMUL   100

Definition at line 125 of file lgc.h.

Referenced by lua_newstate().

◆ LUAI_GENMINORMUL

#define LUAI_GENMINORMUL   20

Definition at line 126 of file 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 lgc.h.

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

◆ otherwhite

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

Definition at line 94 of file lgc.h.

Referenced by atomic(), and sweeplist().

◆ resetbit

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

Definition at line 66 of file lgc.h.

Referenced by udata2finalize().

◆ resetbits

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

Definition at line 60 of file lgc.h.

◆ setage

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

Definition at line 117 of file lgc.h.

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

◆ setbits

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

Definition at line 61 of file lgc.h.

◆ setgcparam

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

Definition at line 136 of file lgc.h.

Referenced by lua_gc(), and lua_newstate().

◆ testbit

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

Definition at line 67 of file lgc.h.

Referenced by luaC_runtilstate().

◆ TESTBIT

#define TESTBIT   7

Definition at line 80 of file lgc.h.

◆ testbits

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

Definition at line 62 of file lgc.h.

◆ tofinalize

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

Definition at line 92 of file lgc.h.

Referenced by luaC_checkfinalizer(), separatetobefnz(), and udata2finalize().

◆ WHITE0BIT

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

Definition at line 75 of file lgc.h.

Referenced by lua_newstate().

◆ WHITE1BIT

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

Definition at line 76 of file lgc.h.

◆ WHITEBITS

#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)

Definition at line 84 of file lgc.h.

Function Documentation

◆ luaC_barrier_()

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

◆ luaC_barrierback_()

LUAI_FUNC void luaC_barrierback_ ( lua_State L,
GCObject o 
)

◆ luaC_changemode()

LUAI_FUNC void luaC_changemode ( lua_State L,
int  newmode 
)

Definition at line 1323 of file lgc.cpp.

References entergen(), enterinc(), G, global_State::gckind, KGC_GEN, and global_State::lastatomic.

Referenced by lua_gc(), and luaC_freeallobjects().

◆ luaC_checkfinalizer()

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

◆ luaC_fix()

LUAI_FUNC void luaC_fix ( lua_State L,
GCObject o 
)

Definition at line 243 of file lgc.cpp.

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

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

◆ luaC_freeallobjects()

LUAI_FUNC void luaC_freeallobjects ( lua_State L)

◆ luaC_fullgc()

LUAI_FUNC void luaC_fullgc ( lua_State L,
int  isemergency 
)

Definition at line 1703 of file lgc.cpp.

References fullgen(), fullinc(), G, global_State::gcemergency, global_State::gckind, KGC_INC, and lua_assert.

Referenced by growstrtab(), lua_gc(), and tryagain().

◆ luaC_newobj()

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

◆ luaC_runtilstate()

LUAI_FUNC void luaC_runtilstate ( lua_State L,
int  statesmask 
)

Definition at line 1631 of file lgc.cpp.

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

Referenced by entergen(), fullinc(), and stepgenfull().

◆ luaC_step()

LUAI_FUNC void luaC_step ( lua_State L)

Definition at line 1666 of file lgc.cpp.

References G, global_State::gcemergency, global_State::gcrunning, genstep(), incstep(), isdecGCmodegen, and lua_assert.

Referenced by lua_gc().