Lua 5.1.4: lgc.h


L0001    /*
L0002    ** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
L0003    ** Garbage Collector
L0004    ** See Copyright Notice in lua.h
L0005    */
L0006    
L0007    #ifndef lgc_h
L0008    #define lgc_h
L0009    
L0010    
L0011    #include "lobject.h"
L0012    
L0013    
L0014    /*
L0015    ** Possible states of the Garbage Collector
L0016    */
L0017    #define GCSpause	0
L0018    #define GCSpropagate	1
L0019    #define GCSsweepstring	2
L0020    #define GCSsweep	3
L0021    #define GCSfinalize	4
L0022    
L0023    
L0024    /*
L0025    ** some userful bit tricks
L0026    */
L0027    #define resetbits(x,m)	((x) &= cast(lu_byte, ~(m)))
L0028    #define setbits(x,m)	((x) |= (m))
L0029    #define testbits(x,m)	((x) & (m))
L0030    #define bitmask(b)	(1<<(b))
L0031    #define bit2mask(b1,b2)	(bitmask(b1) | bitmask(b2))
L0032    #define l_setbit(x,b)	setbits(x, bitmask(b))
L0033    #define resetbit(x,b)	resetbits(x, bitmask(b))
L0034    #define testbit(x,b)	testbits(x, bitmask(b))
L0035    #define set2bits(x,b1,b2)	setbits(x, (bit2mask(b1, b2)))
L0036    #define reset2bits(x,b1,b2)	resetbits(x, (bit2mask(b1, b2)))
L0037    #define test2bits(x,b1,b2)	testbits(x, (bit2mask(b1, b2)))
L0038    
L0039    
L0040    
L0041    /*
L0042    ** Layout for bit use in `marked' field:
L0043    ** bit 0 - object is white (type 0)
L0044    ** bit 1 - object is white (type 1)
L0045    ** bit 2 - object is black
L0046    ** bit 3 - for userdata: has been finalized
L0047    ** bit 3 - for tables: has weak keys
L0048    ** bit 4 - for tables: has weak values
L0049    ** bit 5 - object is fixed (should not be collected)
L0050    ** bit 6 - object is "super" fixed (only the main thread)
L0051    */
L0052    
L0053    
L0054    #define WHITE0BIT	0
L0055    #define WHITE1BIT	1
L0056    #define BLACKBIT	2
L0057    #define FINALIZEDBIT	3
L0058    #define KEYWEAKBIT	3
L0059    #define VALUEWEAKBIT	4
L0060    #define FIXEDBIT	5
L0061    #define SFIXEDBIT	6
L0062    #define WHITEBITS	bit2mask(WHITE0BIT, WHITE1BIT)
L0063    
L0064    
L0065    #define iswhite(x)      test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
L0066    #define isblack(x)      testbit((x)->gch.marked, BLACKBIT)
L0067    #define isgray(x)	(!isblack(x) && !iswhite(x))
L0068    
L0069    #define otherwhite(g)	(g->currentwhite ^ WHITEBITS)
L0070    #define isdead(g,v)	((v)->gch.marked & otherwhite(g) & WHITEBITS)
L0071    
L0072    #define changewhite(x)	((x)->gch.marked ^= WHITEBITS)
L0073    #define gray2black(x)	l_setbit((x)->gch.marked, BLACKBIT)
L0074    
L0075    #define valiswhite(x)	(iscollectable(x) && iswhite(gcvalue(x)))
L0076    
L0077    #define luaC_white(g)	cast(lu_byte, (g)->currentwhite & WHITEBITS)
L0078    
L0079    
L0080    #define luaC_checkGC(L) { \
L0081      condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
L0082      if (G(L)->totalbytes >= G(L)->GCthreshold) \
L0083    	luaC_step(L); }
L0084    
L0085    
L0086    #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p)))  \
L0087    	luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
L0088    
L0089    #define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t)))  \
L0090    	luaC_barrierback(L,t); }
L0091    
L0092    #define luaC_objbarrier(L,p,o)  \
L0093    	{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
L0094    		luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
L0095    
L0096    #define luaC_objbarriert(L,t,o)  \
L0097       { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
L0098    
L0099    LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
L0100    LUAI_FUNC void luaC_callGCTM (lua_State *L);
L0101    LUAI_FUNC void luaC_freeall (lua_State *L);
L0102    LUAI_FUNC void luaC_step (lua_State *L);
L0103    LUAI_FUNC void luaC_fullgc (lua_State *L);
L0104    LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
L0105    LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
L0106    LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
L0107    LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
L0108    
L0109    
L0110    #endif

Generated by pretty.lua