Skip to content

Commit

Permalink
[gc] add MEMORY_DEBUG support to the GMS gc
Browse files Browse the repository at this point in the history
fix and enable -DMEMORY_DEBUG for the GMS gc,
add DETAIL_MEMORY_DEBUG lines for all sanity checked PMCs,
and add a single MEMORY_DEBUG line when write_barrier'ing a PMC

we never caught up with the change from the List_Item_Header iterator
to POINTER_ARRAY_ITER.
Fixes GH issue #1073
  • Loading branch information
Reini Urban committed Jun 9, 2014
1 parent 8e173af commit 13ba440
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2014-06-17 release 6.5.0
- Core
+ Re-add -DMEMORY_DEBUG support to the new GMS GC [GH #1073]
- Build
+ Fixed wrong ICU header probes on multi-arch systems (debian) [GH #1014]
+ Fix opengl on bsd which does not have __APPLE__ defined as 0 [GH #1070]
Expand Down
1 change: 1 addition & 0 deletions config/gen/makefiles/root.in
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ src/gc/gc_gms$(O) : \
$(PARROT_H_HEADERS) \
src/gc/gc_gms.c \
$(INC_DIR)/pointer_array.h \
$(INC_DIR)/list.h \
src/gc/gc_private.h \
src/gc/fixed_allocator.h \
src/gc/variable_size_pool.h
Expand Down
53 changes: 31 additions & 22 deletions src/gc/gc_gms.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ TBD
#include "parrot/parrot.h"
#include "parrot/gc_api.h"
#include "parrot/pointer_array.h"
#include "parrot/list.h" /* only for MEMORY_DEBUG */
#include "gc_private.h"
#include "fixed_allocator.h"

Expand Down Expand Up @@ -2083,6 +2084,10 @@ gc_gms_write_barrier(PARROT_INTERP, ARGMOD(PMC *pmc))

PARROT_GC_ASSERT_INTERP(pmc, interp);

#ifdef MEMORY_DEBUG
fprintf(stderr, "GC WB pmc %-21s gen %ld at %p - %p\n",
pmc->vtable->whoami->strstart, gen, pmc, item->ptr);
#endif
Parrot_pa_remove(interp, self->objects[gen], item->ptr);
item->ptr = Parrot_pa_insert(self->dirty_list, item);

Expand Down Expand Up @@ -2171,19 +2176,13 @@ gc_gms_count_used_string_memory(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *list)
UNUSED(interp)
UNUSED(list)
#else
List_Item_Header *tmp = list->first;
while (tmp) {
List_Item_Header *next = tmp->next;
PObj *obj = LLH2Obj_typed(tmp, PObj);
STRING *str = (STRING*)obj;
POINTER_ARRAY_ITER(list,
string_alloc_struct * const item = (string_alloc_struct *)ptr;
STRING * const str = &(item->str);

/* Header size */
total_amount += sizeof (List_Item_Header)
+ sizeof (STRING*);
total_amount += str->bufused;

tmp = next;
}
total_amount += sizeof (string_alloc_struct);
total_amount += str->bufused;);
#endif
return total_amount;
}
Expand Down Expand Up @@ -2211,18 +2210,13 @@ gc_gms_count_used_pmc_memory(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *list))
UNUSED(interp)
UNUSED(list)
#else
List_Item_Header *tmp = list->first;
while (tmp) {
List_Item_Header *next = tmp->next;
PMC *obj = LLH2Obj_typed(tmp, PMC);
POINTER_ARRAY_ITER(list,
PMC *pmc = &(((pmc_alloc_struct*)ptr)->pmc);
PARROT_GC_ASSERT_INTERP(pmc, interp);

/* Header size */
total_amount += sizeof (List_Item_Header)
+ sizeof (PMC*);
total_amount += obj->vtable->attr_size;

tmp = next;
}
total_amount += sizeof (pmc_alloc_struct);
total_amount += pmc->vtable->attr_size;);
#endif
return total_amount;
}
Expand Down Expand Up @@ -2278,8 +2272,15 @@ gc_gms_check_sanity(PARROT_INTERP)
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);
PARROT_ASSERT((POBJ2GEN(pmc) == i)

# ifdef DETAIL_MEMORY_DEBUG
fprintf(stderr, "GC live pmc %-21s gen %ld at %p\n",
pmc->vtable->whoami->strstart, gen, pmc);
# endif

PARROT_ASSERT((gen == i)
|| !"Object from wrong generation");

if (i)
Expand All @@ -2295,12 +2296,20 @@ gc_gms_check_sanity(PARROT_INTERP)
POINTER_ARRAY_ITER(self->dirty_list,
PMC *pmc = &(((pmc_alloc_struct*)ptr)->pmc);
PARROT_GC_ASSERT_INTERP(pmc, interp);
# ifdef DETAIL_MEMORY_DEBUG
fprintf(stderr, "GC dirty pmc %-21s at %p\n",
pmc->vtable->whoami->strstart, pmc);
# endif
PARROT_ASSERT(PObj_GC_on_dirty_list_TEST(pmc)
|| !"Object in dirty_list without dirty_flag"););

POINTER_ARRAY_ITER(self->work_list,
PMC *pmc = &(((pmc_alloc_struct*)ptr)->pmc);
PARROT_GC_ASSERT_INTERP(pmc, interp);
# ifdef DETAIL_MEMORY_DEBUG
fprintf(stderr, "GC work pmc %-21s at %p\n",
pmc->vtable->whoami->strstart, pmc);
# endif
PARROT_ASSERT(!PObj_GC_on_dirty_list_TEST(pmc)
|| !"Dirty object in work_list"););
#endif
Expand Down

0 comments on commit 13ba440

Please sign in to comment.