[svn:parrot] r49736 - branches/gc_ms2_sf/src/gc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Oct 30 23:06:06 UTC 2010


Author: chromatic
Date: Sat Oct 30 23:06:06 2010
New Revision: 49736
URL: https://trac.parrot.org/parrot/changeset/49736

Log:
[GC] Added GC list for constant PMCs.

Because constant PMCs only get swept away during global destruction, they don't
need to be swept at all--on creation, they get stored in a constant-specific
list for safekeeping.

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

Modified: branches/gc_ms2_sf/src/gc/gc_ms2.c
==============================================================================
--- branches/gc_ms2_sf/src/gc/gc_ms2.c	Sat Oct 30 23:06:03 2010	(r49735)
+++ branches/gc_ms2_sf/src/gc/gc_ms2.c	Sat Oct 30 23:06:06 2010	(r49736)
@@ -36,6 +36,9 @@
     /* Currently allocated objects */
     struct Linked_List    *objects;
 
+    /* Currently allocated constant objects */
+    struct Linked_List    *constants;
+
     /* During M&S gather new live objects in this list */
     struct Linked_List    *new_objects;
 
@@ -659,7 +662,8 @@
 
         self->pmc_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (PMC));
-        self->objects = Parrot_list_new(interp);
+        self->objects   = Parrot_list_new(interp);
+        self->constants = Parrot_list_new(interp);
 
         self->string_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (STRING));
@@ -696,6 +700,7 @@
         Parrot_gc_str_finalize(interp, &self->string_gc);
 
         Parrot_list_destroy(interp, self->objects);
+        Parrot_list_destroy(interp, self->constants);
         Parrot_list_destroy(interp, self->strings);
         Parrot_gc_pool_destroy(interp, self->pmc_allocator);
         Parrot_gc_pool_destroy(interp, self->string_allocator);
@@ -727,7 +732,12 @@
     interp->gc_sys->stats.mem_used_last_collect += sizeof (PMC);
 
     ptr = (List_Item_Header *)Parrot_gc_pool_allocate(interp, pool);
-    LIST_APPEND(self->objects, ptr);
+    if (flags & PObj_constant_FLAG) {
+        LIST_APPEND(self->constants, ptr);
+    }
+    else {
+        LIST_APPEND(self->objects, ptr);
+    }
 
     return LLH2Obj_typed(ptr, PMC);
 }
@@ -742,7 +752,10 @@
     if (pmc) {
         if (PObj_on_free_list_TEST(pmc))
             return;
-        Parrot_list_remove(interp, self->objects, Obj2LLH(pmc));
+        if (PObj_constant_TEST(pmc))
+            Parrot_list_remove(interp, self->constants, Obj2LLH(pmc));
+        else
+            Parrot_list_remove(interp, self->objects, Obj2LLH(pmc));
         PObj_on_free_list_SET(pmc);
 
         Parrot_pmc_destroy(interp, pmc);
@@ -780,6 +793,7 @@
     /* mark it live */
     PObj_live_SET(pmc);
 
+    /* there should be no constant PMCs to move here */
     LIST_REMOVE(self->objects, item);
     LIST_APPEND(self->new_objects, item);
 }
@@ -1159,8 +1173,9 @@
 
     /* destroy the rest */
     if (flags & GC_finish_FLAG) {
-        gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->objects);
         gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->new_objects);
+        gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->objects);
+        gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->constants);
     }
 
     /* Replace objects with new_objects. Ignoring "constant" one */
@@ -1206,7 +1221,7 @@
         if (PObj_live_TEST(obj))
             PObj_live_CLEAR(obj);
 
-        else if (!PObj_constant_TEST(obj)) {
+        else {
             LIST_REMOVE(list, tmp);
 
             Parrot_pmc_destroy(interp, (PMC *)obj);


More information about the parrot-commits mailing list