[svn:parrot] r38836 - trunk/src/gc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat May 16 20:15:09 UTC 2009


Author: whiteknight
Date: Sat May 16 20:15:09 2009
New Revision: 38836
URL: https://trac.parrot.org/parrot/changeset/38836

Log:
[gc] move a few more functions around, a few funcs that don't need to be in the MS core. Start fixing up the documentation

Modified:
   trunk/src/gc/gc_private.h
   trunk/src/gc/incremental_ms.c
   trunk/src/gc/mark_sweep.c
   trunk/src/gc/pools.c

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Sat May 16 20:11:34 2009	(r38835)
+++ trunk/src/gc/gc_private.h	Sat May 16 20:15:09 2009	(r38836)
@@ -352,6 +352,16 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+void Parrot_gc_free_pmc(PARROT_INTERP,
+    SHIM(Small_Object_Pool *pool),
+    ARGMOD(PObj *p))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*p);
+
+void Parrot_gc_run_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
 void Parrot_gc_sweep(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -397,6 +407,11 @@
 #define ASSERT_ARGS_Parrot_gc_clear_live_bits __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_Parrot_gc_free_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(p)
+#define ASSERT_ARGS_Parrot_gc_run_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_gc_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pool)
@@ -704,33 +719,13 @@
         __attribute__nonnull__(1)
         FUNC_MODIFIES(*pool);
 
-void Parrot_gc_ms_free_pmc(PARROT_INTERP,
-    SHIM(Small_Object_Pool *pool),
-    ARGMOD(PObj *p))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*p);
-
 void Parrot_gc_ms_init(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void Parrot_gc_ms_run(PARROT_INTERP, UINTVAL flags)
-        __attribute__nonnull__(1);
-
-void Parrot_gc_ms_run_init(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
 #define ASSERT_ARGS_gc_pmc_ext_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_Parrot_gc_ms_free_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(p)
 #define ASSERT_ARGS_Parrot_gc_ms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ms_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ms_run_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/gc_ms.c */
 

Modified: trunk/src/gc/incremental_ms.c
==============================================================================
--- trunk/src/gc/incremental_ms.c	Sat May 16 20:11:34 2009	(r38835)
+++ trunk/src/gc/incremental_ms.c	Sat May 16 20:15:09 2009	(r38836)
@@ -697,7 +697,7 @@
     Arenas * const  arena_base = interp->arena_base;
 
     arena_base->lazy_gc = 0;
-    Parrot_gc_ms_run_init(interp);
+    Parrot_gc_run_init(interp);
 
     /*
      * trace root set w/o system areas

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Sat May 16 20:11:34 2009	(r38835)
+++ trunk/src/gc/mark_sweep.c	Sat May 16 20:15:09 2009	(r38836)
@@ -44,6 +44,29 @@
 
 /*
 
+=item C<void Parrot_gc_run_init(PARROT_INTERP)>
+
+Prepares the collector for a mark & sweep GC run. This is the
+initializer function for the MS garbage collector.
+
+=cut
+
+*/
+
+void
+Parrot_gc_run_init(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_gc_run_init)
+    Arenas * const arena_base       = interp->arena_base;
+
+    arena_base->gc_trace_ptr        = NULL;
+    arena_base->gc_mark_start       = NULL;
+    arena_base->num_early_PMCs_seen = 0;
+    arena_base->num_extended_PMCs   = 0;
+}
+
+/*
+
 =item C<int Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)>
 
 Traces the root set. Returns 0 if it's a lazy GC run and all objects
@@ -165,7 +188,45 @@
     return 1;
 }
 
+/*
+
+=item C<void Parrot_ms_free_pmc(PARROT_INTERP, Small_Object_Pool *pool, PObj
+*p)>
+
+Frees a PMC that is no longer being used. Calls a custom C<destroy> VTABLE
+method if one is available. If the PMC uses a PMC_EXT structure, that is freed
+as well.
 
+=cut
+
+*/
+
+void
+Parrot_gc_free_pmc(PARROT_INTERP, SHIM(Small_Object_Pool *pool),
+        ARGMOD(PObj *p))
+{
+    ASSERT_ARGS(Parrot_gc_free_pmc)
+    PMC    * const pmc        = (PMC *)p;
+    Arenas * const arena_base = interp->arena_base;
+
+    /* TODO collect objects with finalizers */
+    if (PObj_needs_early_gc_TEST(p))
+        --arena_base->num_early_gc_PMCs;
+
+    if (PObj_active_destroy_TEST(p))
+        VTABLE_destroy(interp, pmc);
+
+    if (PObj_is_PMC_EXT_TEST(p))
+         Parrot_gc_free_pmc_ext(interp, pmc);
+
+#ifndef NDEBUG
+
+    pmc->pmc_ext     = (PMC_EXT *)0xdeadbeef;
+    pmc->vtable      = (VTABLE  *)0xdeadbeef;
+
+#endif
+
+}
 
 /*
 

Modified: trunk/src/gc/pools.c
==============================================================================
--- trunk/src/gc/pools.c	Sat May 16 20:11:34 2009	(r38835)
+++ trunk/src/gc/pools.c	Sat May 16 20:15:09 2009	(r38836)
@@ -145,7 +145,7 @@
         new_small_object_pool(sizeof (PMC), num_headers);
 
     pmc_pool->mem_pool   = NULL;
-    pmc_pool->gc_object  = Parrot_gc_ms_free_pmc;
+    pmc_pool->gc_object  = Parrot_gc_free_pmc;
 
     (interp->arena_base->init_pool)(interp, pmc_pool);
     return pmc_pool;


More information about the parrot-commits mailing list