# 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"`

## Defines
#define | lgc_c
#define | LUA_CORE
#define | GCSTEPSIZE 1024u
#define | GCSWEEPMAX 40
#define | GCSWEEPCOST 10
#define | GCFINALIZECOST 100
#define | maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
#define | makewhite(g, x) ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
#define | white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
#define | black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
#define | stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
#define | isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
#define | markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
#define | KEYWEAK bitmask(KEYWEAKBIT)
#define | VALUEWEAK bitmask(VALUEWEAKBIT)
#define | markvalue(g, o)
#define | markobject(g, t)
#define | setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
#define | sweepwholelist(L, p) sweeplist(L,p,MAX_LUMEM)
## Functions
static void | removeentry (Node *n)
static void | reallymarkobject (global_State *g, GCObject *o)
static void | marktmu (global_State *g)
size_t | luaC_separateudata (lua_State *L, int all)
static int | traversetable (global_State *g, Table *h)
static void | traverseproto (global_State *g, Proto *f)
static void | traverseclosure (global_State *g, Closure *cl)
static void | checkstacksizes (lua_State *L, StkId max)
static void | traversestack (global_State *g, lua_State *l)
static l_mem | propagatemark (global_State *g)
static size_t | propagateall (global_State *g)
static int | iscleared (const TValue *o, int iskey)
static void | cleartable (GCObject *l)
static void | freeobj (lua_State *L, GCObject *o)
static GCObject ** | sweeplist (lua_State *L, GCObject **p, lu_mem count)
static void | checkSizes (lua_State *L)
static void | GCTM (lua_State *L)
void | luaC_callGCTM (lua_State *L)
void | luaC_freeall (lua_State *L)
static void | markmt (global_State *g)
static void | markroot (lua_State *L)
static void | remarkupvals (global_State *g)
static void | atomic (lua_State *L)
static l_mem | singlestep (lua_State *L)
void | luaC_step (lua_State *L)
void | luaC_fullgc (lua_State *L)
void | luaC_barrierf (lua_State *L, GCObject *o, GCObject *v)
void | luaC_barrierback (lua_State *L, Table *t)
void | luaC_link (lua_State *L, GCObject *o, lu_byte tt)
void | luaC_linkupval (lua_State *L, UpVal *uv)

## Define Documentation

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

#define GCFINALIZECOST 100

#define GCSTEPSIZE 1024u

#define GCSWEEPCOST 10

#define GCSWEEPMAX 40

#define isfinalized | ( | u |  | ) | testbit((u)->marked, FINALIZEDBIT)

#define KEYWEAK bitmask(KEYWEAKBIT)

#define lgc_c

#define LUA_CORE

#define makewhite | ( | g,
|  | x |  | ) | ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))

#define markfinalized | ( | u |  | ) | l_setbit((u)->marked, FINALIZEDBIT)

#define markobject | ( | g,
|  | t |  | ) |

Value:

    { if (iswhite(obj2gco(t))) \
                    reallymarkobject(g, obj2gco(t)); }

#define markvalue | ( | g,
|  | o |  | ) |

Value:

    { checkconsistency(o); \
      if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }

#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))

#define setthreshold | ( | g |  | ) | (g->GCthreshold = (g->estimate/100) * g->gcpause)

#define stringmark | ( | s |  | ) | reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)

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

#define VALUEWEAK bitmask(VALUEWEAKBIT)

#define white2gray | ( | x |  | ) | reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)

## Function Documentation

static void atomic | ( | lua_State * | L | ) | `[static]`

static void checkSizes | ( | lua_State * | L | ) | `[static]`

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

static void cleartable | ( | GCObject * | l | ) | `[static]`

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

static void GCTM | ( | lua_State * | L | ) | `[static]`

static int iscleared | ( | const TValue * | o,
|  | int | iskey |
| ) |  |  | `[static]`

void luaC_barrierback | ( | lua_State * | L,
|  | Table * | t |
| ) |  |  |

void luaC_barrierf | ( | lua_State * | L,
|  | GCObject * | o,
|  | GCObject * | v |
| ) |  |  |

void luaC_callGCTM | ( | lua_State * | L | ) |

void luaC_freeall | ( | lua_State * | L | ) |

void luaC_fullgc | ( | lua_State * | L | ) |

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

void luaC_linkupval | ( | lua_State * | L,
|  | UpVal * | uv |
| ) |  |  |

size_t luaC_separateudata | ( | lua_State * | L,
|  | int | all |
| ) |  |  |

void luaC_step | ( | lua_State * | L | ) |

static void markmt | ( | global_State * | g | ) | `[static]`

static void markroot | ( | lua_State * | L | ) | `[static]`

static void marktmu | ( | global_State * | g | ) | `[static]`

static size_t propagateall | ( | global_State * | g | ) | `[static]`

static l_mem propagatemark | ( | global_State * | g | ) | `[static]`

static void reallymarkobject | ( | global_State * | g,
|  | GCObject * | o |
| ) |  |  | `[static]`

static void remarkupvals | ( | global_State * | g | ) | `[static]`

static void removeentry | ( | Node * | n | ) | `[static]`

static l_mem singlestep | ( | lua_State * | L | ) | `[static]`

static GCObject** sweeplist | ( | lua_State * | L,
|  | GCObject ** | p,
|  | lu_mem | count |
| ) |  |  | `[static]`

static void traverseclosure | ( | global_State * | g,
|  | Closure * | cl |
| ) |  |  | `[static]`

static void traverseproto | ( | global_State * | g,
|  | Proto * | f |
| ) |  |  | `[static]`

static void traversestack | ( | global_State * | g,
|  | lua_State * | l |
| ) |  |  | `[static]`

static int traversetable | ( | global_State * | g,
|  | Table * | h |
| ) |  |  | `[static]`