Skip to content

Commit

Permalink
[gc-precise] codingstd
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Dec 8, 2014
1 parent 27a4438 commit f6a2f75
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 56 deletions.
96 changes: 50 additions & 46 deletions include/parrot/gc_api.h
Expand Up @@ -152,63 +152,67 @@ typedef struct gc_anchor_storage_s {

#if GC_USE_PRECISE != 0

#define GC_SETUP_ANCHOR_STORAGE(i, p, s) { \
const size_t __num_pmc_slots = ; \
const size_t __num_str_slots = s; \
const size_t __slot_storage_size = ((p) * sizeof (PMC *)) + ((s) * sizeof(STRING*)); \
const size_t __total_storage_size = __slot_storage_size + sizeof (gc_anchor_storage_t); \
gc_anchor_storage_t * const __anchor_storage = (gc_anchor_storage_t *) \
Parrot_gc_allocate_fixed_size_storage((i), __total_storage_size); \
PMC ** const __pmc_storage_slots = (PMC **) (__anchor_storage + 1); \
STRING ** const __str_storage_slots = (STRING **) (__pmc_storage_slots + __num_pmc_slots); \
memset(__anchor_storage, 0, __total_storage_size); \
__anchor_storage->num_p = __pmc_storage_size; \
__anchor_storage->num_s = __str_storage_size; \
__anchor_storage->prev = (i)->gc_anchor_storage; \
(i)->gc_anchor_storage = __anchor_storage; \
{

#define GC_CLEANUP_ANCHOR_STORAGE(i) \
} \
{ \
gc_anchor_storage_t * __current_storage = (i)->gc_anchor_storage; \
while (__current_storage && __current_storage != __anchor_storage) { \
gc_anchor_storage_t * const __tmp = __current_storage->prev; \
Parrot_gc_free_fixed_size_storage((i), __anchor_storage_size, __current_storage); \
__current_storage = __tmp; \
} \
(i)->gc_anchor_storage = __current_storage; \
} \
}

#define GC_GET_PMC_ANCHOR(n, p) { \
PARROT_ASSERT(n < __num_pmc_slots); \
(p) = __pmc_storage_slots[(n)]; \
# define GC_SETUP_ANCHOR_STORAGE(i, p, s) { \
const size_t __num_pmc_slots = (p); \
const size_t __num_str_slots = (s); \
const size_t __slot_storage_size = ((p) * sizeof (PMC *)) + \
((__num_str_slots) * sizeof (STRING*)); \
const size_t __total_storage_size = __slot_storage_size + \
sizeof (gc_anchor_storage_t); \
gc_anchor_storage_t * const __anchor_storage = (gc_anchor_storage_t *) \
Parrot_gc_allocate_fixed_size_storage((i), __total_storage_size); \
PMC ** const __pmc_storage_slots = (PMC **) (__anchor_storage + 1); \
STRING ** const __str_storage_slots = (STRING **) (__pmc_storage_slots + \
__num_pmc_slots); \
memset(__anchor_storage, 0, __total_storage_size); \
__anchor_storage->num_p = __pmc_storage_size; \
__anchor_storage->num_s = __str_storage_size; \
__anchor_storage->prev = (i)->gc_anchor_storage; \
(i)->gc_anchor_storage = __anchor_storage; \
{

# define GC_CLEANUP_ANCHOR_STORAGE(i) \
} \
{ \
gc_anchor_storage_t * __current_storage = (i)->gc_anchor_storage; \
while (__current_storage && __current_storage != __anchor_storage) { \
gc_anchor_storage_t * const __tmp = __current_storage->prev; \
Parrot_gc_free_fixed_size_storage((i), __anchor_storage_size, \
__current_storage); \
__current_storage = __tmp; \
} \
(i)->gc_anchor_storage = __current_storage; \
} \
}

# define GC_GET_PMC_ANCHOR(n, p) { \
PARROT_ASSERT((n) < __num_pmc_slots); \
(p) = __pmc_storage_slots[(n)]; \
}

#define GC_SET_PMC_ANCHOR(n, p) { \
PARROT_ASSERT(n < __num_pmc_slots); \
__pmc_storage_slots[(n)] = (p); \
# define GC_SET_PMC_ANCHOR(n, p) { \
PARROT_ASSERT((n) < __num_pmc_slots); \
__pmc_storage_slots[(n)] = (p); \
}

#define GC_GET_STRING_ANCHOR(n, s) { \
PARROT_ASSERT(n < __num_str_slots); \
# define GC_GET_STRING_ANCHOR(n, s) { \
PARROT_ASSERT((n) < __num_str_slots); \
(s) = __str_storage_slots[(n)]; \
}

#define GC_SET_STRING_ANCHOR(n, s) { \
PARROT_ASSERT(n < __num_str_slots); \
__str_storage_slots[(n)] = (s); \
# define GC_SET_STRING_ANCHOR(n, s) { \
PARROT_ASSERT((n) < __num_str_slots); \
__str_storage_slots[(n)] = (s); \
}

#else

#define GC_SETUP_ANCHOR_STORAGE(i, n)
#define GC_CLEANUP_ANCHOR_STORAGE(i)
#define GC_GET_PMC_ANCHOR(n, p)
#define GC_SET_PMC_ANCHOR(n, p)
#define GC_GET_STRING_ANCHOR(n, s)
#define GC_SET_STRING_ANCHOR(n, s)
# define GC_SETUP_ANCHOR_STORAGE(i, n)
# define GC_CLEANUP_ANCHOR_STORAGE(i)
# define GC_GET_PMC_ANCHOR(n, p)
# define GC_SET_PMC_ANCHOR(n, p)
# define GC_GET_STRING_ANCHOR(n, s)
# define GC_SET_STRING_ANCHOR(n, s)

#endif

Expand Down
6 changes: 3 additions & 3 deletions src/gc/mark_sweep.c
Expand Up @@ -272,18 +272,18 @@ mark_interp(PARROT_INTERP)
#if GC_USE_PRECISE != 0
{
gc_anchor_storage_t * gcas = interp->gc_anchor_storage;
while(gcas) {
while (gcas) {
const size_t num_p = gcas->num_p;
const size_t num_s = gcas->num_s;
PMC ** const ps = (PMC **)(gcas + 1);
STRING ** const ss = (STRING **)(ps + num_p);
size_t t;
for(t = 0 ; t < num_p; t++) {
for (t = 0; t < num_p; t++) {
PMC * const pmc = ps[t];
if (!PMC_IS_NULL(pmc))
Parrot_gc_mark_PMC_alive(interp, pmc);
}
for(t = 0 ; t < num_s; t++) {
for (t = 0; t < num_s; t++) {
STRING * const str = ss[t];
if (!PMC_IS_NULL(str))
Parrot_gc_mark_STRING_alive(interp, str);
Expand Down
14 changes: 7 additions & 7 deletions src/gc/system.c
Expand Up @@ -470,13 +470,13 @@ trace_mem_block(PARROT_INTERP,
? mask & buffer_min
: 0;

#if (GC_USE_PRECISE == 1) && defined(MEMORY_DEBUG)
# define GC_PRECISE_WARN(msg) \
# if (GC_USE_PRECISE == 1) && defined(MEMORY_DEBUG)
# define GC_PRECISE_WARN(msg) \
if (Interp_debug_TEST(interp, PARROT_MEM_STAT_DEBUG_FLAG | PARROT_GC_DETAIL_DEBUG_FLAG)) \
fprintf(stderr, "GC_USE_PRECISE: "msg, (void *)ptr, (void *)cur_var_ptr)
#else
# define GC_PRECISE_WARN(msg)
#endif
fprintf(stderr, "GC_USE_PRECISE: "(msg), (void *)ptr, (void *)cur_var_ptr)
# else
# define GC_PRECISE_WARN(msg)
# endif


for (cur_var_ptr = lo_var_ptr; cur_var_ptr < (ptrdiff_t)hi_var_ptr; cur_var_ptr++) {
Expand Down Expand Up @@ -511,7 +511,7 @@ trace_mem_block(PARROT_INTERP,
}
}
}
#undef GC_PRECISE_WARN
# undef GC_PRECISE_WARN

return;
}
Expand Down

0 comments on commit f6a2f75

Please sign in to comment.