Skip to content

Commit

Permalink
[gc] initialize more stack-allocated ptrs
Browse files Browse the repository at this point in the history
see GH #1067.
initialize more values on the C-stack to help the GC.
also change some mem_internal_* to mem_sys_*
mem_internal_* are only macros to mem_sys now.

testcase:
  valgrind --track-origins=yes ./parrot_old examples/benchmarks/dispatch.pir

There's still a remaining stack-object scanned,
int offset from runops(src/call/ops.c),
which can only be fixed with a precise GC.
  • Loading branch information
Reini Urban committed Nov 6, 2014
1 parent 76e549e commit 0f6ddac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 4 additions & 8 deletions src/gc/fixed_allocator.c
Expand Up @@ -138,7 +138,6 @@ struct Fixed_Allocator*
Parrot_gc_fixed_allocator_new(SHIM_INTERP)
{
ASSERT_ARGS(Parrot_gc_fixed_allocator_new)

return mem_internal_allocate_zeroed_typed(Fixed_Allocator);
}

Expand Down Expand Up @@ -311,7 +310,7 @@ Parrot_gc_pool_new(SHIM_INTERP, size_t object_size)
newpool->newfree = NULL;
newpool->newlast = NULL;
newpool->num_arenas = 0;
newpool->arena_bounds = (void **)mem_sys_allocate(NEXT_ARENA_BOUNDS_SIZE(0));
newpool->arena_bounds = (void **)mem_sys_allocate_zeroed(NEXT_ARENA_BOUNDS_SIZE(0));

return newpool;
}
Expand All @@ -323,16 +322,13 @@ Parrot_gc_pool_destroy(SHIM_INTERP, ARGMOD(Pool_Allocator *pool))
ASSERT_ARGS(Parrot_gc_pool_destroy)

Pool_Allocator_Arena *arena = pool->top_arena;

while (arena) {
Pool_Allocator_Arena * const next = arena->next;
mem_internal_free(arena);
mem_sys_free(arena);
arena = next;
}

mem_sys_free(pool->arena_bounds);

mem_internal_free(pool);
mem_sys_free(pool);
}

PARROT_CANNOT_RETURN_NULL
Expand Down Expand Up @@ -544,7 +540,7 @@ allocate_new_pool_arena(PARROT_INTERP, ARGMOD(Pool_Allocator *pool))
/* Run a GC if needed */
Parrot_gc_maybe_mark_and_sweep(interp, GC_trace_stack_FLAG);

new_arena = (Pool_Allocator_Arena *)mem_internal_allocate_zeroed(total_size);
new_arena = (Pool_Allocator_Arena *)mem_sys_allocate_zeroed(total_size);

interp->gc_sys->stats.memory_allocated += total_size;

Expand Down
2 changes: 1 addition & 1 deletion src/gc/gc_gms.c
Expand Up @@ -1477,7 +1477,7 @@ gc_gms_allocate_pmc_header(PARROT_INTERP, SHIM(UINTVAL flags))
ASSERT_ARGS(gc_gms_allocate_pmc_header)
MarkSweep_GC * const self = (MarkSweep_GC *)interp->gc_sys->gc_private;
Pool_Allocator * const pool = self->pmc_allocator;
pmc_alloc_struct *item;
pmc_alloc_struct * item = NULL;

gc_gms_maybe_mark_and_sweep(interp);

Expand Down
2 changes: 1 addition & 1 deletion src/pmc.c
Expand Up @@ -506,7 +506,7 @@ static PMC *
get_new_pmc_header(PARROT_INTERP, INTVAL base_type, UINTVAL flags)
{
ASSERT_ARGS(get_new_pmc_header)
PMC *newpmc;
PMC *newpmc = NULL;
VTABLE *vtable = interp->vtables[base_type];
UINTVAL vtable_flags;

Expand Down
8 changes: 5 additions & 3 deletions src/pmc/callcontext.pmc
Expand Up @@ -465,10 +465,12 @@ mark_positionals(PARROT_INTERP, ARGIN(PMC *self))
if (size) {
Pcc_cell *cells;
INTVAL i;
GETATTR_CallContext_positionals(interp, self, cells);

for (i = 0; i < size; ++i)
mark_cell(interp, &cells[i]);
GETATTR_CallContext_positionals(interp, self, cells);
if (cells) {
for (i = 0; i < size; ++i)
mark_cell(interp, &cells[i]);
}
}
}

Expand Down

0 comments on commit 0f6ddac

Please sign in to comment.