The Battle for Wesnoth  1.15.2+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 GCSTEPSIZE   (cast_int(100 * sizeof(TString)))
 
#define GCSpropagate   0
 
#define GCSatomic   1
 
#define GCSswpallgc   2
 
#define GCSswpfinobj   3
 
#define GCSswptobefnz   4
 
#define GCSswpend   5
 
#define GCScallfin   6
 
#define GCSpause   7
 
#define issweepphase(g)   (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
 
#define keepinvariant(g)   ((g)->gcstate <= GCSatomic)
 
#define resetbits(x, m)   ((x) &= cast(lu_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   0 /* object is white (type 0) */
 
#define WHITE1BIT   1 /* object is white (type 1) */
 
#define BLACKBIT   2 /* object is black */
 
#define FINALIZEDBIT   3 /* object has been marked for finalization */
 
#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) ^ WHITEBITS) & (ow)))
 
#define isdead(g, v)   isdeadm(otherwhite(g), (v)->marked)
 
#define changewhite(x)   ((x)->marked ^= WHITEBITS)
 
#define gray2black(x)   l_setbit((x)->marked, BLACKBIT)
 
#define luaC_white(g)   cast(lu_byte, (g)->currentwhite & WHITEBITS)
 
#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)
 
#define luaC_upvalbarrier(L, uv)
 

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, Table *o)
 
LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv)
 
LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt)
 
LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv)
 

Macro Definition Documentation

◆ bit2mask

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

Definition at line 71 of file lgc.h.

◆ bitmask

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

Definition at line 70 of file lgc.h.

Referenced by lua_newstate(), and luaC_fullgc().

◆ BLACKBIT

#define BLACKBIT   2 /* object is black */

Definition at line 80 of file lgc.h.

◆ changewhite

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

Definition at line 98 of file lgc.h.

Referenced by internshrstr().

◆ FINALIZEDBIT

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

Definition at line 81 of file lgc.h.

Referenced by luaC_checkfinalizer(), and udata2finalize().

◆ GCSatomic

#define GCSatomic   1

Definition at line 40 of file lgc.h.

Referenced by singlestep().

◆ GCScallfin

#define GCScallfin   6

Definition at line 45 of file lgc.h.

Referenced by luaC_fullgc(), and singlestep().

◆ GCSpause

#define GCSpause   7

Definition at line 46 of file lgc.h.

Referenced by lua_gc(), lua_newstate(), luaC_fullgc(), luaC_step(), and singlestep().

◆ GCSpropagate

#define GCSpropagate   0

Definition at line 39 of file lgc.h.

Referenced by singlestep(), traverseephemeron(), and traverseweakvalue().

◆ GCSswpallgc

#define GCSswpallgc   2

Definition at line 41 of file lgc.h.

Referenced by entersweep(), and singlestep().

◆ GCSswpend

#define GCSswpend   5

Definition at line 44 of file lgc.h.

Referenced by singlestep().

◆ GCSswpfinobj

#define GCSswpfinobj   3

Definition at line 42 of file lgc.h.

Referenced by singlestep().

◆ GCSswptobefnz

#define GCSswptobefnz   4

Definition at line 43 of file lgc.h.

Referenced by singlestep().

◆ GCSTEPSIZE

#define GCSTEPSIZE   (cast_int(100 * sizeof(TString)))

Definition at line 32 of file lgc.h.

Referenced by lua_gc(), and luaC_step().

◆ gray2black

#define gray2black (   x)    l_setbit((x)->marked, BLACKBIT)

Definition at line 99 of file lgc.h.

Referenced by propagatemark(), and reallymarkobject().

◆ isblack

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

Definition at line 88 of file lgc.h.

Referenced by luaC_barrier_(), luaC_barrierback_(), pushclosure(), and remarkupvals().

◆ isdead

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

Definition at line 96 of file lgc.h.

Referenced by internshrstr(), luaC_barrier_(), and luaC_barrierback_().

◆ isdeadm

#define isdeadm (   ow,
 
)    (!(((m) ^ WHITEBITS) & (ow)))

Definition at line 95 of file lgc.h.

Referenced by sweeplist().

◆ 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:70
#define BLACKBIT
Definition: lgc.h:80
#define testbits(x, m)
Definition: lgc.h:69

Definition at line 89 of file lgc.h.

Referenced by propagatemark(), and remarkupvals().

◆ issweepphase

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

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

Referenced by luaC_barrier_(), luaC_fullgc(), and luaC_upvalbarrier_().

◆ l_setbit

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

Definition at line 72 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:167
#define obj2gco(v)
Definition: lstate.h:238
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:113
mock_party p
#define isblack(x)
Definition: lgc.h:88
#define iscollectable(o)
Definition: lobject.h:184
LUAI_FUNC void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
Definition: lgc.cpp:155

Definition at line 118 of file lgc.h.

Referenced by addk(), lua_copy(), lua_setupvalue(), and lua_setuservalue().

◆ luaC_barrierback

#define luaC_barrierback (   L,
  p,
 
)
Value:
( \
(iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
#define gcvalue(o)
Definition: lobject.h:167
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:113
LUAI_FUNC void luaC_barrierback_(lua_State *L, Table *o)
Definition: lgc.cpp:171
mock_party p
#define isblack(x)
Definition: lgc.h:88
#define iscollectable(o)
Definition: lobject.h:184

Definition at line 122 of file lgc.h.

Referenced by lua_rawset(), lua_rawseti(), lua_rawsetp(), 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:205
LUAI_FUNC void luaC_step(lua_State *L)
Definition: lgc.cpp:1129

Definition at line 110 of file lgc.h.

◆ luaC_objbarrier

#define luaC_objbarrier (   L,
  p,
 
)
Value:
( \
(isblack(p) && iswhite(o)) ? \
#define obj2gco(v)
Definition: lstate.h:238
#define iswhite(x)
Definition: lgc.h:87
#define cast_void(i)
Definition: llimits.h:113
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:155

Definition at line 126 of file lgc.h.

Referenced by addprototype(), lua_setmetatable(), newupvalue(), and registerlocalvar().

◆ luaC_upvalbarrier

#define luaC_upvalbarrier (   L,
  uv 
)
Value:
( \
(iscollectable((uv)->v) && !upisopen(uv)) ? \
#define upisopen(up)
Definition: lfunc.h:47
#define cast_void(i)
Definition: llimits.h:113
LUAI_FUNC void luaC_upvalbarrier_(lua_State *L, UpVal *uv)
Definition: lgc.cpp:185
#define iscollectable(o)
Definition: lobject.h:184

Definition at line 130 of file lgc.h.

Referenced by lua_load(), lua_setupvalue(), lua_upvaluejoin(), luaF_close(), and luaV_execute().

◆ luaC_white

#define luaC_white (   g)    cast(lu_byte, (g)->currentwhite & WHITEBITS)

Definition at line 101 of file lgc.h.

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

◆ 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 73 of file lgc.h.

Referenced by udata2finalize().

◆ resetbits

#define resetbits (   x,
 
)    ((x) &= cast(lu_byte, ~(m)))

Definition at line 67 of file lgc.h.

◆ setbits

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

Definition at line 68 of file lgc.h.

◆ testbit

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

Definition at line 74 of file lgc.h.

Referenced by luaC_runtilstate().

◆ testbits

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

Definition at line 69 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   0 /* object is white (type 0) */

Definition at line 78 of file lgc.h.

Referenced by lua_newstate().

◆ WHITE1BIT

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

Definition at line 79 of file lgc.h.

◆ WHITEBITS

#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)

Definition at line 84 of file lgc.h.

Referenced by luaC_freeallobjects().

Function Documentation

◆ luaC_barrier_()

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

Definition at line 155 of file lgc.cpp.

References g, G, isblack, isdead, issweepphase, iswhite, keepinvariant, lua_assert, makewhite, and reallymarkobject().

◆ luaC_barrierback_()

LUAI_FUNC void luaC_barrierback_ ( lua_State L,
Table o 
)

Definition at line 171 of file lgc.cpp.

References black2gray, g, G, global_State::grayagain, isblack, isdead, linkgclist, and lua_assert.

◆ 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 194 of file lgc.cpp.

References global_State::allgc, global_State::fixedgc, g, G, lua_assert, and white2gray.

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 
)

◆ 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 1104 of file lgc.cpp.

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

Referenced by luaC_fullgc().

◆ luaC_step()

LUAI_FUNC void luaC_step ( lua_State L)

◆ luaC_upvalbarrier_()

LUAI_FUNC void luaC_upvalbarrier_ ( lua_State L,
UpVal uv 
)

Definition at line 185 of file lgc.cpp.

References g, G, gcvalue, keepinvariant, lua_assert, markobject, upisopen, and UpVal::v.

◆ luaC_upvdeccount()

LUAI_FUNC void luaC_upvdeccount ( lua_State L,
UpVal uv 
)

Definition at line 678 of file lgc.cpp.

References lua_assert, luaM_free, UpVal::refcount, and upisopen.

Referenced by freeLclosure(), and lua_upvaluejoin().