lua/lgc.c 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"

Go to the source code of this file.

Data Structures

struct  GCState

Defines

#define lgc_c
#define setbit(x, b)   ((x) |= (1<<(b)))
#define resetbit(x, b)   ((x) &= cast(lu_byte, ~(1<<(b))))
#define testbit(x, b)   ((x) & (1<<(b)))
#define unmark(x)   resetbit((x)->gch.marked, 0)
#define ismarked(x)   ((x)->gch.marked & ((1<<4)|1))
#define stringmark(s)   setbit((s)->tsv.marked, 0)
#define isfinalized(u)   (!testbit((u)->uv.marked, 1))
#define markfinalized(u)   resetbit((u)->uv.marked, 1)
#define KEYWEAKBIT   1
#define VALUEWEAKBIT   2
#define KEYWEAK   (1<<KEYWEAKBIT)
#define VALUEWEAK   (1<<VALUEWEAKBIT)
#define markobject(st, o)
#define condmarkobject(st, o, c)
#define markvalue(st, t)

Functions

static void reallymarkobject (GCState *st, GCObject *o)
static void marktmu (GCState *st)
size_t luaC_separateudata (lua_State *L)
static void removekey (Node *n)
static void traversetable (GCState *st, Table *h)
static void traverseproto (GCState *st, Proto *f)
static void traverseclosure (GCState *st, Closure *cl)
static void checkstacksizes (lua_State *L, StkId max)
static void traversestack (GCState *st, lua_State *L1)
static void propagatemarks (GCState *st)
static int valismarked (const TObject *o)
static void cleartablekeys (GCObject *l)
static void cleartablevalues (GCObject *l)
static void freeobj (lua_State *L, GCObject *o)
static int sweeplist (lua_State *L, GCObject **p, int limit)
static void sweepstrings (lua_State *L, int all)
static void checkSizes (lua_State *L, size_t deadmem)
static void do1gcTM (lua_State *L, Udata *udata)
void luaC_callGCTM (lua_State *L)
void luaC_sweep (lua_State *L, int all)
static void markroot (GCState *st, lua_State *L)
static size_t mark (lua_State *L)
void luaC_collectgarbage (lua_State *L)
void luaC_link (lua_State *L, GCObject *o, lu_byte tt)


Define Documentation

#define condmarkobject ( st,
o,
 ) 

Value:

{ checkconsistency(o); \
  if (iscollectable(o) && !ismarked(gcvalue(o)) && (c)) \
    reallymarkobject(st,gcvalue(o)); }

Definition at line 66 of file lgc.c.

Referenced by traversetable().

#define isfinalized (  )     (!testbit((u)->uv.marked, 1))

Definition at line 52 of file lgc.c.

Referenced by luaC_separateudata().

#define ismarked (  )     ((x)->gch.marked & ((1<<4)|1))

Definition at line 47 of file lgc.c.

Referenced by luaC_separateudata(), and reallymarkobject().

#define KEYWEAK   (1<<KEYWEAKBIT)

Definition at line 58 of file lgc.c.

Referenced by cleartablekeys(), and traversetable().

#define KEYWEAKBIT   1

Definition at line 56 of file lgc.c.

Referenced by traversetable().

#define lgc_c

Definition at line 9 of file lgc.c.

#define markfinalized (  )     resetbit((u)->uv.marked, 1)

Definition at line 53 of file lgc.c.

Referenced by luaC_callGCTM(), and luaC_separateudata().

#define markobject ( st,
 ) 

Value:

Definition at line 63 of file lgc.c.

Referenced by markroot(), traverseclosure(), traversestack(), and traversetable().

#define markvalue ( st,
 ) 

Value:

{ if (!ismarked(valtogco(t))) \
                reallymarkobject(st, valtogco(t)); }

Definition at line 70 of file lgc.c.

Referenced by markroot(), reallymarkobject(), traverseclosure(), traverseproto(), and traversetable().

#define resetbit ( x,
 )     ((x) &= cast(lu_byte, ~(1<<(b))))

Definition at line 43 of file lgc.c.

#define setbit ( x,
 )     ((x) |= (1<<(b)))

Definition at line 42 of file lgc.c.

Referenced by reallymarkobject().

#define stringmark (  )     setbit((s)->tsv.marked, 0)

Definition at line 49 of file lgc.c.

Referenced by traverseproto(), and valismarked().

#define testbit ( x,
 )     ((x) & (1<<(b)))

Definition at line 44 of file lgc.c.

Referenced by valismarked().

#define unmark (  )     resetbit((x)->gch.marked, 0)

Definition at line 46 of file lgc.c.

Referenced by luaC_callGCTM(), marktmu(), and sweeplist().

#define VALUEWEAK   (1<<VALUEWEAKBIT)

Definition at line 59 of file lgc.c.

Referenced by cleartablevalues(), and traversetable().

#define VALUEWEAKBIT   2

Definition at line 57 of file lgc.c.

Referenced by traversetable().


Function Documentation

static void checkSizes ( lua_State L,
size_t  deadmem 
) [static]

Definition at line 436 of file lgc.c.

References cast, G, LUA_MINBUFFER, luaS_resize(), luaZ_resizebuffer, luaZ_sizebuffer, and MINSTRTABSIZE.

Referenced by luaC_collectgarbage().

static void checkstacksizes ( lua_State L,
StkId  max 
) [static]

Definition at line 251 of file lgc.c.

References lua_State::base_ci, BASIC_STACK_SIZE, lua_State::ci, condhardstacktests, EXTRA_STACK, luaD_reallocCI(), luaD_reallocstack(), and lua_State::size_ci.

Referenced by traversestack().

static void cleartablekeys ( GCObject l  )  [static]

Definition at line 335 of file lgc.c.

References Table::gclist, gcotoh, gkey, gnode, KEYWEAK, lua_assert, Table::marked, removekey(), sizenode, and valismarked().

Referenced by mark().

static void cleartablevalues ( GCObject l  )  [static]

Definition at line 355 of file lgc.c.

References Table::array, Table::gclist, gcotoh, gnode, gval, lua_assert, Table::marked, removekey(), setnilvalue, Table::sizearray, sizenode, valismarked(), and VALUEWEAK.

Referenced by mark().

static void do1gcTM ( lua_State L,
Udata udata 
) [static]

Definition at line 452 of file lgc.c.

References fasttm, luaD_call(), Udata::metatable, setobj2s, setuvalue, TM_GC, lua_State::top, and Udata::uv.

Referenced by luaC_callGCTM().

static void freeobj ( lua_State L,
GCObject o 
) [static]

Definition at line 378 of file lgc.c.

References G, GCObject::gch, gcotocl, gcotoh, gcotop, gcototh, gcotots, gcotou, gcotouv, lua_assert, LUA_TPROTO, LUA_TUPVAL, luaE_freethread(), luaF_freeclosure(), luaF_freeproto(), luaH_free(), luaM_free, luaM_freelem, sizestring, sizeudata, and GCheader::tt.

Referenced by sweeplist().

void luaC_callGCTM ( lua_State L  ) 

Definition at line 465 of file lgc.c.

References lua_State::allowhook, do1gcTM(), G, gcotou, markfinalized, Udata::next, setuvalue, lua_State::top, unmark, and Udata::uv.

Referenced by callallgcTM(), and luaC_collectgarbage().

void luaC_collectgarbage ( lua_State L  ) 

Definition at line 535 of file lgc.c.

References checkSizes(), luaC_callGCTM(), luaC_sweep(), and mark().

void luaC_link ( lua_State L,
GCObject o,
lu_byte  tt 
)

Definition at line 543 of file lgc.c.

References G, GCObject::gch, GCheader::marked, GCheader::next, and GCheader::tt.

Referenced by luaE_newthread(), luaF_close(), luaF_newCclosure(), luaF_newLclosure(), luaF_newproto(), and luaH_new().

size_t luaC_separateudata ( lua_State L  ) 

Definition at line 124 of file lgc.c.

References fasttm, G, GCObject::gch, gcotou, isfinalized, ismarked, lua_assert, markfinalized, GCheader::next, sizeudata, TM_GC, and GCheader::tt.

Referenced by lua_close(), and mark().

void luaC_sweep ( lua_State L,
int  all 
)

Definition at line 485 of file lgc.c.

References G, sweeplist(), and sweepstrings().

Referenced by close_state(), and luaC_collectgarbage().

static size_t mark ( lua_State L  )  [static]

Definition at line 506 of file lgc.c.

References cleartablekeys(), cleartablevalues(), G, GCState::g, luaC_separateudata(), markroot(), marktmu(), propagatemarks(), GCState::tmark, GCState::wk, GCState::wkv, and GCState::wv.

Referenced by luaC_collectgarbage().

static void markroot ( GCState st,
lua_State L 
) [static]

Definition at line 494 of file lgc.c.

References defaultmeta, GCState::g, global_State::mainthread, markobject, markvalue, registry, and traversestack().

Referenced by mark().

static void marktmu ( GCState st  )  [static]

Definition at line 112 of file lgc.c.

References GCState::g, GCObject::gch, GCheader::next, reallymarkobject(), global_State::tmudata, and unmark.

Referenced by mark().

static void propagatemarks ( GCState st  )  [static]

Definition at line 286 of file lgc.c.

References Closure::c, GCObject::gch, Proto::gclist, lua_State::gclist, CClosure::gclist, Table::gclist, gcotocl, gcotoh, gcotop, gcototh, lua_assert, LUA_TPROTO, GCState::tmark, traverseclosure(), traverseproto(), traversestack(), traversetable(), and GCheader::tt.

Referenced by mark().

static void reallymarkobject ( GCState st,
GCObject o 
) [static]

Definition at line 75 of file lgc.c.

References GCObject::gch, gcotocl, gcotoh, gcotop, gcototh, gcotou, ismarked, lua_assert, LUA_TPROTO, GCheader::marked, markvalue, setbit, GCState::tmark, and GCheader::tt.

Referenced by marktmu().

static void removekey ( Node n  )  [static]

Definition at line 156 of file lgc.c.

References gkey, gval, iscollectable, setnilvalue, and setttype.

Referenced by cleartablekeys(), and cleartablevalues().

static int sweeplist ( lua_State L,
GCObject **  p,
int  limit 
) [static]

Definition at line 404 of file lgc.c.

References freeobj(), GCObject::gch, GCheader::marked, GCheader::next, and unmark.

Referenced by luaC_sweep(), and sweepstrings().

static void sweepstrings ( lua_State L,
int  all 
) [static]

Definition at line 426 of file lgc.c.

References G, and sweeplist().

Referenced by luaC_sweep().

static void traverseclosure ( GCState st,
Closure cl 
) [static]

Definition at line 227 of file lgc.c.

References Closure::c, LClosure::g, hvalue, CClosure::isC, Closure::l, lua_assert, markobject, markvalue, Proto::nups, LClosure::nupvalues, CClosure::nupvalues, LClosure::p, LClosure::upvals, and CClosure::upvalue.

Referenced by propagatemarks().

static void traverseproto ( GCState st,
Proto f 
) [static]

Definition at line 207 of file lgc.c.

References Proto::k, Proto::locvars, lua_assert, luaG_checkcode(), markvalue, Proto::p, Proto::sizek, Proto::sizelocvars, Proto::sizep, Proto::sizeupvalues, Proto::source, stringmark, tsvalue, ttisstring, Proto::upvalues, and LocVar::varname.

Referenced by propagatemarks().

static void traversestack ( GCState st,
lua_State L1 
) [static]

Definition at line 265 of file lgc.c.

References lua_State::base_ci, checkstacksizes(), CI_C, CI_HASFRAME, CI_SAVEDPC, gt, lua_assert, markobject, setnilvalue, lua_State::stack, lua_State::stack_last, CallInfo::state, CallInfo::top, and lua_State::top.

Referenced by markroot(), and propagatemarks().

static void traversetable ( GCState st,
Table h 
) [static]

Definition at line 165 of file lgc.c.

References Table::array, cast, condmarkobject, global_State::dummynode, GCState::g, Table::gclist, gfasttm, gkey, gnode, gval, KEYWEAK, KEYWEAKBIT, Table::lsizenode, lua_assert, Table::marked, markobject, markvalue, Table::metatable, Table::node, Table::sizearray, sizenode, svalue, TM_MODE, ttisnil, ttisstring, valtogco, VALUEWEAK, VALUEWEAKBIT, GCState::wk, GCState::wkv, and GCState::wv.

Referenced by propagatemarks().

static int valismarked ( const TObject o  )  [static]

Definition at line 323 of file lgc.c.

References iscollectable, stringmark, testbit, tsvalue, and ttisstring.

Referenced by cleartablekeys(), and cleartablevalues().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2