The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions
lgc.cpp File Reference
#include <string.h>
#include "lua.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
Include dependency graph for lgc.cpp:

Go to the source code of this file.

Macros

#define lgc_c
 
#define LUA_CORE
 
#define GCSWEEPCOST   ((sizeof(TString) + 4) / 4)
 
#define GCSWEEPMAX   (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4))
 
#define GCFINALIZENUM   4
 
#define STEPMULADJ   200
 
#define PAUSEADJ   100
 
#define maskcolors   (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS))
 
#define makewhite(g, x)   (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g)))
 
#define white2gray(x)   resetbits(gch(x)->marked, WHITEBITS)
 
#define black2gray(x)   resetbit(gch(x)->marked, BLACKBIT)
 
#define isfinalized(x)   testbit(gch(x)->marked, FINALIZEDBIT)
 
#define checkdeadkey(n)   lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))
 
#define checkconsistency(obj)   lua_longassert(!iscollectable(obj) || righttt(obj))
 
#define markvalue(g, o)
 
#define markobject(g, t)
 
#define gnodelast(h)   gnode(h, cast(size_t, sizenode(h)))
 
#define linktable(h, p)   ((h)->gclist = *(p), *(p) = obj2gco(h))
 
#define sweepwholelist(L, p)   sweeplist(L,p,MAX_LUMEM)
 
#define sweepphases   (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep))
 

Functions

static void reallymarkobject (global_State *g, GCObject *o)
 
static void removeentry (Node *n)
 
static int iscleared (global_State *g, const TValue *o)
 
void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v)
 
void luaC_barrierback_ (lua_State *L, GCObject *o)
 
LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c)
 
void luaC_checkupvalcolor (global_State *g, UpVal *uv)
 
GCObjectluaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, int offset)
 
static void markmt (global_State *g)
 
static void markbeingfnz (global_State *g)
 
static void remarkupvals (global_State *g)
 
static void restartcollection (global_State *g)
 
static void traverseweakvalue (global_State *g, Table *h)
 
static int traverseephemeron (global_State *g, Table *h)
 
static void traversestrongtable (global_State *g, Table *h)
 
static lu_mem traversetable (global_State *g, Table *h)
 
static int traverseproto (global_State *g, Proto *f)
 
static lu_mem traverseCclosure (global_State *g, CClosure *cl)
 
static lu_mem traverseLclosure (global_State *g, LClosure *cl)
 
static lu_mem traversestack (global_State *g, lua_State *th)
 
static void propagatemark (global_State *g)
 
static void propagateall (global_State *g)
 
static void propagatelist (global_State *g, GCObject *l)
 
static void retraversegrays (global_State *g)
 
static void convergeephemerons (global_State *g)
 
static void clearkeys (global_State *g, GCObject *l, GCObject *f)
 
static void clearvalues (global_State *g, GCObject *l, GCObject *f)
 
static void freeobj (lua_State *L, GCObject *o)
 
static GCObject ** sweeplist (lua_State *L, GCObject **p, lu_mem count)
 
static void sweepthread (lua_State *L, lua_State *L1)
 
static GCObject ** sweeptolive (lua_State *L, GCObject **p, int *n)
 
static void checkSizes (lua_State *L)
 
static GCObjectudata2finalize (global_State *g)
 
static void dothecall (lua_State *L, void *ud)
 
static void GCTM (lua_State *L, int propagateerrors)
 
static void separatetobefnz (lua_State *L, int all)
 
void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt)
 
static void setpause (global_State *g, l_mem estimate)
 
static int entersweep (lua_State *L)
 
void luaC_changemode (lua_State *L, int mode)
 
static void callallpendingfinalizers (lua_State *L, int propagateerrors)
 
void luaC_freeallobjects (lua_State *L)
 
static l_mem atomic (lua_State *L)
 
static lu_mem singlestep (lua_State *L)
 
void luaC_runtilstate (lua_State *L, int statesmask)
 
static void generationalcollection (lua_State *L)
 
static void incstep (lua_State *L)
 
void luaC_forcestep (lua_State *L)
 
void luaC_step (lua_State *L)
 
void luaC_fullgc (lua_State *L, int isemergency)
 

Macro Definition Documentation

#define black2gray (   x)    resetbit(gch(x)->marked, BLACKBIT)

Definition at line 62 of file lgc.cpp.

Referenced by luaC_barrierback_(), luaC_barrierproto_(), propagatemark(), and traversetable().

#define checkconsistency (   obj)    lua_longassert(!iscollectable(obj) || righttt(obj))

Definition at line 70 of file lgc.cpp.

#define checkdeadkey (   n)    lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))

Definition at line 67 of file lgc.cpp.

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

#define GCFINALIZENUM   4

Definition at line 36 of file lgc.cpp.

Referenced by luaC_forcestep().

#define GCSWEEPCOST   ((sizeof(TString) + 4) / 4)

Definition at line 30 of file lgc.cpp.

Referenced by singlestep().

#define GCSWEEPMAX   (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4))

Definition at line 33 of file lgc.cpp.

Referenced by singlestep().

#define gnodelast (   h)    gnode(h, cast(size_t, sizenode(h)))
#define isfinalized (   x)    testbit(gch(x)->marked, FINALIZEDBIT)

Definition at line 65 of file lgc.cpp.

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

#define lgc_c

Definition at line 8 of file lgc.cpp.

#define linktable (   h,
  p 
)    ((h)->gclist = *(p), *(p) = obj2gco(h))

Definition at line 99 of file lgc.cpp.

Referenced by reallymarkobject(), traverseephemeron(), traversetable(), and traverseweakvalue().

#define LUA_CORE

Definition at line 9 of file lgc.cpp.

#define makewhite (   g,
  x 
)    (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g)))
#define markobject (   g,
  t 
)
Value:
{ if ((t) && iswhite(obj2gco(t))) \
#define obj2gco(v)
Definition: lstate.h:214
#define iswhite(x)
Definition: lgc.h:98
GLboolean GLboolean g
Definition: glew.h:7319
GLdouble GLdouble t
Definition: glew.h:1366
static void reallymarkobject(global_State *g, GCObject *o)
Definition: lgc.cpp:242

Definition at line 77 of file lgc.cpp.

Referenced by atomic(), iscleared(), markmt(), reallymarkobject(), restartcollection(), traverseLclosure(), traverseproto(), and traversetable().

#define markvalue (   g,
 
)
Value:
#define gcvalue(o)
Definition: lobject.h:153
#define valiswhite(x)
Definition: lgc.h:116
#define checkconsistency(obj)
Definition: lgc.cpp:70
GLboolean GLboolean g
Definition: glew.h:7319
static void reallymarkobject(global_State *g, GCObject *o)
Definition: lgc.cpp:242
CALLABLE_WRAPPER_INPUT_END if(key=="terrain")

Definition at line 74 of file lgc.cpp.

Referenced by atomic(), luaC_checkupvalcolor(), reallymarkobject(), remarkupvals(), restartcollection(), traverseCclosure(), traverseproto(), traversestack(), traversestrongtable(), and traverseweakvalue().

#define maskcolors   (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS))

Definition at line 57 of file lgc.cpp.

Referenced by sweeplist().

#define PAUSEADJ   100

Definition at line 50 of file lgc.cpp.

Referenced by setpause().

#define STEPMULADJ   200

Definition at line 43 of file lgc.cpp.

Referenced by incstep().

#define sweepphases   (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep))

Definition at line 923 of file lgc.cpp.

Referenced by luaC_changemode().

#define sweepwholelist (   L,
  p 
)    sweeplist(L,p,MAX_LUMEM)

Definition at line 689 of file lgc.cpp.

Referenced by luaC_freeallobjects(), singlestep(), and sweepthread().

#define white2gray (   x)    resetbits(gch(x)->marked, WHITEBITS)

Definition at line 61 of file lgc.cpp.

Referenced by reallymarkobject().

Function Documentation

static l_mem atomic ( lua_State L)
static
static void callallpendingfinalizers ( lua_State L,
int  propagateerrors 
)
static

Definition at line 973 of file lgc.cpp.

References G, GCTM(), resetoldbit, and global_State::tobefnz.

Referenced by luaC_freeallobjects(), and luaC_fullgc().

static void checkSizes ( lua_State L)
static
static void clearkeys ( global_State g,
GCObject l,
GCObject f 
)
static

Definition at line 624 of file lgc.cpp.

References gco2t, gkey, gnode, gnodelast, gval, iscleared(), removeentry(), setnilvalue, and ttisnil.

Referenced by atomic().

static void clearvalues ( global_State g,
GCObject l,
GCObject f 
)
static

Definition at line 642 of file lgc.cpp.

References Table::array, gco2t, gnode, gnodelast, gval, i, iscleared(), removeentry(), setnilvalue, Table::sizearray, and ttisnil.

Referenced by atomic().

static void convergeephemerons ( global_State g)
static

Definition at line 593 of file lgc.cpp.

References global_State::ephemeron, gco2t, next, propagateall(), and traverseephemeron().

Referenced by atomic().

static void dothecall ( lua_State L,
void ud 
)
static

Definition at line 802 of file lgc.cpp.

References luaD_call(), lua_State::top, and UNUSED.

Referenced by GCTM().

static int entersweep ( lua_State L)
static
static void freeobj ( lua_State L,
GCObject o 
)
static
static void GCTM ( lua_State L,
int  propagateerrors 
)
static
static void generationalcollection ( lua_State L)
static
static void incstep ( lua_State L)
static
static int iscleared ( global_State g,
const TValue o 
)
static
void luaC_barrier_ ( lua_State L,
GCObject o,
GCObject v 
)
void luaC_barrierback_ ( lua_State L,
GCObject o 
)

Definition at line 154 of file lgc.cpp.

References black2gray, G, gch, gco2t, global_State::grayagain, isblack, isdead, lua_assert, and LUA_TTABLE.

LUAI_FUNC void luaC_barrierproto_ ( lua_State L,
Proto p,
Closure c 
)
void luaC_changemode ( lua_State L,
int  mode 
)
void luaC_checkfinalizer ( lua_State L,
GCObject o,
Table mt 
)
void luaC_checkupvalcolor ( global_State g,
UpVal uv 
)

Definition at line 189 of file lgc.cpp.

References gray2black, isblack, isgray, issweepphase, keepinvariant, lua_assert, makewhite, markvalue, obj2gco, resetoldbit, and UpVal::v.

Referenced by luaF_close().

void luaC_forcestep ( lua_State L)
void luaC_freeallobjects ( lua_State L)
void luaC_fullgc ( lua_State L,
int  isemergency 
)
GCObject* luaC_newobj ( lua_State L,
int  tt,
size_t  sz,
GCObject **  list,
int  offset 
)
void luaC_runtilstate ( lua_State L,
int  statesmask 
)

Definition at line 1109 of file lgc.cpp.

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

Referenced by generationalcollection(), luaC_changemode(), luaC_fullgc(), and luaS_resize().

void luaC_step ( lua_State L)

Definition at line 1176 of file lgc.cpp.

References G, global_State::gcrunning, GCSTEPSIZE, luaC_forcestep(), and luaE_setdebt().

static void markbeingfnz ( global_State g)
static

Definition at line 310 of file lgc.cpp.

References gch, makewhite, next, reallymarkobject(), and global_State::tobefnz.

Referenced by atomic(), and restartcollection().

static void markmt ( global_State g)
static

Definition at line 300 of file lgc.cpp.

References i, LUA_NUMTAGS, markobject, and global_State::mt.

Referenced by atomic(), and restartcollection().

static void propagateall ( global_State g)
static

Definition at line 565 of file lgc.cpp.

References global_State::gray, and propagatemark().

Referenced by atomic(), convergeephemerons(), propagatelist(), and retraversegrays().

static void propagatelist ( global_State g,
GCObject l 
)
static

Definition at line 570 of file lgc.cpp.

References global_State::gray, lua_assert, and propagateall().

Referenced by retraversegrays().

static void propagatemark ( global_State g)
static
static void reallymarkobject ( global_State g,
GCObject o 
)
static
static void remarkupvals ( global_State g)
static

Definition at line 323 of file lgc.cpp.

References isgray, UpVal::l, markvalue, obj2gco, UpVal::u, global_State::uvhead, and UpVal::v.

Referenced by atomic().

static void removeentry ( Node n)
static
static void restartcollection ( global_State g)
static
static void retraversegrays ( global_State g)
static
static void separatetobefnz ( lua_State L,
int  all 
)
static
static void setpause ( global_State g,
l_mem  estimate 
)
static
static lu_mem singlestep ( lua_State L)
static
static GCObject ** sweeplist ( lua_State L,
GCObject **  p,
lu_mem  count 
)
static
static void sweepthread ( lua_State L,
lua_State L1 
)
static
static GCObject** sweeptolive ( lua_State L,
GCObject **  p,
int n 
)
static

Definition at line 757 of file lgc.cpp.

References i, and sweeplist().

Referenced by entersweep(), and luaC_checkfinalizer().

static lu_mem traverseCclosure ( global_State g,
CClosure cl 
)
static

Definition at line 478 of file lgc.cpp.

References i, markvalue, sizeCclosure, and CClosure::upvalue.

Referenced by propagatemark().

static int traverseephemeron ( global_State g,
Table h 
)
static
static lu_mem traverseLclosure ( global_State g,
LClosure cl 
)
static

Definition at line 485 of file lgc.cpp.

References i, markobject, LClosure::p, sizeLclosure, and LClosure::upvals.

Referenced by propagatemark().

static int traverseproto ( global_State g,
Proto f 
)
static
static lu_mem traversestack ( global_State g,
lua_State th 
)
static
static void traversestrongtable ( global_State g,
Table h 
)
static

Definition at line 415 of file lgc.cpp.

References Table::array, checkdeadkey, gkey, gnode, gnodelast, gval, i, lua_assert, markvalue, removeentry(), Table::sizearray, and ttisnil.

Referenced by traversetable().

static lu_mem traversetable ( global_State g,
Table h 
)
static
static void traverseweakvalue ( global_State g,
Table h 
)
static
static GCObject* udata2finalize ( global_State g)
static