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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Wed Aug 11 08:08:49 UTC 2010


Author: chromatic
Date: Wed Aug 11 08:08:49 2010
New Revision: 48416
URL: https://trac.parrot.org/parrot/changeset/48416

Log:
[GC] Removed the non-lazy allocator.

The lazy allocator has been the default for a year.

Modified:
   trunk/src/gc/gc_ms.c
   trunk/src/gc/gc_private.h
   trunk/src/gc/mark_sweep.c

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Wed Aug 11 08:08:44 2010	(r48415)
+++ trunk/src/gc/gc_ms.c	Wed Aug 11 08:08:49 2010	(r48416)
@@ -830,7 +830,6 @@
     ASSERT_ARGS(Parrot_gc_get_attributes_from_pool)
     PMC_Attribute_Free_List *item;
 
-#if GC_USE_LAZY_ALLOCATOR
     if (pool->free_list) {
         item            = pool->free_list;
         pool->free_list = item->next;
@@ -846,12 +845,6 @@
         Parrot_gc_allocate_new_attributes_arena(pool);
         return Parrot_gc_get_attributes_from_pool(interp, pool);
     }
-#else
-    if (pool->free_list == NULL)
-        Parrot_gc_allocate_new_attributes_arena(pool);
-    item            = pool->free_list;
-    pool->free_list = item->next;
-#endif
 
     --pool->num_free_objects;
     return (void *)item;
@@ -877,18 +870,8 @@
     pool->top_arena = new_arena;
     next            = (PMC_Attribute_Free_List *)(new_arena + 1);
 
-#if GC_USE_LAZY_ALLOCATOR
     pool->newfree   = next;
     pool->newlast   = (PMC_Attribute_Free_List *)((char *)next + item_space);
-#else
-    pool->free_list = next;
-    for (i = 0; i < num_items; ++i) {
-        list        = next;
-        list->next  = (PMC_Attribute_Free_List *)((char *)list + item_size);
-        next        = list->next;
-    }
-    list->next      = pool->free_list;
-#endif
 
     pool->num_free_objects += num_items;
     pool->total_objects    += num_items;
@@ -986,18 +969,12 @@
 {
     ASSERT_ARGS(gc_ms_allocate_pmc_attributes)
     const size_t attr_size = pmc->vtable->attr_size;
-#if GC_USE_FIXED_SIZE_ALLOCATOR
     PMC_Attribute_Pool * const pool = Parrot_gc_get_attribute_pool(interp,
             interp->mem_pools, attr_size);
     void * const attrs = Parrot_gc_get_attributes_from_pool(interp, pool);
     memset(attrs, 0, attr_size);
     PMC_data(pmc) = attrs;
     return attrs;
-#else
-    void * const data =  gc_ms_allocate_memory_chunk(attr_size);
-    PMC_data(pmc) = data;
-    return data;
-#endif
 }
 
 /*
@@ -1016,17 +993,11 @@
     void * const data = PMC_data(pmc);
 
     if (data) {
-
-#if GC_USE_FIXED_SIZE_ALLOCATOR
         const size_t attr_size = pmc->vtable->attr_size;
         const size_t item_size = attr_size < sizeof (void *) ? sizeof (void *) : attr_size;
         PMC_Attribute_Pool ** const pools = interp->mem_pools->attrib_pools;
         const size_t idx = item_size - sizeof (void *);
         gc_ms_free_attributes_from_pool(pools[idx], data);
-#else
-        gc_ms_free_memory_chunk(intepr, PMC_data(pmc));
-        PMC_data(pmc) = NULL;
-#endif
     }
 }
 
@@ -1533,14 +1504,9 @@
 
     /* requires that num_free_objects be updated in Parrot_gc_mark_and_sweep.
        If gc is disabled, then we must check the free list directly. */
-#if GC_USE_LAZY_ALLOCATOR
     if ((!pool->free_list || pool->num_free_objects < pool->replenish_level)
         && !pool->newfree)
         (*pool->alloc_objects) (interp, interp->mem_pools, pool);
-#else
-    if (!pool->free_list || pool->num_free_objects < pool->replenish_level)
-    (*pool->alloc_objects) (interp, interp->mem_pools, pool);
-#endif
 }
 
 /*
@@ -1595,8 +1561,6 @@
     PObj *ptr;
     PObj *free_list = (PObj *)pool->free_list;
 
-#if GC_USE_LAZY_ALLOCATOR
-
   HAVE_FREE:
     if (free_list) {
         ptr             = free_list;
@@ -1618,16 +1582,6 @@
         free_list = (PObj *)pool->free_list;
         goto HAVE_FREE;
     }
-#else
-    /* if we don't have any objects */
-    if (!free_list) {
-        (*pool->more_objects)(interp, mem_pools, pool);
-        free_list = (PObj *)pool->free_list;
-    }
-
-    ptr             = free_list;
-    pool->free_list = ((GC_MS_PObj_Wrapper*)ptr)->next_ptr;
-#endif
 
     --pool->num_free_objects;
 

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Wed Aug 11 08:08:44 2010	(r48415)
+++ trunk/src/gc/gc_private.h	Wed Aug 11 08:08:49 2010	(r48416)
@@ -60,12 +60,6 @@
 #define GC_ATTRIB_POOLS_HEADROOM 8
 #define GC_FIXED_SIZE_POOL_SIZE 4096
 
-/* Use the lazy allocator. Since it amortizes arena allocation costs, turn
-   this on at the same time that you increase the size of allocated arenas.
-   increase *_HEADERS_PER_ALLOC and GC_FIXED_SIZE_POOL_SIZE to be large
-   enough to satisfy most startup costs. */
-#define GC_USE_LAZY_ALLOCATOR 1
-
 /* Set to 1 if we want to use the fixed-size allocator. Set to 0 if we want
    to allocate these things using mem_sys_allocate instead */
 #define GC_USE_FIXED_SIZE_ALLOCATOR 1
@@ -209,12 +203,10 @@
     size_t total_objects;
     size_t objects_per_alloc;
     size_t num_free_objects;
-    PMC_Attribute_Free_List * free_list;
-    PMC_Attribute_Arena     * top_arena;
-#if GC_USE_LAZY_ALLOCATOR
-    PMC_Attribute_Free_List * newfree;
-    PMC_Attribute_Free_List * newlast;
-#endif
+    PMC_Attribute_Arena     *top_arena;
+    PMC_Attribute_Free_List *free_list;
+    PMC_Attribute_Free_List *newfree;
+    PMC_Attribute_Free_List *newlast;
 } PMC_Attribute_Pool;
 
 /* Tracked resource pool */
@@ -255,11 +247,8 @@
     } gc_private;
     */
 
-#if GC_USE_LAZY_ALLOCATOR
     void *newfree;
     void *newlast;
-#endif
-
 } Fixed_Size_Pool;
 
 typedef struct Memory_Pools {

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Wed Aug 11 08:08:44 2010	(r48415)
+++ trunk/src/gc/mark_sweep.c	Wed Aug 11 08:08:49 2010	(r48416)
@@ -425,7 +425,6 @@
 
     pool->total_objects += num_objects;
     object = (void *)arena->start_objects;
-#if GC_USE_LAZY_ALLOCATOR
     /* Don't move anything onto the free list. Set the pointers and do it
        lazily when we allocate. */
     {
@@ -434,14 +433,7 @@
         pool->newlast = (void*)((char*)object + total_size);
         arena->used = 0;
     }
-#else
-    /* Move all the new objects into the free list */
-    arena->used          = num_objects;
-    for (i = 0; i < num_objects; ++i) {
-        pool->add_free_object(interp, pool, object);
-        object = (void *)((char *)object + pool->object_size);
-    }
-#endif
+
     pool->num_free_objects += num_objects;
 }
 
@@ -609,12 +601,10 @@
     pool->last_Arena        = NULL;
     pool->free_list         = NULL;
     pool->mem_pool          = NULL;
-    pool->object_size       = object_size;
-    pool->objects_per_alloc = objects_per_alloc;
-#if GC_USE_LAZY_ALLOCATOR
     pool->newfree           = NULL;
     pool->newlast           = NULL;
-#endif
+    pool->object_size       = object_size;
+    pool->objects_per_alloc = objects_per_alloc;
 
     return pool;
 }


More information about the parrot-commits mailing list