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

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Jun 5 00:11:58 UTC 2010


Author: bacek
Date: Sat Jun  5 00:11:58 2010
New Revision: 47363
URL: https://trac.parrot.org/parrot/changeset/47363

Log:
Factor out gc_ms2_sweep_pool helper function.

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	Sat Jun  5 00:11:46 2010	(r47362)
+++ branches/gc_massacre/src/gc/gc_ms2.c	Sat Jun  5 00:11:58 2010	(r47363)
@@ -188,6 +188,13 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*str);
 
+static void gc_ms2_sweep_pool(PARROT_INTERP,
+    ARGIN(Pool_Allocator *pool),
+    ARGIN(Linked_List *list))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
 static void gc_ms2_unblock_GC_mark(PARROT_INTERP)
         __attribute__nonnull__(1);
 
@@ -261,6 +268,10 @@
 #define ASSERT_ARGS_gc_ms2_reallocate_string_storage \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(str))
+#define ASSERT_ARGS_gc_ms2_sweep_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(pool) \
+    , PARROT_ASSERT_ARG(list))
 #define ASSERT_ARGS_gc_ms2_unblock_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms2_unblock_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -678,15 +689,15 @@
     counter = 0;
     while (tmp) {
         List_Item_Header *next = tmp->next;
-        PMC              *pmc  = LLH2Obj_typed(tmp, PMC);
-        if (PObj_live_TEST(pmc)) {
+        PObj             *obj  = LLH2Obj_typed(tmp, PObj);
+        if (PObj_live_TEST(obj)) {
             /* Paint live objects white */
-            PObj_live_CLEAR(pmc);
+            PObj_live_CLEAR(obj);
         }
-        else if (!PObj_constant_TEST(pmc)) {
-            PObj_on_free_list_SET(pmc);
-            LIST_REMOVE(self->objects, tmp);
-            Parrot_gc_pool_free(self->pmc_allocator, tmp);
+        else if (!PObj_constant_TEST(obj)) {
+            PObj_on_free_list_SET(obj);
+            LIST_REMOVE(self->objects, obj);
+            Parrot_gc_pool_free(self->pmc_allocator, obj);
         }
         tmp = next;
         ++counter;
@@ -759,6 +770,35 @@
 }
 
 /*
+=item C<static void gc_ms2_sweep_pool(PARROT_INTERP, Pool_Allocator *pool,
+Linked_List *list)>
+
+Helper function to sweep pool.
+
+=cut
+*/
+static void
+gc_ms2_sweep_pool(PARROT_INTERP, ARGIN(Pool_Allocator *pool), ARGIN(Linked_List *list))
+{
+    ASSERT_ARGS(gc_ms2_sweep_pool);
+    tmp = list->first;
+    while (tmp) {
+        List_Item_Header *next = tmp->next;
+        PObj             *obj  = LLH2Obj_typed(tmp, PObj);
+        if (PObj_live_TEST(obj)) {
+            /* Paint live objects white */
+            PObj_live_CLEAR(obj);
+        }
+        else if (!PObj_constant_TEST(obj)) {
+            PObj_on_free_list_SET(obj);
+            LIST_REMOVE(list, obj);
+            Parrot_gc_pool_free(pool, obj);
+        }
+        tmp = next;
+    }
+}
+
+/*
 =item C<static int gc_ms2_is_ptr_owned(PARROT_INTERP, void *ptr, Pool_Allocator
 *pool, Linked_List *list)>
 


More information about the parrot-commits mailing list