[svn:parrot] r40743 - trunk/src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sun Aug 23 20:31:15 UTC 2009
Author: whiteknight
Date: Sun Aug 23 20:31:13 2009
New Revision: 40743
URL: https://trac.parrot.org/parrot/changeset/40743
Log:
[gc] enable the lazy allocator. Fix one bug in the lazy allocator where a new arena can potentially be allocated before the last arena has been completely allocated. Also, some cleanups for the fixed-size allocator (though that still is disabled by default)
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 Sun Aug 23 16:38:17 2009 (r40742)
+++ trunk/src/gc/gc_ms.c Sun Aug 23 20:31:13 2009 (r40743)
@@ -346,8 +346,11 @@
/* 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 (!pool->free_list
- || pool->num_free_objects < pool->replenish_level)
+ if ((!pool->free_list || pool->num_free_objects < pool->replenish_level)
+#if GC_USE_LAZY_ALLOCATOR
+ && !pool->newfree
+#endif
+ )
(*pool->alloc_objects) (interp, pool);
}
@@ -469,6 +472,8 @@
Parrot_append_arena_in_pool(interp, pool, new_arena, size);
+ PARROT_ASSERT(pool->last_Arena);
+
Parrot_add_to_free_list(interp, pool, new_arena);
/* Allocate more next time */
Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h Sun Aug 23 16:38:17 2009 (r40742)
+++ trunk/src/gc/gc_private.h Sun Aug 23 20:31:13 2009 (r40743)
@@ -68,7 +68,7 @@
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 0
+#define GC_USE_LAZY_ALLOCATOR 1
/* We're using this here to add an additional pointer to a PObj without
having to actually add an entire pointer to every PObj-alike structure
Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c Sun Aug 23 16:38:17 2009 (r40742)
+++ trunk/src/gc/mark_sweep.c Sun Aug 23 20:31:13 2009 (r40743)
@@ -1226,7 +1226,7 @@
ASSERT_ARGS(Parrot_gc_allocate_new_attributes_arena)
const size_t num_items = pool->objects_per_alloc;
const size_t item_size = pool->attr_size;
- const size_t total_size = sizeof (PMC_Attribute_Arena) + (pool->attr_size * num_items);
+ const size_t total_size = sizeof (PMC_Attribute_Arena) + (item_size * num_items);
size_t i;
PMC_Attribute_Free_List *list, *next, *first;
PMC_Attribute_Arena * const new_arena = (PMC_Attribute_Arena *)mem_internal_allocate(
@@ -1247,7 +1247,8 @@
list->next = pool->free_list;
pool->free_list = first;
#endif
- pool->total_objects += num_items;
+ pool->num_free_objects += num_items;
+ pool->total_objects += num_items;
}
PARROT_CANNOT_RETURN_NULL
@@ -1261,25 +1262,25 @@
const size_t idx = size - sizeof (void *);
if (pools == NULL) {
- const size_t total_size = idx + GC_ATTRIB_POOLS_HEADROOM;
+ const size_t total_length = idx + GC_ATTRIB_POOLS_HEADROOM;
+ const size_t total_size = total_length * sizeof (void *);
/* Allocate more then we strictly need, hoping that we can reduce the
number of resizes. 8 is just an arbitrary number */
- pools = (PMC_Attribute_Pool **)mem_internal_allocate(total_size
- * sizeof (PMC_Attribute_Pool *));
- memset(pools, 0, total_size * sizeof (void*));
+ pools = (PMC_Attribute_Pool **)mem_internal_allocate(total_size);
+ memset(pools, 0, total_size);
arenas->attrib_pools = pools;
- arenas->num_attribs = total_size;
+ arenas->num_attribs = total_length;
}
if (arenas->num_attribs < idx) {
- const size_t total_size = idx + GC_ATTRIB_POOLS_HEADROOM;
+ const size_t total_length = idx + GC_ATTRIB_POOLS_HEADROOM;
+ const size_t total_size = total_length * sizeof (void *);
const size_t current_size = arenas->num_attribs;
- const size_t diff = total_size - current_size;
+ const size_t diff = total_length - current_size;
- pools = (PMC_Attribute_Pool **)mem_internal_realloc(pools, total_size
- * sizeof (PMC_Attribute_Pool *));
+ pools = (PMC_Attribute_Pool **)mem_internal_realloc(pools, total_size);
memset(pools + current_size, 0, diff * sizeof (void *));
arenas->attrib_pools = pools;
- arenas->num_attribs = total_size;
+ arenas->num_attribs = total_length;
}
if (pools[idx] == NULL)
pools[idx] = Parrot_gc_create_attrib_pool(interp, size);
More information about the parrot-commits
mailing list