[svn:parrot] r49565 - branches/generational_gc/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Oct 18 11:03:35 UTC 2010
Author: bacek
Date: Mon Oct 18 11:03:34 2010
New Revision: 49565
URL: https://trac.parrot.org/parrot/changeset/49565
Log:
Add more self-checking functionality
Modified:
branches/generational_gc/src/gc/gc_ms2.c
Modified: branches/generational_gc/src/gc/gc_ms2.c
==============================================================================
--- branches/generational_gc/src/gc/gc_ms2.c Mon Oct 18 10:53:45 2010 (r49564)
+++ branches/generational_gc/src/gc/gc_ms2.c Mon Oct 18 11:03:34 2010 (r49565)
@@ -260,6 +260,10 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmc);
+static void gc_ms2_pmc_validate(PARROT_INTERP, ARGIN(PMC *pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
static void gc_ms2_reallocate_buffer_storage(PARROT_INTERP,
ARGIN(Buffer *str),
size_t size)
@@ -297,6 +301,10 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+static void gc_ms2_string_validate(PARROT_INTERP, ARGIN(STRING *s))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
static void gc_ms2_sweep_pmc_cb(PARROT_INTERP, ARGIN(PObj *obj))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -423,6 +431,9 @@
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_gc_ms2_pmc_validate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_gc_ms2_reallocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -444,6 +455,9 @@
#define ASSERT_ARGS_gc_ms2_string_mark_propagate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(s))
+#define ASSERT_ARGS_gc_ms2_string_validate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_gc_ms2_sweep_pmc_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(obj))
@@ -846,6 +860,51 @@
interp->gc_sys->mark_pmc_header = gc_ms2_mark_pmc_header;
gc_ms2_check_sanity(interp);
+
+
+ // DEBUG ONLY. Simple recursive check
+ interp->gc_sys->mark_pmc_header = gc_ms2_pmc_validate;
+ interp->gc_sys->mark_str_header = gc_ms2_string_validate;
+
+ for (i = 2; i > 0; i--) {
+ /* It can be our first move to this generation */
+ List_Item_Header *tmp = self->objects[i]->first;
+
+ /* We are "marking" this generation */
+ self->current_generation = i;
+
+ while (tmp) {
+ PMC *pmc = LLH2Obj_typed(tmp, PMC);
+ if (PObj_custom_mark_TEST(pmc))
+ VTABLE_mark(interp, pmc);
+
+ if (PMC_metadata(pmc))
+ Parrot_gc_mark_PMC_alive(interp, PMC_metadata(pmc));
+
+ tmp = tmp->next;
+ }
+ }
+
+ interp->gc_sys->mark_str_header = gc_ms2_mark_string_header;
+ interp->gc_sys->mark_pmc_header = gc_ms2_mark_pmc_header;
+
+}
+
+static void
+gc_ms2_pmc_validate(PARROT_INTERP, ARGIN(PMC *pmc))
+{
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ PARROT_ASSERT(pobj2gen(pmc) == self->current_generation
+ || !"Got object from wrong generation");
+ if (PObj_custom_mark_TEST(pmc))
+ VTABLE_mark(interp, pmc);
+}
+
+static void
+gc_ms2_string_validate(PARROT_INTERP, ARGIN(STRING *s))
+{
+ MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+ PARROT_ASSERT(pobj2gen(s) == self->current_generation);
}
/*
More information about the parrot-commits
mailing list