Skip to content

Commit

Permalink
Expose compating of string pool via GC_Subsystem.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/gc_encapsulate@43748 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Feb 7, 2010
1 parent 29d72a8 commit 35253c8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gc/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void
Parrot_gc_compact_memory_pool(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_compact_memory_pool)
// XXX compact_pool(interp, interp->mem_pools->memory_pool);
interp->gc_sys->do_compact(interp);
}

/*
Expand Down
28 changes: 27 additions & 1 deletion src/gc/gc_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ static void gc_ms_block_gc_mark(PARROT_INTERP)
static void gc_ms_block_gc_sweep(PARROT_INTERP)
__attribute__nonnull__(1);

static void gc_ms_compact(PARROT_INTERP)
__attribute__nonnull__(1);

static void gc_ms_finalize(PARROT_INTERP,
ARGIN(Memory_Pools * const mem_pools))
__attribute__nonnull__(1)
Expand Down Expand Up @@ -188,6 +191,8 @@ static void Parrot_gc_free_attributes_from_pool(PARROT_INTERP,
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_block_gc_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_compact __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_finalize __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(mem_pools))
Expand Down Expand Up @@ -264,9 +269,11 @@ Parrot_gc_ms_init(PARROT_INTERP)
GC_Subsystem *gc = interp->gc_sys;

gc->init_child_interp = gc_ms_init_child_inter;
gc->do_gc_mark = gc_ms_mark_and_sweep;
gc->finalize_gc_system = NULL;

gc->do_gc_mark = gc_ms_mark_and_sweep;
gc->do_compact = gc_ms_compact;

gc->allocate_pmc_header = gc_ms_allocate_pmc_header;
gc->free_pmc_header = gc_ms_free_pmc_header;
gc->allocate_string_header = gc_ms_allocate_string_header;
Expand Down Expand Up @@ -418,6 +425,25 @@ gc_ms_finalize(PARROT_INTERP, ARGIN(Memory_Pools * const mem_pools))

/*
=item C<static void gc_ms_compact(PARROT_INTERP)>
Compact string pool.
=cut
*/

static void
gc_ms_compact(PARROT_INTERP)
{
ASSERT_ARGS(gc_ms_compact)
Memory_Pools * const mem_pools = (Memory_Pools*)interp->gc_sys->gc_private;
compact_pool(interp, mem_pools, mem_pools->memory_pool);
return;
}

/*
=item C<static PMC* gc_ms_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)>
=item C<static void gc_ms_free_pmc_header(PARROT_INTERP, PMC *pmc)>
Expand Down
3 changes: 3 additions & 0 deletions src/gc/gc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ typedef struct GC_Subsystem {
/* Run GC "mark" explicitely */
void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);

/* Compact string pool */
void (*do_compact)(PARROT_INTERP);

/* Allocation functions with explicit freeing counterparts */
PMC* (*allocate_pmc_header)(PARROT_INTERP, UINTVAL flags);
void (*free_pmc_header)(PARROT_INTERP, PMC *pmc);
Expand Down

0 comments on commit 35253c8

Please sign in to comment.