Skip to content

Commit

Permalink
Prepare deprecation of the ListChunk GC API, and src/list.c
Browse files Browse the repository at this point in the history
See GH #1179.
See #define PARROT_BUFFERLIKE_LIST in config.h to use it, still.
imageiofreeze still uses it.
  • Loading branch information
Reini Urban committed Oct 19, 2015
1 parent 45cf48b commit 0dbfd52
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 18 deletions.
2 changes: 2 additions & 0 deletions config/gen/config_h/config_h.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ typedef @float8_t@ Parrot_Float8;
#ifndef PARROT_GC_DEFAULT_TYPE
# define PARROT_GC_DEFAULT_TYPE @gc_type@
#endif
/* Deprecate the ListChunk objects in src/list.c. Still needed for imageiofreeze */
#define PARROT_BUFFERLIKE_LIST

#if defined(PARROT_IN_CORE)

Expand Down
9 changes: 7 additions & 2 deletions src/gc/api.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2014, Parrot Foundation.
Copyright (C) 2001-2015, Parrot Foundation.
=head1 NAME
Expand Down Expand Up @@ -244,8 +244,10 @@ Parrot_gc_initialize(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
PARROT_ASSERT(interp->gc_sys->allocate_string_header);
PARROT_ASSERT(interp->gc_sys->free_string_header);

#ifdef PARROT_BUFFERLIKE_LIST
PARROT_ASSERT(interp->gc_sys->allocate_bufferlike_header);
PARROT_ASSERT(interp->gc_sys->free_bufferlike_header);
#endif

PARROT_ASSERT(interp->gc_sys->allocate_pmc_attributes);
PARROT_ASSERT(interp->gc_sys->free_pmc_attributes);
Expand Down Expand Up @@ -397,6 +399,8 @@ Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
interp->gc_sys->free_string_header(interp, s);
}

#ifdef PARROT_BUFFERLIKE_LIST

/*
=item C<Parrot_Buffer * Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t
Expand All @@ -405,7 +409,7 @@ size)>
Returns a new buffer-like header from the appropriate sized pool.
A "bufferlike object" is an object that is considered to be isomorphic to the
PObj, so it will participate in normal GC. At the moment these are only used
to create ListChunk objects in src/list.c.
to create ListChunk objects in src/list.c, which is unused.
=cut
Expand Down Expand Up @@ -441,6 +445,7 @@ Parrot_gc_free_bufferlike_header(PARROT_INTERP, ARGMOD(Parrot_Buffer *obj),
ASSERT_ARGS(Parrot_gc_free_bufferlike_header)
interp->gc_sys->free_bufferlike_header(interp, obj, size);
}
#endif

/*
Expand Down
16 changes: 14 additions & 2 deletions src/gc/gc_gms.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2014, Parrot Foundation.
Copyright (C) 2001-2015, Parrot Foundation.
=head1 NAME
Expand Down Expand Up @@ -705,8 +705,10 @@ Parrot_gc_gms_init(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
interp->gc_sys->allocate_string_header = gc_gms_allocate_string_header;
interp->gc_sys->free_string_header = gc_gms_free_string_header;

#ifdef PARROT_BUFFERLIKE_LIST
interp->gc_sys->allocate_bufferlike_header = gc_gms_allocate_buffer_header;
interp->gc_sys->free_bufferlike_header = gc_gms_free_buffer_header;
#endif

interp->gc_sys->allocate_pmc_attributes = gc_gms_allocate_pmc_attributes;
interp->gc_sys->free_pmc_attributes = gc_gms_free_pmc_attributes_locked;
Expand Down Expand Up @@ -1650,15 +1652,21 @@ gc_gms_is_pmc_ptr(PARROT_INTERP, ARGIN_NULLOK(void *ptr))
=item C<gc_gms_allocate_string_header(PARROT_INTERP, STRING *str)>
Allocate a string header.
=item C<gc_gms_free_string_header(PARROT_INTERP, STRING *s)>
Free a string header.
=item C<static Parrot_Buffer* gc_gms_allocate_buffer_header(PARROT_INTERP,
size_t size)>
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=item C<static void gc_gms_free_buffer_header(PARROT_INTERP, Parrot_Buffer *s,
size_t size)>
Allocate/free string/buffer headers.
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
*/

Expand Down Expand Up @@ -1720,6 +1728,8 @@ gc_gms_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
}
}

#ifdef PARROT_BUFFERLIKE_LIST

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static Parrot_Buffer*
Expand All @@ -1736,6 +1746,8 @@ gc_gms_free_buffer_header(PARROT_INTERP, ARGFREE(Parrot_Buffer *s), SHIM(size_t
gc_gms_free_string_header(interp, (STRING*)s);
}

#endif

/*
=item C<static int gc_gms_is_string_ptr(PARROT_INTERP, void *ptr)>
Expand Down
12 changes: 11 additions & 1 deletion src/gc/gc_inf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2014, Parrot Foundation.
Copyright (C) 2001-2015, Parrot Foundation.
=head1 NAME
Expand Down Expand Up @@ -259,9 +259,13 @@ flags)>
=item C<static Parrot_Buffer* gc_inf_allocate_bufferlike_header(PARROT_INTERP,
size_t size)>
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=item C<static void gc_inf_free_bufferlike_header(PARROT_INTERP, Parrot_Buffer
*b, size_t size)>
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=item C<static void* gc_inf_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
=item C<static void gc_inf_free_pmc_attributes(PARROT_INTERP, PMC *pmc)>
Expand Down Expand Up @@ -338,6 +342,8 @@ gc_inf_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
}
}

#ifdef PARROT_BUFFERLIKE_LIST

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static Parrot_Buffer*
Expand All @@ -363,6 +369,8 @@ gc_inf_free_bufferlike_header(PARROT_INTERP, ARGFREE(Parrot_Buffer *b), SHIM(siz
}
}

#endif

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void*
Expand Down Expand Up @@ -532,8 +540,10 @@ Parrot_gc_inf_init(PARROT_INTERP, SHIM(Parrot_GC_Init_Args *args))
interp->gc_sys->allocate_string_header = gc_inf_allocate_string_header;
interp->gc_sys->free_string_header = gc_inf_free_string_header;

#ifdef PARROT_BUFFERLIKE_LIST
interp->gc_sys->allocate_bufferlike_header = gc_inf_allocate_bufferlike_header;
interp->gc_sys->free_bufferlike_header = gc_inf_free_bufferlike_header;
#endif

interp->gc_sys->allocate_pmc_attributes = gc_inf_allocate_pmc_attributes;
interp->gc_sys->free_pmc_attributes = gc_inf_free_pmc_attributes;
Expand Down
30 changes: 25 additions & 5 deletions src/gc/gc_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@ Parrot_gc_ms_init(PARROT_INTERP, SHIM(Parrot_GC_Init_Args *args))
interp->gc_sys->allocate_string_header = gc_ms_allocate_string_header;
interp->gc_sys->free_string_header = gc_ms_free_string_header;

#ifdef PARROT_BUFFERLIKE_LIST
interp->gc_sys->allocate_bufferlike_header = gc_ms_allocate_bufferlike_header;
interp->gc_sys->free_bufferlike_header = gc_ms_free_bufferlike_header;

#endif
interp->gc_sys->is_pmc_ptr = gc_ms_is_pmc_ptr;
interp->gc_sys->is_string_ptr = gc_ms_is_string_ptr;
interp->gc_sys->mark_pmc_header = gc_ms_mark_pmc_header;
Expand Down Expand Up @@ -621,11 +622,15 @@ gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
}

if (flags & GC_finish_FLAG) {
#ifndef NDEBUG
gc_ms_print_stats(interp, "finish: finalize_memory_pools");
#endif
gc_ms_finalize_memory_pools(interp, mem_pools);
return;
}
#ifndef NDEBUG
gc_ms_print_stats(interp, "Mark phase");
#endif

++mem_pools->gc_mark_block_level;
mem_pools->lazy_gc = flags & GC_lazy_FLAG;
Expand All @@ -641,7 +646,9 @@ gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
mem_pools->gc_trace_ptr = NULL;
mem_pools->gc_mark_ptr = NULL;

#ifndef NDEBUG
gc_ms_print_stats(interp, "Sweep phase");
#endif
/* We've done the mark, now do the sweep. Pass the sweep callback
function to the PMC pool and all the sized pools. */
header_pools_iterate_callback(interp, mem_pools,
Expand All @@ -650,12 +657,16 @@ gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
}
else {
++interp->gc_sys->stats.gc_lazy_mark_runs;
#ifndef NDEBUG
gc_ms_print_stats(interp, "Lazy trace");
#endif
Parrot_gc_clear_live_bits(interp, mem_pools->pmc_pool);
}

/* compact STRING pools to collect free headers and allocated buffers */
#ifndef NDEBUG
gc_ms_print_stats(interp, "Compact memory");
#endif
Parrot_gc_compact_memory_pool(interp);

/* Note it */
Expand Down Expand Up @@ -940,6 +951,7 @@ gc_ms_is_string_ptr(PARROT_INTERP, ARGIN_NULLOK(void *ptr))
flags)>
Allocate new STRING header from pool.
If flags & PObj_constant_FLAG from the constant_string_header_pool.
=cut
Expand Down Expand Up @@ -1005,6 +1017,8 @@ gc_ms_mark_str_header(SHIM_INTERP, ARGMOD_NULLOK(STRING *obj))
}
}

#ifdef PARROT_BUFFERLIKE_LIST

/*
=item C<static Parrot_Buffer * gc_ms_allocate_bufferlike_header(PARROT_INTERP,
Expand All @@ -1013,7 +1027,9 @@ size_t size)>
Returns a new buffer-like header from the appropriate sized pool.
A "bufferlike object" is an object that is considered to be isomorphic to the
PObj, so it will participate in normal GC. At the moment these are only used
to create ListChunk objects in src/list.c.
to create ListChunk objects in src/list.c, which are unused.
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=cut
Expand All @@ -1040,6 +1056,8 @@ gc_ms_allocate_bufferlike_header(PARROT_INTERP, size_t size)
Free a bufferlike header that is not being used, so that Parrot can recycle
it and use it again.
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=cut
*/
Expand All @@ -1054,6 +1072,8 @@ gc_ms_free_bufferlike_header(PARROT_INTERP, ARGMOD(Parrot_Buffer *obj),
pool->add_free_object(interp, mem_pools, pool, obj);
}

#endif

/*
=over 4
Expand Down Expand Up @@ -1990,7 +2010,7 @@ gc_ms_iterate_live_strings(PARROT_INTERP,

/*
=item C<void gc_ms_print_stats_always(PARROT_INTERP, const char* header)>
=item C<static void gc_ms_print_stats_always(PARROT_INTERP, const char* header)>
=item C<static void gc_ms_print_stats(PARROT_INTERP, const char* header)>
Expand All @@ -2000,10 +2020,10 @@ Debug function, only enabled with C<-DMEMORY_DEBUG> in C<ccflags>.
*/

void
static void
gc_ms_print_stats_always(PARROT_INTERP, ARGIN(const char* header))
{
ASSERT_ARGS(gc_ms_print_stats_always)
/*ASSERT_ARGS(gc_ms_print_stats_always)*/

Memory_Pools * const mem_pools = (Memory_Pools *)interp->gc_sys->gc_private;
GC_Statistics stats = interp->gc_sys->stats;
Expand Down
12 changes: 11 additions & 1 deletion src/gc/gc_ms2.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,10 @@ Parrot_gc_ms2_init(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
gc_sys->allocate_string_header = gc_ms2_allocate_string_header;
gc_sys->free_string_header = gc_ms2_free_string_header;

#ifdef PARROT_BUFFERLIKE_LIST
gc_sys->allocate_bufferlike_header = gc_ms2_allocate_buffer_header;
gc_sys->free_bufferlike_header = gc_ms2_free_buffer_header;
#endif

gc_sys->allocate_pmc_attributes = gc_ms2_allocate_pmc_attributes;
gc_sys->free_pmc_attributes = gc_ms2_free_pmc_attributes;
Expand Down Expand Up @@ -837,15 +839,21 @@ gc_ms2_is_pmc_ptr(PARROT_INTERP, ARGIN_NULLOK(void *ptr))
=item C<gc_ms2_allocate_string_header()>
Allocate string headers.
=item C<gc_ms2_free_string_header()>
Free string headers.
=item C<static Parrot_Buffer* gc_ms2_allocate_buffer_header(PARROT_INTERP,
size_t size)>
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
=item C<static void gc_ms2_free_buffer_header(PARROT_INTERP, Parrot_Buffer *s,
size_t size)>
Allocate/free string/buffer headers.
Deprecated. define PARROT_BUFFERLIKE_LIST in config.h to use it.
*/

Expand Down Expand Up @@ -897,6 +905,7 @@ gc_ms2_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
}
}

#ifdef PARROT_BUFFERLIKE_LIST

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
Expand All @@ -915,6 +924,7 @@ gc_ms2_free_buffer_header(PARROT_INTERP, ARGFREE(Parrot_Buffer *s), SHIM(size_t
gc_ms2_free_string_header(interp, (STRING*)s);
}

#endif

/*
Expand Down
15 changes: 8 additions & 7 deletions src/gc/gc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,6 @@ void gc_ms_pmc_needs_early_collection(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmc);

void gc_ms_print_stats_always(PARROT_INTERP, ARGIN(const char* header))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

void gc_ms_reallocate_buffer_storage(PARROT_INTERP,
ARGIN(Parrot_Buffer *str),
size_t size)
Expand Down Expand Up @@ -673,6 +669,11 @@ PARROT_PURE_FUNCTION
int Parrot_gc_ms_needed(PARROT_INTERP)
__attribute__nonnull__(1);

static void gc_ms_print_stats_always(PARROT_INTERP,
ARGIN(const char* header))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

#define ASSERT_ARGS_gc_ms_allocate_buffer_storage __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(str))
Expand All @@ -696,9 +697,6 @@ int Parrot_gc_ms_needed(PARROT_INTERP)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_gc_ms_print_stats_always __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(header))
#define ASSERT_ARGS_gc_ms_reallocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
Expand All @@ -713,6 +711,9 @@ int Parrot_gc_ms_needed(PARROT_INTERP)
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_gc_ms_needed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_void gc_ms_print_stats_always __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(header))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/gc_ms.c */

Expand Down

0 comments on commit 0dbfd52

Please sign in to comment.