Skip to content

Commit

Permalink
Add a GC debugging aid.
Browse files Browse the repository at this point in the history
Allows extra checks to be turned on that trap some bogus additions to
the GC worklist. Got tired of re-doing this each time I debugged GC
issues, so now it can be turned on with a #define.
  • Loading branch information
jnthn committed Aug 18, 2014
1 parent 63e1937 commit 12a0a5b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/gc/worklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,30 @@ struct MVMGCWorklist {
MVMuint8 include_gen2;
};

/* Turn this on to define a worklist addition that panics if it spots
* something untoward with an object being added to a worklist. */
#define MVM_GC_WORKLIST_DEBUG_ADD 0

/* Some macros for doing stuff fast with worklists, defined to look like
* functions since perhaps they become them in the future if needed. */
#if MVM_GC_WORKLIST_DEBUG_ADD
#define MVM_gc_worklist_add(tc, worklist, item) \
do { \
MVMCollectable **item_to_add = (MVMCollectable **)(item);\
if (*item_to_add) { \
if ((*item_to_add)->owner == 0) \
MVM_panic(1, "Zeroed owner in item added to GC worklist"); \
if ((*item_to_add)->flags & MVM_CF_STABLE == 0 && !STABLE(*item_to_add)) \
MVM_panic(1, "NULL STable in time added to GC worklist"); \
} \
if (*item_to_add && (worklist->include_gen2 || !((*item_to_add)->flags & MVM_CF_SECOND_GEN))) { \
if (worklist->items == worklist->alloc) \
MVM_gc_worklist_add_slow(tc, worklist, item_to_add); \
else \
worklist->list[worklist->items++] = item_to_add; \
} \
} while (0)
#else
#define MVM_gc_worklist_add(tc, worklist, item) \
do { \
MVMCollectable **item_to_add = (MVMCollectable **)(item);\
Expand All @@ -43,6 +65,7 @@ struct MVMGCWorklist {
worklist->list[worklist->items++] = item_to_add; \
} \
} while (0)
#endif

#define MVM_gc_worklist_add_frame(tc, worklist, frame) \
do { \
Expand Down

0 comments on commit 12a0a5b

Please sign in to comment.