/
dod.h
251 lines (196 loc) · 7.33 KB
/
dod.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/* dod.h
* Copyright (C) 2001-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
* Handles dead object destruction of the various headers
* History:
* Initial version by Mike Lambert on 2002.05.27
*/
#ifndef PARROT_DOD_H_GUARD
#define PARROT_DOD_H_GUARD
#include "parrot/parrot.h"
/* Macros for recursively blocking and unblocking DOD */
#define Parrot_block_DOD(interp) \
{ \
(interp)->arena_base->DOD_block_level++; \
Parrot_shared_DOD_block(interp); \
}
#define Parrot_unblock_DOD(interp) \
if ((interp)->arena_base->DOD_block_level) { \
(interp)->arena_base->DOD_block_level--; \
Parrot_shared_DOD_unblock(interp); \
}
/* Macros for recursively blocking and unblocking GC */
#define Parrot_block_GC(interp) \
(interp)->arena_base->GC_block_level++
#define Parrot_unblock_GC(interp) \
if ((interp)->arena_base->GC_block_level) \
(interp)->arena_base->GC_block_level--
/* Macros for testing if the DOD and GC are blocked */
#define Parrot_is_blocked_DOD(interp) \
((interp)->arena_base->DOD_block_level)
#define Parrot_is_blocked_GC(interp) \
((interp)->arena_base->GC_block_level)
#define DOD_trace_stack_FLAG (UINTVAL)(1 << 0) /* trace system areads and stack */
#define DOD_trace_normal (UINTVAL)(1 << 0) /* the same */
#define DOD_lazy_FLAG (UINTVAL)(1 << 1) /* timely destruction run */
#define DOD_finish_FLAG (UINTVAL)(1 << 2) /* on Parrot exit: mark (almost) all PMCs dead and */
/* garbage collect. */
#define DOD_no_trace_volatile_roots (UINTVAL)(1 << 3)
/* trace all but volatile root set, i.e. registers */
/* HEADERIZER BEGIN: src/gc/dod.c */
PARROT_API
void pobject_lives( PARROT_INTERP, NOTNULL(PObj *obj) )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void clear_cow( PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), int cleanup )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void Parrot_do_dod_run( PARROT_INTERP, UINTVAL flags )
__attribute__nonnull__(1);
void Parrot_dod_clear_live_bits( PARROT_INTERP )
__attribute__nonnull__(1);
void Parrot_dod_free_buffer(
PARROT_INTERP,
NOTNULL(Small_Object_Pool *pool),
NOTNULL(PObj *b) )
__attribute__nonnull__(2)
__attribute__nonnull__(3);
void Parrot_dod_free_buffer_malloc( PARROT_INTERP,
NOTNULL(Small_Object_Pool *pool),
NOTNULL(PObj *b) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
void Parrot_dod_free_pmc( PARROT_INTERP,
NOTNULL(Small_Object_Pool *pool),
NOTNULL(PObj *p) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
void Parrot_dod_free_sysmem( PARROT_INTERP,
NOTNULL(Small_Object_Pool *pool),
NOTNULL(PObj *b) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
void Parrot_dod_ms_run( PARROT_INTERP, int flags )
__attribute__nonnull__(1);
void Parrot_dod_ms_run_init( PARROT_INTERP )
__attribute__nonnull__(1);
void Parrot_dod_profile_end( PARROT_INTERP, int what )
__attribute__nonnull__(1);
void Parrot_dod_profile_start( PARROT_INTERP )
__attribute__nonnull__(1);
void Parrot_dod_sweep( PARROT_INTERP, NOTNULL(Small_Object_Pool *pool) )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
int Parrot_dod_trace_children( PARROT_INTERP, size_t how_many )
__attribute__nonnull__(1);
void Parrot_dod_trace_pmc_data( PARROT_INTERP, NOTNULL(PMC * const p) )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
int Parrot_dod_trace_root( PARROT_INTERP, int trace_stack )
__attribute__nonnull__(1);
void Parrot_free_pmc_ext( PARROT_INTERP, NOTNULL(PMC *p) )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void trace_mem_block( PARROT_INTERP, size_t lo_var_ptr, size_t hi_var_ptr )
__attribute__nonnull__(1);
void used_cow( PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), int cleanup )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
/* HEADERIZER END: src/gc/dod.c */
/* HEADERIZER BEGIN: src/cpu_dep.c */
void trace_system_areas( PARROT_INTERP )
__attribute__nonnull__(1);
/* HEADERIZER END: src/cpu_dep.c */
#if ! DISABLE_GC_DEBUG
/* Set when walking the system stack */
extern int CONSERVATIVE_POINTER_CHASING;
#endif
/* GC subsystem init functions */
/* HEADERIZER BEGIN: src/gc/gc_gms.c */
void Parrot_gc_gms_init( PARROT_INTERP )
__attribute__nonnull__(1);
void parrot_gc_gms_pobject_lives( PARROT_INTERP, NOTNULL(PObj *obj) )
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void parrot_gc_gms_wb( PARROT_INTERP,
NOTNULL(PMC *agg),
NOTNULL(void *old),
NOTNULL(void *_new) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
__attribute__nonnull__(4);
void parrot_gc_gms_wb_key( PARROT_INTERP,
NOTNULL(PMC *agg),
NOTNULL(void *old),
NOTNULL(void *old_key),
NOTNULL(void *_new),
NOTNULL(void *new_key) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
__attribute__nonnull__(4)
__attribute__nonnull__(5)
__attribute__nonnull__(6);
/* HEADERIZER END: src/gc/gc_gms.c */
/* HEADERIZER BEGIN: src/gc/gc_ims.c */
void Parrot_dod_ims_wb( PARROT_INTERP, NOTNULL(PMC *agg), NOTNULL(PMC *_new) )
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);
void Parrot_gc_ims_init( PARROT_INTERP )
__attribute__nonnull__(1);
/* HEADERIZER END: src/gc/gc_ims.c */
/*
* write barrier
*/
#if PARROT_GC_IMS
# define DOD_WRITE_BARRIER(interp, agg, old, new) \
do { \
if (!PMC_IS_NULL(new) && \
PObj_live_TEST(agg) && \
(PObj_get_FLAGS(agg) & PObj_custom_GC_FLAG) && \
!PObj_live_TEST(new)) { \
Parrot_dod_ims_wb(interp, agg, new); \
} \
} while (0)
# define DOD_WRITE_BARRIER_KEY(interp, agg, old, old_key, new, new_key) \
DOD_WRITE_BARRIER(interp, agg, old, new)
#endif
#if PARROT_GC_MS
# define DOD_WRITE_BARRIER(interp, agg, old, new)
# define DOD_WRITE_BARRIER_KEY(interp, agg, old, old_key, new, new_key)
#endif
#if PARROT_GC_GMS
# define DOD_WRITE_BARRIER(interp, agg, old, new) do { \
UINTVAL gen_agg, gen_new; \
if (!(new) || PMC_IS_NULL(new)) \
break; \
gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
gen_new = PObj_to_GMSH(new)->gen->gen_no; \
if (gen_agg < gen_new) \
parrot_gc_gms_wb(interp, agg, old, new); \
} while (0)
# define DOD_WRITE_BARRIER_KEY(interp, agg, old, old_key, new, new_key) do { \
UINTVAL gen_agg, gen_new, gen_key; \
if (!(new) || PMC_IS_NULL(new)) \
break; \
gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \
gen_new = PObj_to_GMSH(new)->gen->gen_no; \
gen_key = PObj_to_GMSH(new_key)->gen->gen_no; \
if (gen_agg < gen_new || gen_agg < gen_key) \
parrot_gc_gms_wb_key(interp, agg, old, old_key, new, new_key); \
} while (0)
#endif
#endif /* PARROT_DOD_H_GUARD */
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/