summaryrefslogtreecommitdiff
path: root/lgc.h
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.h')
-rw-r--r--lgc.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/lgc.h b/lgc.h
index 4e38c0fc..846d40d8 100644
--- a/lgc.h
+++ b/lgc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.h,v 2.59 2013/08/05 16:58:28 roberto Exp roberto $ 2** $Id: lgc.h,v 2.60 2013/08/13 17:36:44 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -79,6 +79,7 @@
79#define FINALIZEDBIT 3 /* object has been separated for finalization */ 79#define FINALIZEDBIT 3 /* object has been separated for finalization */
80#define SEPARATED 4 /* object is in 'finobj' list or in 'tobefnz' */ 80#define SEPARATED 4 /* object is in 'finobj' list or in 'tobefnz' */
81#define FIXEDBIT 5 /* object is fixed (should not be collected) */ 81#define FIXEDBIT 5 /* object is fixed (should not be collected) */
82#define LOCALBIT 6 /* object is not local */
82/* bit 7 is currently used by tests (luaL_checkmemory) */ 83/* bit 7 is currently used by tests (luaL_checkmemory) */
83 84
84#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 85#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
@@ -88,6 +89,7 @@
88#define isblack(x) testbit((x)->gch.marked, BLACKBIT) 89#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
89#define isgray(x) /* neither white nor black */ \ 90#define isgray(x) /* neither white nor black */ \
90 (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) 91 (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT)))
92#define islocal(x) (!testbit((x)->gch.marked, LOCALBIT))
91 93
92 94
93#define otherwhite(g) (g->currentwhite ^ WHITEBITS) 95#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
@@ -97,6 +99,9 @@
97#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) 99#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
98#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) 100#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
99 101
102#define nolocal(x) l_setbit((x)->gch.marked, LOCALBIT)
103#define valnolocal(v) { if (iscollectable(v)) nolocal(gcvalue(v)); }
104
100#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) 105#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
101 106
102 107
@@ -106,22 +111,25 @@
106 111
107 112
108#define luaC_barrier(L,p,v) { \ 113#define luaC_barrier(L,p,v) { \
109 if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \ 114 if (iscollectable(v) && \
115 (nolocal(gcvalue(v)), isblack(obj2gco(p)) && iswhite(gcvalue(v)))) \
110 luaC_barrier_(L,obj2gco(p),gcvalue(v)); } 116 luaC_barrier_(L,obj2gco(p),gcvalue(v)); }
111 117
112#define luaC_barrierback(L,p,v) { \ 118#define luaC_barrierback(L,p,v) { \
113 if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \ 119 if (iscollectable(v) && \
120 (nolocal(gcvalue(v)), isblack(obj2gco(p)) && iswhite(gcvalue(v)))) \
114 luaC_barrierback_(L,p); } 121 luaC_barrierback_(L,p); }
115 122
116#define luaC_objbarrier(L,p,o) { \ 123#define luaC_objbarrier(L,p,o) { \
117 if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ 124 if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \
118 luaC_barrier_(L,obj2gco(p),obj2gco(o)); } 125 luaC_barrier_(L,obj2gco(p),obj2gco(o)); }
119 126
120#define luaC_objbarrierback(L,p,o) \ 127#define luaC_objbarrierback(L,p,o) \
121 { if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) luaC_barrierback_(L,p); } 128 { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \
129 luaC_barrierback_(L,p); }
122 130
123#define luaC_barrierproto(L,p,c) \ 131#define luaC_barrierproto(L,p,c) \
124 { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } 132 { if (nolocal(obj2gco(c)), isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); }
125 133
126LUAI_FUNC void luaC_freeallobjects (lua_State *L); 134LUAI_FUNC void luaC_freeallobjects (lua_State *L);
127LUAI_FUNC void luaC_step (lua_State *L); 135LUAI_FUNC void luaC_step (lua_State *L);