[svn:parrot] r48798 - branches/gc_massacre/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Sun Sep 5 13:13:07 UTC 2010


Author: bacek
Date: Sun Sep  5 13:13:07 2010
New Revision: 48798
URL: https://trac.parrot.org/parrot/changeset/48798

Log:
Add preliminary support for 'lazy' GC

Modified:
   branches/gc_massacre/src/gc/gc_ms2.c

Modified: branches/gc_massacre/src/gc/gc_ms2.c
==============================================================================
--- branches/gc_massacre/src/gc/gc_ms2.c	Sun Sep  5 13:12:42 2010	(r48797)
+++ branches/gc_massacre/src/gc/gc_ms2.c	Sun Sep  5 13:13:07 2010	(r48798)
@@ -45,6 +45,8 @@
     UINTVAL gc_sweep_block_level; /* How many outstanding GC block
                                      requests are there? */
 
+    UINTVAL num_early_gc_PMCs;    /* how many PMCs want immediate destruction */
+
 } MarkSweep_GC;
 
 /* Callback to destroy PMC or free string storage */
@@ -135,7 +137,9 @@
 static void gc_ms2_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
         __attribute__nonnull__(1);
 
-static size_t gc_ms2_get_gc_info(SHIM_INTERP, SHIM(Interpinfo_enum what));
+static size_t gc_ms2_get_gc_info(PARROT_INTERP, Interpinfo_enum which)
+        __attribute__nonnull__(1);
+
 static unsigned int gc_ms2_is_blocked_GC_mark(PARROT_INTERP)
         __attribute__nonnull__(1);
 
@@ -166,6 +170,12 @@
 static void gc_ms2_mark_pobj_header(PARROT_INTERP, ARGIN_NULLOK(PObj * obj))
         __attribute__nonnull__(1);
 
+static void gc_ms2_pmc_needs_early_collection(PARROT_INTERP,
+    ARGMOD(PMC *pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pmc);
+
 static void gc_ms2_reallocate_buffer_storage(SHIM_INTERP,
     ARGMOD(Buffer *buffer),
     size_t size)
@@ -255,7 +265,8 @@
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms2_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_gc_ms2_get_gc_info __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_gc_ms2_get_gc_info __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms2_is_blocked_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms2_is_blocked_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -275,6 +286,10 @@
     , PARROT_ASSERT_ARG(pmc))
 #define ASSERT_ARGS_gc_ms2_mark_pobj_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms2_pmc_needs_early_collection \
+     __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(buffer))
@@ -523,6 +538,10 @@
 {
     ASSERT_ARGS(gc_ms2_get_gc_info)
     MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+
+    if (which == IMPATIENT_PMCS)
+        return self->num_early_gc_PMCs;
+
     return Parrot_gc_get_info(interp, which, &self->stats);
 }
 
@@ -558,8 +577,8 @@
 
     /*
     interp->gc_sys->mark_special                = gc_ms2_mark_special;
-    interp->gc_sys->pmc_needs_early_collection  = gc_ms2_pmc_needs_early_collection;
     */
+    interp->gc_sys->pmc_needs_early_collection  = gc_ms2_pmc_needs_early_collection;
 
     interp->gc_sys->allocate_pmc_header     = gc_ms2_allocate_pmc_header;
     interp->gc_sys->free_pmc_header         = gc_ms2_free_pmc_header;
@@ -1154,6 +1173,24 @@
 }
 
 
+/*
+
+=item C<void gc_ms_pmc_needs_early_collection(PARROT_INTERP, PMC *pmc)>
+
+Mark a PMC as needing timely destruction
+
+=cut
+
+*/
+
+static void
+gc_ms2_pmc_needs_early_collection(PARROT_INTERP, ARGMOD(PMC *pmc))
+{
+    ASSERT_ARGS(gc_ms2_pmc_needs_early_collection)
+    MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
+    ++self->num_early_gc_PMCs;
+}
+
 
 /*
 


More information about the parrot-commits mailing list