Skip to content

Commit

Permalink
Allocate the array_bounds array in chunks of 128, so we aren't doing …
Browse files Browse the repository at this point in the history
…a realloc on every arena allocation
  • Loading branch information
Whiteknight committed Sep 4, 2011
1 parent 1b0e041 commit 3f42979
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gc/fixed_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ allocate_new_pool_arena(PARROT_INTERP, ARGMOD(Pool_Allocator *pool))

pool->num_arenas++;
if (pool->arena_bounds == NULL)
pool->arena_bounds = mem_sys_allocate(2 * pool->num_arenas * sizeof (void*));
else
pool->arena_bounds = mem_sys_realloc(pool->arena_bounds, 2 * pool->num_arenas * sizeof (void*));
pool->arena_bounds = mem_sys_allocate(NEXT_ARENA_BOUNDS_SIZE(0));
else if (pool->num_arenas % ARENA_BOUNDS_PADDING == 0)
pool->arena_bounds = mem_sys_realloc(pool->arena_bounds, NEXT_ARENA_BOUNDS_SIZE(pool->num_arenas));
{
size_t ptr_idx = (pool->num_arenas - 1) * 2;
pool->arena_bounds[ptr_idx] = (size_t) (new_arena + 1);
Expand Down
3 changes: 3 additions & 0 deletions src/gc/fixed_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ src/gc/fixed_allocator.h - implementation of allocator for small-size objects.
increase *_HEADERS_PER_ALLOC and GC_FIXED_SIZE_POOL_SIZE to be large
enough to satisfy most startup costs. */

#define ARENA_BOUNDS_PADDING 128
#define NEXT_ARENA_BOUNDS_SIZE(n) (2 * ((n) + ARENA_BOUNDS_PADDING) * sizeof (void*))

typedef struct Pool_Allocator_Free_List {
struct Pool_Allocator_Free_List * next;
} Pool_Allocator_Free_List;
Expand Down

0 comments on commit 3f42979

Please sign in to comment.