Skip to content

Commit

Permalink
temp: expand 2 POINTER_ARRAY_ITER macros
Browse files Browse the repository at this point in the history
for easier debugging. fixed codingstd violations.
revert this when the GC bug is being found.
  • Loading branch information
Reini Urban committed Nov 8, 2014
1 parent 222d6f1 commit b4dae7b
Showing 1 changed file with 52 additions and 26 deletions.
78 changes: 52 additions & 26 deletions src/gc/gc_gms.c
Expand Up @@ -886,9 +886,7 @@ gc_gms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
/* Update some stats */
interp->gc_sys->stats.header_allocs_since_last_collect = 0;
interp->gc_sys->stats.mem_used_last_collect = 0;

self->gc_mark_block_level--;

/* We swept all dead objects */
self->num_early_gc_PMCs = 0;

Expand Down Expand Up @@ -1113,7 +1111,16 @@ gc_gms_sweep_pools(PARROT_INTERP, ARGMOD(MarkSweep_GC *self))
/* Don't move to generation beyond last */
const int move_to_old = (i + 1) != MAX_GENERATIONS;

POINTER_ARRAY_ITER(self->objects[i],
/* expanded POINTER_ARRAY_ITER(self->objects[i], */
size_t _i;
for (_i = 0; _i < (self->objects[i])->total_chunks; _i++) {
Parrot_Pointer_Array_Chunk *chunk = (self->objects[i])->chunks[_i];
size_t _j;
for (_j = 0; _j < CELL_PER_CHUNK - chunk->num_free; _j++) {
void *ptr = chunk->data[_j];
if ((ptrcast_t)(ptr) & 1)
continue;
{
pmc_alloc_struct * const item = (pmc_alloc_struct *)ptr;
PMC * const pmc = &(item->pmc);

Expand All @@ -1132,12 +1139,13 @@ gc_gms_sweep_pools(PARROT_INTERP, ARGMOD(MarkSweep_GC *self))
if (PObj_GC_soil_root_TEST(pmc)) {
item->ptr = Parrot_pa_insert(self->dirty_list, item);
PObj_GC_soil_root_CLEAR(pmc);
/* !! valgrind unitialized, stack allocation in runops */
PObj_GC_on_dirty_list_SET(pmc);
GC_DEBUG_DETAIL_FLAGS("GC ->dirty ", pmc);
}
else {
item->ptr = Parrot_pa_insert(self->objects[i + 1], item);
/* gc_gms_seal_object(interp, pmc); */
/* inlined gc_gms_seal_object(interp, pmc); */
PObj_GC_need_write_barrier_SET(pmc);
}
}
Expand All @@ -1160,7 +1168,10 @@ gc_gms_sweep_pools(PARROT_INTERP, ARGMOD(MarkSweep_GC *self))
PObj_gc_CLEAR(pmc);

Parrot_gc_pool_free(interp, self->pmc_allocator, ptr);
});
}/*);*/
}
}
}

POINTER_ARRAY_ITER(self->strings[i],
string_alloc_struct * const item = (string_alloc_struct *)ptr;
Expand Down Expand Up @@ -1233,7 +1244,10 @@ gc_gms_mark_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
/* mark it live. */
PObj_live_SET(pmc);

PARROT_ASSERT(self->work_list);
/* empty work_list. not from last gc_gms_validate_objects in m&s */
if (!self->work_list)
self->work_list = Parrot_pa_new(interp);
/* PARROT_ASSERT(self->work_list); */
Parrot_pa_remove(interp, self->objects[gen], item->ptr);
item->ptr = Parrot_pa_insert(self->work_list, item);
}
Expand Down Expand Up @@ -2103,7 +2117,7 @@ gc_gms_write_barrier(PARROT_INTERP, ARGMOD(PMC *pmc))

PObj_GC_on_dirty_list_SET(pmc);
/* We don't need it anymore */
/* gc_gms_unseal_object(interp, pmc); */
/* inlined gc_gms_unseal_object(interp, pmc); */
PObj_GC_need_write_barrier_CLEAR(pmc);
}

Expand Down Expand Up @@ -2280,26 +2294,38 @@ gc_gms_check_sanity(PARROT_INTERP)
size_t i;

for (i = 0; i < MAX_GENERATIONS; i++) {
POINTER_ARRAY_ITER(self->objects[i],
PMC *pmc = &(((pmc_alloc_struct*)ptr)->pmc);
const size_t gen = POBJ2GEN(pmc);
PARROT_GC_ASSERT_INTERP(pmc, interp);
if (i < 3) { /* too many objects in gen3 */
GC_DEBUG_DETAIL_1_FLAGS("GC live gen %ld ", gen, pmc);
}
if (gen != i) {
fprintf(stderr, "GC live gen %ld != %ld ", gen, i);
trace_pmc_dump(interp, pmc);
fprintf(stderr, "\n");
/* expanded POINTER_ARRAY_ITER(self->objects[i], */
size_t _i;
for (_i = 0; _i < (self->objects[i])->total_chunks; _i++) {
Parrot_Pointer_Array_Chunk *chunk = (self->objects[i])->chunks[_i];
size_t _j;
for (_j = 0; _j < CELL_PER_CHUNK - chunk->num_free; _j++) {
void *ptr = chunk->data[_j];
if ((ptrcast_t)(ptr) & 1)
continue;
{
PMC *pmc = &(((pmc_alloc_struct*)ptr)->pmc);
/* !! valgrind uninitialized stack allocated in runops */
const size_t gen = POBJ2GEN(pmc);
PARROT_GC_ASSERT_INTERP(pmc, interp);
if (i < 3) { /* too many objects in gen3 */
GC_DEBUG_DETAIL_1_FLAGS("GC live gen "SIZE_FMT" ", gen, pmc);
}
if (gen != i) {
fprintf(stderr, "GC live gen "SIZE_FMT" != "SIZE_FMT" ", gen, i);
trace_pmc_dump(interp, pmc);
fprintf(stderr, "\n");
}
PARROT_ASSERT((gen == i) || !PObj_GC_on_dirty_list_TEST(pmc)
|| !"Dirty live object from wrong generation");
PARROT_ASSERT((gen == i)
|| !"Object from wrong generation");
if (i)
PARROT_ASSERT(PObj_GC_need_write_barrier_TEST(pmc)
|| !"Unsealed object in old generation");
}
}
/*PARROT_ASSERT((gen == i) || !PObj_GC_on_dirty_list_TEST(pmc)
|| !"Dirty live object from wrong generation");*/
PARROT_ASSERT((gen == i) || (pmc->vtable->base_type == enum_class_Coroutine)
|| !"Object from wrong generation");

if (i)
PARROT_ASSERT(PObj_GC_need_write_barrier_TEST(pmc)
|| !"Unsealed object in old generation"););
}

POINTER_ARRAY_ITER(self->strings[i],
STRING *str = &(((string_alloc_struct*)ptr)->str);
Expand Down

0 comments on commit b4dae7b

Please sign in to comment.