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

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sun Aug 2 02:39:51 UTC 2009


Author: whiteknight
Date: Sun Aug  2 02:39:50 2009
New Revision: 40372
URL: https://trac.parrot.org/parrot/changeset/40372

Log:
[TT #895] If I had a dollar for every typo, I could afford to quite my job and work on Parrot full-time (where I would make even more typos, and thus, more money). This new attributes allocator now passes all tests that I have thrown at it locally

Modified:
   trunk/src/gc/api.c
   trunk/src/gc/mark_sweep.c

Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c	Sun Aug  2 02:33:48 2009	(r40371)
+++ trunk/src/gc/api.c	Sun Aug  2 02:39:50 2009	(r40372)
@@ -1687,6 +1687,7 @@
     PMC_Attribute_Pool * pool = Parrot_gc_get_attribute_pool(interp, attr_size);
     void * attrs = Parrot_gc_get_attributes_from_pool(interp, pool);
     PMC_data(pmc) = attrs;
+    pool->num_free_objects--;
     return attrs;
 }
 
@@ -1703,6 +1704,7 @@
         PMC_Attribute_Free_List * const item = (PMC_Attribute_Free_List *)data;
         item->next = pool->free_list;
         pool->free_list = item;
+        pool->num_free_objects++;
         PMC_data(pmc) = NULL;
     }
 }

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Sun Aug  2 02:33:48 2009	(r40371)
+++ trunk/src/gc/mark_sweep.c	Sun Aug  2 02:39:50 2009	(r40372)
@@ -1219,7 +1219,7 @@
 Parrot_gc_allocate_new_attributes_arena(PARROT_INTERP, ARGMOD(PMC_Attribute_Pool *pool))
 {
     ASSERT_ARGS(Parrot_gc_allocate_new_attributes_arena)
-    size_t const num_items = GC_ATTRIBS_INITIAL_ALLOC;
+    size_t const num_items = pool->objects_per_alloc;
     size_t const item_size = pool->attr_size;
     size_t i;
     PMC_Attribute_Free_List * list;
@@ -1231,16 +1231,16 @@
     new_arena->prev = NULL;
     new_arena->next = pool->top_arena;
     pool->top_arena = new_arena;
-    next = (PMC_Attribute_Free_List *)(pool + 1);
-    new_arena->start_objects = list;
+    next = (PMC_Attribute_Free_List *)(new_arena + 1);
+    new_arena->start_objects = next;
     for (i = 0; i < num_items; i++) {
         list = next;
         list->next = (PMC_Attribute_Free_List *)((char *)list + item_size);
         next = list->next;
     }
-    fprintf(stderr, "arena %d: %p - %p\n", item_size, new_arena->start_objects, list);
     list->next = pool->free_list;
     pool->free_list = (PMC_Attribute_Free_List *)new_arena->start_objects;
+    pool->total_objects += num_items;
 }
 
 PARROT_CANNOT_RETURN_NULL
@@ -1283,7 +1283,7 @@
     PMC_Attribute_Pool * const newpool = mem_internal_allocate_typed(PMC_Attribute_Pool);
     newpool->attr_size = attrib_size;
     newpool->total_objects = 0;
-    newpool->objects_per_alloc = 0;
+    newpool->objects_per_alloc = GC_ATTRIBS_INITIAL_ALLOC;
     newpool->num_free_objects = 0;
     newpool->free_list = NULL;
     newpool->top_arena = NULL;


More information about the parrot-commits mailing list