[svn:parrot] r40962 - in trunk: include/parrot src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Thu Sep 3 20:26:07 UTC 2009
Author: whiteknight
Date: Thu Sep 3 20:26:05 2009
New Revision: 40962
URL: https://trac.parrot.org/parrot/changeset/40962
Log:
Fix and enable the fixed-size object allocator on windows. Also, enable it on Linux. The problem was that I wasn't initializing the pools array properly, leaving the last item in the array non-null, which caused some issues later.
Modified:
trunk/include/parrot/gc_api.h
trunk/src/gc/mark_sweep.c
Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h Thu Sep 3 18:13:30 2009 (r40961)
+++ trunk/include/parrot/gc_api.h Thu Sep 3 20:26:05 2009 (r40962)
@@ -21,9 +21,9 @@
to allocate these things using mem_sys_allocate instead */
/* Disabled on Windows platforms until problems get fixed, TT #940 */
#if defined(_WIN32) || defined(_WIN64)
-# define GC_USE_FIXED_SIZE_ALLOCATOR 0
+# define GC_USE_FIXED_SIZE_ALLOCATOR 1
#else
-# define GC_USE_FIXED_SIZE_ALLOCATOR 0
+# define GC_USE_FIXED_SIZE_ALLOCATOR 1
#endif
/*
Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c Thu Sep 3 18:13:30 2009 (r40961)
+++ trunk/src/gc/mark_sweep.c Thu Sep 3 20:26:05 2009 (r40962)
@@ -1169,14 +1169,16 @@
{
ASSERT_ARGS(Parrot_gc_get_attributes_from_pool)
PMC_Attribute_Free_List *item;
-
if (pool->top_arena == NULL
+
#if GC_USE_LAZY_ALLOCATOR
|| (pool->newfree == NULL && pool->free_list == NULL))
#else
+
|| pool->free_list == NULL)
#endif
Parrot_gc_allocate_new_attributes_arena(interp, pool);
+
#if GC_USE_LAZY_ALLOCATOR
if (pool->newfree) {
@@ -1191,6 +1193,7 @@
pool->free_list = item->next;
}
#else
+
item = pool->free_list;
pool->free_list = item->next;
#endif
@@ -1246,6 +1249,7 @@
Parrot_gc_get_attribute_pool(PARROT_INTERP, size_t attrib_size)
{
ASSERT_ARGS(Parrot_gc_get_attribute_pool)
+
Arenas * const arenas = interp->arena_base;
PMC_Attribute_Pool ** pools = arenas->attrib_pools;
const size_t size = (attrib_size < sizeof (void *))?(sizeof (void *)):(attrib_size);
@@ -1253,7 +1257,7 @@
if (pools == NULL) {
const size_t total_length = idx + GC_ATTRIB_POOLS_HEADROOM;
- const size_t total_size = total_length * sizeof (void *);
+ const size_t total_size = (total_length + 1) * 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);
@@ -1261,7 +1265,7 @@
arenas->attrib_pools = pools;
arenas->num_attribs = total_length;
}
- if (arenas->num_attribs < idx) {
+ if (arenas->num_attribs <= idx) {
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;
More information about the parrot-commits
mailing list