tagged release 0.7.1
[parrot.git] / include / parrot / dod.h
blob9edcf571702bc4e88761272a16869993f293f9fb
1 /* dod.h
2 * Copyright (C) 2001-2007, The Perl Foundation.
3 * SVN Info
4 * $Id$
5 * Overview:
6 * Handles dead object destruction of the various headers
7 * History:
8 * Initial version by Mike Lambert on 2002.05.27
9 */
11 #ifndef PARROT_DOD_H_GUARD
12 #define PARROT_DOD_H_GUARD
14 #include "parrot/parrot.h"
16 /* Macros for recursively blocking and unblocking DOD */
17 #define Parrot_block_GC_mark(interp) \
18 { \
19 (interp)->arena_base->DOD_block_level++; \
20 Parrot_shared_DOD_block(interp); \
23 #define Parrot_unblock_GC_mark(interp) \
24 if ((interp)->arena_base->DOD_block_level) { \
25 (interp)->arena_base->DOD_block_level--; \
26 Parrot_shared_DOD_unblock(interp); \
29 /* Macros for recursively blocking and unblocking GC */
30 #define Parrot_block_GC_sweep(interp) \
31 (interp)->arena_base->GC_block_level++
33 #define Parrot_unblock_GC_sweep(interp) \
34 if ((interp)->arena_base->GC_block_level) \
35 (interp)->arena_base->GC_block_level--
37 /* Macros for testing if the DOD and GC are blocked */
38 #define Parrot_is_blocked_GC_mark(interp) \
39 ((interp)->arena_base->DOD_block_level)
41 #define Parrot_is_blocked_GC_sweep(interp) \
42 ((interp)->arena_base->GC_block_level)
44 #define GC_trace_stack_FLAG (UINTVAL)(1 << 0) /* trace system areas and stack */
45 #define GC_trace_normal (UINTVAL)(1 << 0) /* the same */
46 #define GC_lazy_FLAG (UINTVAL)(1 << 1) /* timely destruction run */
47 #define GC_finish_FLAG (UINTVAL)(1 << 2) /* on Parrot exit: mark (almost) all PMCs dead and */
48 /* garbage collect. */
50 /* HEADERIZER BEGIN: src/gc/dod.c */
51 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
53 PARROT_API
54 void pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
55 __attribute__nonnull__(1)
56 __attribute__nonnull__(2)
57 FUNC_MODIFIES(*obj);
59 void clear_cow(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int cleanup)
60 __attribute__nonnull__(1)
61 __attribute__nonnull__(2)
62 FUNC_MODIFIES(*pool);
64 void Parrot_do_dod_run(PARROT_INTERP, UINTVAL flags)
65 __attribute__nonnull__(1);
67 void Parrot_dod_clear_live_bits(PARROT_INTERP)
68 __attribute__nonnull__(1);
70 void Parrot_dod_free_buffer(SHIM_INTERP,
71 ARGMOD(Small_Object_Pool *pool),
72 ARGMOD(PObj *b))
73 __attribute__nonnull__(2)
74 __attribute__nonnull__(3)
75 FUNC_MODIFIES(*pool)
76 FUNC_MODIFIES(*b);
78 void Parrot_dod_free_buffer_malloc(SHIM_INTERP,
79 SHIM(Small_Object_Pool *pool),
80 ARGMOD(PObj *b))
81 __attribute__nonnull__(3)
82 FUNC_MODIFIES(*b);
84 void Parrot_dod_free_pmc(PARROT_INTERP,
85 SHIM(Small_Object_Pool *pool),
86 ARGMOD(PObj *p))
87 __attribute__nonnull__(1)
88 __attribute__nonnull__(3)
89 FUNC_MODIFIES(*p);
91 void Parrot_dod_free_sysmem(SHIM_INTERP,
92 SHIM(Small_Object_Pool *pool),
93 ARGMOD(PObj *b))
94 __attribute__nonnull__(3)
95 FUNC_MODIFIES(*b);
97 void Parrot_dod_ms_run(PARROT_INTERP, int flags)
98 __attribute__nonnull__(1);
100 void Parrot_dod_ms_run_init(PARROT_INTERP)
101 __attribute__nonnull__(1);
103 void Parrot_dod_profile_end(PARROT_INTERP, int what)
104 __attribute__nonnull__(1);
106 void Parrot_dod_profile_start(PARROT_INTERP)
107 __attribute__nonnull__(1);
109 void Parrot_dod_sweep(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
110 __attribute__nonnull__(1)
111 __attribute__nonnull__(2)
112 FUNC_MODIFIES(*pool);
114 int Parrot_dod_trace_children(PARROT_INTERP, size_t how_many)
115 __attribute__nonnull__(1);
117 void Parrot_dod_trace_pmc_data(PARROT_INTERP, ARGIN(PMC *p))
118 __attribute__nonnull__(1)
119 __attribute__nonnull__(2);
121 int Parrot_dod_trace_root(PARROT_INTERP, int trace_stack)
122 __attribute__nonnull__(1);
124 void Parrot_free_pmc_ext(PARROT_INTERP, ARGMOD(PMC *p))
125 __attribute__nonnull__(1)
126 __attribute__nonnull__(2)
127 FUNC_MODIFIES(*p);
129 void trace_mem_block(PARROT_INTERP, size_t lo_var_ptr, size_t hi_var_ptr)
130 __attribute__nonnull__(1);
132 void used_cow(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), int cleanup)
133 __attribute__nonnull__(1)
134 __attribute__nonnull__(2)
135 FUNC_MODIFIES(*pool);
137 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
138 /* HEADERIZER END: src/gc/dod.c */
141 /* HEADERIZER BEGIN: src/cpu_dep.c */
142 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
144 void trace_system_areas(PARROT_INTERP)
145 __attribute__nonnull__(1);
147 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
148 /* HEADERIZER END: src/cpu_dep.c */
151 #if ! DISABLE_GC_DEBUG
152 /* Set when walking the system stack */
153 extern int CONSERVATIVE_POINTER_CHASING;
154 #endif
157 /* GC subsystem init functions */
158 /* HEADERIZER BEGIN: src/gc/gc_gms.c */
159 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
161 PARROT_API
162 void Parrot_gc_gms_init(PARROT_INTERP)
163 __attribute__nonnull__(1);
165 PARROT_API
166 void parrot_gc_gms_pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
167 __attribute__nonnull__(1)
168 __attribute__nonnull__(2)
169 FUNC_MODIFIES(*obj);
171 void parrot_gc_gms_wb(PARROT_INTERP,
172 ARGIN(PMC *agg),
173 ARGIN(void *old),
174 ARGIN(void *_new))
175 __attribute__nonnull__(1)
176 __attribute__nonnull__(2)
177 __attribute__nonnull__(3)
178 __attribute__nonnull__(4);
180 void parrot_gc_gms_wb_key(PARROT_INTERP,
181 ARGIN(PMC *agg),
182 ARGIN(void *old),
183 ARGIN(void *old_key),
184 ARGIN(void *_new),
185 ARGIN(void *new_key))
186 __attribute__nonnull__(1)
187 __attribute__nonnull__(2)
188 __attribute__nonnull__(3)
189 __attribute__nonnull__(4)
190 __attribute__nonnull__(5)
191 __attribute__nonnull__(6);
193 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
194 /* HEADERIZER END: src/gc/gc_gms.c */
196 /* HEADERIZER BEGIN: src/gc/gc_ims.c */
197 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
199 void Parrot_dod_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
200 __attribute__nonnull__(1)
201 __attribute__nonnull__(2)
202 __attribute__nonnull__(3)
203 FUNC_MODIFIES(*agg)
204 FUNC_MODIFIES(*_new);
206 void Parrot_gc_ims_init(PARROT_INTERP)
207 __attribute__nonnull__(1);
209 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
210 /* HEADERIZER END: src/gc/gc_ims.c */
213 * write barrier
215 #if PARROT_GC_IMS
216 # define GC_WRITE_BARRIER(interp, agg, old, _new) \
217 do { \
218 if (!PMC_IS_NULL(_new) && \
219 PObj_live_TEST(agg) && \
220 (PObj_get_FLAGS(agg) & PObj_custom_GC_FLAG) && \
221 !PObj_live_TEST(_new)) { \
222 Parrot_dod_ims_wb((interp), (agg), (_new)); \
224 } while (0)
226 # define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) \
227 GC_WRITE_BARRIER((interp), (agg), (old), (_new))
228 #endif
230 #if PARROT_GC_MS
231 # define GC_WRITE_BARRIER(interp, agg, old, _new)
232 # define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key)
233 #endif
235 #if PARROT_GC_GMS
236 # define GC_WRITE_BARRIER(interp, agg, old, _new) do { \
237 UINTVAL gen_agg, gen_new; \
238 if (!(_new) || PMC_IS_NULL(_new)) \
239 break; \
240 gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
241 gen_new = PObj_to_GMSH(_new)->gen->gen_no; \
242 if (gen_agg < gen_new) \
243 parrot_gc_gms_wb((interp), (agg), (old), (_new)); \
244 } while (0)
246 # define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { \
247 UINTVAL gen_agg, gen_new, gen_key; \
248 if (!(_new) || PMC_IS_NULL(_new)) \
249 break; \
250 gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
251 gen_new = PObj_to_GMSH(_new)->gen->gen_no; \
252 gen_key = PObj_to_GMSH(new_key)->gen->gen_no; \
253 if (gen_agg < gen_new || gen_agg < gen_key) \
254 parrot_gc_gms_wb_key((interp), (agg), (old), (old_key), (_new), (new_key)); \
255 } while (0)
257 #endif
259 #endif /* PARROT_DOD_H_GUARD */
262 * Local variables:
263 * c-file-style: "parrot"
264 * End:
265 * vim: expandtab shiftwidth=4: