Mercurial > vba-clojure
view src/lua/lgc.h @ 582:393b49a83394
tracked down error to set=HL-from-row-and-column
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 01 Sep 2012 09:43:19 -0500 |
parents | 27763b933818 |
children |
line wrap: on
line source
1 /*2 ** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $3 ** Garbage Collector4 ** See Copyright Notice in lua.h5 */7 #ifndef lgc_h8 #define lgc_h11 #include "lobject.h"14 /*15 ** Possible states of the Garbage Collector16 */17 #define GCSpause 018 #define GCSpropagate 119 #define GCSsweepstring 220 #define GCSsweep 321 #define GCSfinalize 424 /*25 ** some userful bit tricks26 */27 #define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))28 #define setbits(x,m) ((x) |= (m))29 #define testbits(x,m) ((x) & (m))30 #define bitmask(b) (1<<(b))31 #define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))32 #define l_setbit(x,b) setbits(x, bitmask(b))33 #define resetbit(x,b) resetbits(x, bitmask(b))34 #define testbit(x,b) testbits(x, bitmask(b))35 #define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))36 #define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))37 #define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))41 /*42 ** Layout for bit use in `marked' field:43 ** bit 0 - object is white (type 0)44 ** bit 1 - object is white (type 1)45 ** bit 2 - object is black46 ** bit 3 - for userdata: has been finalized47 ** bit 3 - for tables: has weak keys48 ** bit 4 - for tables: has weak values49 ** bit 5 - object is fixed (should not be collected)50 ** bit 6 - object is "super" fixed (only the main thread)51 */54 #define WHITE0BIT 055 #define WHITE1BIT 156 #define BLACKBIT 257 #define FINALIZEDBIT 358 #define KEYWEAKBIT 359 #define VALUEWEAKBIT 460 #define FIXEDBIT 561 #define SFIXEDBIT 662 #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)65 #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)66 #define isblack(x) testbit((x)->gch.marked, BLACKBIT)67 #define isgray(x) (!isblack(x) && !iswhite(x))69 #define otherwhite(g) (g->currentwhite ^ WHITEBITS)70 #define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)72 #define changewhite(x) ((x)->gch.marked ^= WHITEBITS)73 #define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)75 #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))77 #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)80 #define luaC_checkGC(L) { \81 condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \82 if (G(L)->totalbytes >= G(L)->GCthreshold) \83 luaC_step(L); }86 #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \87 luaC_barrierf(L,obj2gco(p),gcvalue(v)); }89 #define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \90 luaC_barrierback(L,t); }92 #define luaC_objbarrier(L,p,o) \93 { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \94 luaC_barrierf(L,obj2gco(p),obj2gco(o)); }96 #define luaC_objbarriert(L,t,o) \97 { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }99 LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);100 LUAI_FUNC void luaC_callGCTM (lua_State *L);101 LUAI_FUNC void luaC_freeall (lua_State *L);102 LUAI_FUNC void luaC_step (lua_State *L);103 LUAI_FUNC void luaC_fullgc (lua_State *L);104 LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);105 LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);106 LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);107 LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);110 #endif