[svn:parrot] r40383 - trunk/src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sun Aug 2 13:37:08 UTC 2009
Author: whiteknight
Date: Sun Aug 2 13:37:07 2009
New Revision: 40383
URL: https://trac.parrot.org/parrot/changeset/40383
Log:
[TT #895] initialize PMC attribute structures on suggestion from NotFound++. Cleanup some unused structure fields.
Modified:
trunk/src/gc/api.c
trunk/src/gc/gc_private.h
trunk/src/gc/mark_sweep.c
Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c Sun Aug 2 13:35:33 2009 (r40382)
+++ trunk/src/gc/api.c Sun Aug 2 13:37:07 2009 (r40383)
@@ -1688,6 +1688,7 @@
PMC_Attribute_Pool * const pool = Parrot_gc_get_attribute_pool(interp,
attr_size);
void * const attrs = Parrot_gc_get_attributes_from_pool(interp, pool);
+ memset(attrs, 0, size);
PMC_data(pmc) = attrs;
return attrs;
}
Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h Sun Aug 2 13:35:33 2009 (r40382)
+++ trunk/src/gc/gc_private.h Sun Aug 2 13:37:07 2009 (r40383)
@@ -38,7 +38,7 @@
/* these values are used for the attribute allocator */
#define GC_ATTRIB_POOLS_HEADROOM 8
-#define GC_ATTRIBS_INITIAL_ALLOC 128
+#define GC_FIXED_SIZE_POOL_SIZE 4096
/* 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
@@ -65,11 +65,8 @@
} PMC_Attribute_Free_List;
typedef struct PMC_Attribute_Arena {
- size_t used;
- size_t total_objects;
struct PMC_Attribute_Arena * next;
struct PMC_Attribute_Arena * prev;
- void *start_objects;
} PMC_Attribute_Arena;
#if PARROT_GC_GMS
Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c Sun Aug 2 13:35:33 2009 (r40382)
+++ trunk/src/gc/mark_sweep.c Sun Aug 2 13:37:07 2009 (r40383)
@@ -1269,24 +1269,20 @@
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;
- PMC_Attribute_Free_List * next;
+ PMC_Attribute_Free_List *list, *next, *first;
PMC_Attribute_Arena * const new_arena = (PMC_Attribute_Arena *)mem_internal_allocate(
sizeof (PMC_Attribute_Arena) + (pool->attr_size * num_items));
- new_arena->used = 0;
- new_arena->total_objects = num_items;
new_arena->prev = NULL;
new_arena->next = pool->top_arena;
pool->top_arena = new_arena;
- next = (PMC_Attribute_Free_List *)(new_arena + 1);
- new_arena->start_objects = next;
+ first = next = (PMC_Attribute_Free_List *)(new_arena + 1);
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;
- pool->free_list = (PMC_Attribute_Free_List *)new_arena->start_objects;
+ pool->free_list = first;
pool->total_objects += num_items;
}
@@ -1329,10 +1325,14 @@
Parrot_gc_create_attrib_pool(PARROT_INTERP, size_t attrib_size)
{
ASSERT_ARGS(Parrot_gc_create_attrib_pool)
+ const size_t num_objs_raw =
+ (GC_FIXED_SIZE_POOL_SIZE - sizeof (PMC_Attribute_Arena)) / attrib_size;
+ const size_t num_objs = (num_objs_raw == 0)?(1):(num_objs_raw);
PMC_Attribute_Pool * const newpool = mem_internal_allocate_typed(PMC_Attribute_Pool);
+ fprintf(stderr, "Pool %d: %d objs\n", attrib_size, num_objs);
newpool->attr_size = attrib_size;
newpool->total_objects = 0;
- newpool->objects_per_alloc = GC_ATTRIBS_INITIAL_ALLOC;
+ newpool->objects_per_alloc = num_objs;
newpool->num_free_objects = 0;
newpool->free_list = NULL;
newpool->top_arena = NULL;
More information about the parrot-commits
mailing list