[svn:parrot] r38630 - in branches/gc_api: include/parrot src src/gc src/interp src/io src/ops src/string src/string/charset
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sat May 9 11:38:18 UTC 2009
Author: whiteknight
Date: Sat May 9 11:38:17 2009
New Revision: 38630
URL: https://trac.parrot.org/parrot/changeset/38630
Log:
[gc_api] rename the rest of the functions in the API to be Parrot_gc_*, fix some documentation, etc
Modified:
branches/gc_api/include/parrot/gc_api.h
branches/gc_api/src/gc/api.c
branches/gc_api/src/gc/gc_private.h
branches/gc_api/src/gc/mark_sweep.c
branches/gc_api/src/gc/pools.c
branches/gc_api/src/gc/res_lea.c
branches/gc_api/src/interp/inter_create.c
branches/gc_api/src/io/buffer.c
branches/gc_api/src/io/filehandle.c
branches/gc_api/src/list.c
branches/gc_api/src/ops/core.ops
branches/gc_api/src/pmc_freeze.c
branches/gc_api/src/string/api.c
branches/gc_api/src/string/charset/ascii.c
branches/gc_api/src/string/charset/iso-8859-1.c
branches/gc_api/src/string/charset/unicode.c
Modified: branches/gc_api/include/parrot/gc_api.h
==============================================================================
--- branches/gc_api/include/parrot/gc_api.h Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/include/parrot/gc_api.h Sat May 9 11:38:17 2009 (r38630)
@@ -333,35 +333,40 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*obj);
-void Parrot_allocate_aligned(PARROT_INTERP,
+void Parrot_gc_add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*pmc);
+
+void Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*pmc);
+
+void Parrot_gc_allocate_aligned(PARROT_INTERP,
ARGOUT(Buffer *buffer),
size_t size)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*buffer);
-void Parrot_allocate_string(PARROT_INTERP, ARGOUT(STRING *str), size_t size)
+void Parrot_gc_allocate_string_storage(PARROT_INTERP,
+ ARGOUT(STRING *str),
+ size_t size)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*str);
-void Parrot_destroy_header_pools(PARROT_INTERP)
+void Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_destroy_memory_pools(PARROT_INTERP)
+void Parrot_gc_compact_memory_pool(PARROT_INTERP)
__attribute__nonnull__(1);
-void Parrot_gc_add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pmc);
-
-void Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*pmc);
+void Parrot_gc_destroy_header_pools(PARROT_INTERP)
+ __attribute__nonnull__(1);
-void Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)
+void Parrot_gc_destroy_memory_pools(PARROT_INTERP)
__attribute__nonnull__(1);
void Parrot_gc_free_bufferlike_header(PARROT_INTERP,
@@ -383,6 +388,13 @@
void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
__attribute__nonnull__(1);
+void Parrot_gc_merge_header_pools(
+ ARGMOD(Interp *dest_interp),
+ ARGIN(Interp *source_interp))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*dest_interp);
+
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
void * Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size)
@@ -398,30 +410,21 @@
STRING * Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)
__attribute__nonnull__(1);
-int Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr))
+PARROT_WARN_UNUSED_RESULT
+int Parrot_gc_ptr_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-void Parrot_go_collect(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-int Parrot_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
+int Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-void Parrot_merge_header_pools(
- ARGMOD(Interp *dest_interp),
- ARGIN(Interp *source_interp))
+void Parrot_gc_reallocate_string_storage(PARROT_INTERP,
+ ARGMOD(STRING *str),
+ size_t newsize)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
- FUNC_MODIFIES(*dest_interp);
-
-void Parrot_merge_memory_pools(
- ARGIN(Interp *dest_interp),
- ARGIN(Interp *source_interp))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
+ FUNC_MODIFIES(*str);
void Parrot_reallocate(PARROT_INTERP,
ARGMOD(Buffer *buffer),
@@ -430,34 +433,32 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*buffer);
-void Parrot_reallocate_string(PARROT_INTERP,
- ARGMOD(STRING *str),
- size_t newsize)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*str);
-
#define ASSERT_ARGS_Parrot_gc_mark_PObj_alive __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(obj)
-#define ASSERT_ARGS_Parrot_allocate_aligned __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(buffer)
-#define ASSERT_ARGS_Parrot_allocate_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(str)
-#define ASSERT_ARGS_Parrot_destroy_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_destroy_memory_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_gc_add_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
#define ASSERT_ARGS_Parrot_gc_add_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_gc_allocate_aligned __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(buffer)
+#define ASSERT_ARGS_Parrot_gc_allocate_string_storage \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(str)
#define ASSERT_ARGS_Parrot_gc_cleanup_next_for_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_compact_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_destroy_header_pools \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_destroy_memory_pools \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_gc_free_bufferlike_header \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
@@ -470,6 +471,9 @@
|| PARROT_ASSERT_ARG(stacktop)
#define ASSERT_ARGS_Parrot_gc_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_merge_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(dest_interp) \
+ || PARROT_ASSERT_ARG(source_interp)
#define ASSERT_ARGS_Parrot_gc_new_bufferlike_header \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
@@ -477,26 +481,19 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_gc_new_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ptr_in_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(bufstart)
#define ASSERT_ARGS_Parrot_gc_ptr_is_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ptr)
-#define ASSERT_ARGS_Parrot_go_collect __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_in_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_reallocate_string_storage \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(bufstart)
-#define ASSERT_ARGS_Parrot_merge_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(dest_interp) \
- || PARROT_ASSERT_ARG(source_interp)
-#define ASSERT_ARGS_Parrot_merge_memory_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(dest_interp) \
- || PARROT_ASSERT_ARG(source_interp)
+ || PARROT_ASSERT_ARG(str)
#define ASSERT_ARGS_Parrot_reallocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(buffer)
-#define ASSERT_ARGS_Parrot_reallocate_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(str)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/api.c */
Modified: branches/gc_api/src/gc/api.c
==============================================================================
--- branches/gc_api/src/gc/api.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/gc/api.c Sat May 9 11:38:17 2009 (r38630)
@@ -195,8 +195,8 @@
=item C<PMC * Parrot_gc_new_pmc_header(PARROT_INTERP, UINTVAL flags)>
Gets a new PMC header from the PMC pool's free list. Guaranteed to return a
-valid PMC object or else Parrot will panic. Sets the necessary flags for the
-objects and initializes the PMC data pointer to C<NULL>.
+valid PMC object or else Parrot will throw an exception. Sets the necessary
+flags for the objects and initializes the PMC data pointer to C<NULL>.
=cut
@@ -300,8 +300,8 @@
=item C<void Parrot_gc_add_pmc_sync(PARROT_INTERP, PMC *pmc)>
Adds a C<Sync*> structure to the given C<PMC>. Initializes the PMC's owner
-field and the synchronization mutext. Does not check to ensure the C<Sync *> is
-non-null.
+field and the synchronization mutext. Throws an exception if Sync allocation
+fails.
=cut
@@ -368,7 +368,8 @@
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 and Stack_Chunk objects in
+src/stacks.c.
=cut
@@ -390,6 +391,9 @@
=item C<void Parrot_gc_free_bufferlike_header(PARROT_INTERP, PObj *obj, size_t
size)>
+Free a bufferlike header that is not being used, so that Parrot can recycle
+it and use it again.
+
=cut
*/
@@ -436,15 +440,12 @@
p->pmc_ext = NULL;
}
-
-
-
/*
=item C<void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)>
Calls the configured garbage collector to find and reclaim unused
-headers.
+headers. Performs a complete mark & sweep run of the GC.
=cut
@@ -460,7 +461,7 @@
/*
-=item C<void Parrot_merge_header_pools(Interp *dest_interp, Interp
+=item C<void Parrot_gc_merge_header_pools(Interp *dest_interp, Interp
*source_interp)>
Merges the header pools of C<source_interp> into those of C<dest_interp>.
@@ -471,9 +472,10 @@
*/
void
-Parrot_merge_header_pools(ARGMOD(Interp *dest_interp), ARGIN(Interp *source_interp))
+Parrot_gc_merge_header_pools(ARGMOD(Interp *dest_interp),
+ ARGIN(Interp *source_interp))
{
- ASSERT_ARGS(Parrot_merge_header_pools)
+ ASSERT_ARGS(Parrot_gc_merge_header_pools)
Arenas * const dest_arena = dest_interp->arena_base;
Arenas * const source_arena = source_interp->arena_base;
@@ -554,7 +556,7 @@
/*
-=item C<void Parrot_destroy_header_pools(PARROT_INTERP)>
+=item C<void Parrot_gc_destroy_header_pools(PARROT_INTERP)>
Performs a garbage collection sweep on all pools, then frees them. Calls
C<Parrot_forall_header_pools> to loop over all the pools, passing
@@ -566,9 +568,9 @@
*/
void
-Parrot_destroy_header_pools(PARROT_INTERP)
+Parrot_gc_destroy_header_pools(PARROT_INTERP)
{
- ASSERT_ARGS(Parrot_destroy_header_pools)
+ ASSERT_ARGS(Parrot_gc_destroy_header_pools)
INTVAL pass;
/* const/non const COW strings life in different pools
@@ -658,21 +660,21 @@
/*
-=item C<void Parrot_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t
+=item C<void Parrot_gc_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t
size)>
-Like above, except the C<size> will be rounded up and the address of
-the buffer will have the same alignment as a pointer returned by
-malloc(3) suitable to hold e.g. a C<FLOATVAL> array.
+Allocates a chunk of memory of at least size C<size> for the given Buffer.
+buffer is guaranteed to be properly aligned for things like C<FLOATVALS>,
+so the size may be rounded up or down to guarantee that this alignment holds.
=cut
*/
void
-Parrot_allocate_aligned(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
+Parrot_gc_allocate_aligned(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
{
- ASSERT_ARGS(Parrot_allocate_aligned)
+ ASSERT_ARGS(Parrot_gc_allocate_aligned)
size_t new_size;
char *mem;
@@ -690,7 +692,8 @@
/*
-=item C<void Parrot_allocate_string(PARROT_INTERP, STRING *str, size_t size)>
+=item C<void Parrot_gc_allocate_string_storage(PARROT_INTERP, STRING *str,
+size_t size)>
Allocate the STRING's buffer memory to the given size. The allocated
buffer maybe slightly bigger than the given C<size>. This function
@@ -702,9 +705,9 @@
*/
void
-Parrot_allocate_string(PARROT_INTERP, ARGOUT(STRING *str), size_t size)
+Parrot_gc_allocate_string_storage(PARROT_INTERP, ARGOUT(STRING *str), size_t size)
{
- ASSERT_ARGS(Parrot_allocate_string)
+ ASSERT_ARGS(Parrot_gc_allocate_string_storage)
size_t new_size;
Memory_Pool *pool;
char *mem;
@@ -733,78 +736,6 @@
/*
-=item C<void Parrot_go_collect(PARROT_INTERP)>
-
-Scan the string pools and compact them. This does not perform a GC mark or
-sweep run, and does not check whether string buffers are still alive.
-Redirects to C<compact_pool>.
-
-=cut
-
-*/
-
-void
-Parrot_go_collect(PARROT_INTERP)
-{
- ASSERT_ARGS(Parrot_go_collect)
- compact_pool(interp, interp->arena_base->memory_pool);
-}
-
-/*
-
-=item C<int Parrot_in_memory_pool(PARROT_INTERP, void *bufstart)>
-
-Determines if the given C<bufstart> pointer points to a location inside the
-memory pool. Returns 1 if the pointer is in the memory pool, 0 otherwise.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-int
-Parrot_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
-{
- ASSERT_ARGS(Parrot_in_memory_pool)
- Memory_Pool * const pool = interp->arena_base->memory_pool;
- Memory_Block * cur_block = pool->top_block;
-
- while (cur_block) {
- if ((char *)bufstart >= cur_block->start &&
- (char *) bufstart < cur_block->start + cur_block->size) {
- return 1;
- }
- cur_block = cur_block->prev;
- }
- return 0;
-}
-
-/*
-
-=item C<void Parrot_merge_memory_pools(Interp *dest_interp, Interp
-*source_interp)>
-
-Merge the memory pools of two interpreter structures. Merge the general
-memory pool and the constant string pools from C<source_interp> into
-C<dest_interp>.
-
-=cut
-
-*/
-
-void
-Parrot_merge_memory_pools(ARGIN(Interp *dest_interp), ARGIN(Interp *source_interp))
-{
- ASSERT_ARGS(Parrot_merge_memory_pools)
- merge_pools(dest_interp->arena_base->constant_string_pool,
- source_interp->arena_base->constant_string_pool);
-
- merge_pools(dest_interp->arena_base->memory_pool,
- source_interp->arena_base->memory_pool);
-}
-
-/*
-
=item C<void Parrot_reallocate(PARROT_INTERP, Buffer *buffer, size_t newsize)>
Reallocate the Buffer's buffer memory to the given size. The
@@ -877,8 +808,56 @@
/*
-=item C<void Parrot_reallocate_string(PARROT_INTERP, STRING *str, size_t
-newsize)>
+=item C<void Parrot_gc_compact_memory_pool(PARROT_INTERP)>
+
+Scan the string pools and compact them. This does not perform a GC mark or
+sweep run, and does not check whether string buffers are still alive.
+Redirects to C<compact_pool>.
+
+=cut
+
+*/
+
+void
+Parrot_gc_compact_memory_pool(PARROT_INTERP)
+{
+ ASSERT_ARGS(Parrot_gc_compact_memory_pool)
+ compact_pool(interp, interp->arena_base->memory_pool);
+}
+
+/*
+
+=item C<int Parrot_gc_ptr_in_memory_pool(PARROT_INTERP, void *bufstart)>
+
+Determines if the given C<bufstart> pointer points to a location inside the
+memory pool. Returns 1 if the pointer is in the memory pool, 0 otherwise.
+
+=cut
+
+*/
+
+PARROT_WARN_UNUSED_RESULT
+int
+Parrot_gc_ptr_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
+{
+ ASSERT_ARGS(Parrot_gc_ptr_in_memory_pool)
+ Memory_Pool * const pool = interp->arena_base->memory_pool;
+ Memory_Block * cur_block = pool->top_block;
+
+ while (cur_block) {
+ if ((char *)bufstart >= cur_block->start &&
+ (char *) bufstart < cur_block->start + cur_block->size) {
+ return 1;
+ }
+ cur_block = cur_block->prev;
+ }
+ return 0;
+}
+
+/*
+
+=item C<void Parrot_gc_reallocate_string_storage(PARROT_INTERP, STRING *str,
+size_t newsize)>
Reallocate the STRING's buffer memory to the given size. The allocated
buffer will not shrink. This function sets also C<str-E<gt>strstart> to the
@@ -889,9 +868,9 @@
*/
void
-Parrot_reallocate_string(PARROT_INTERP, ARGMOD(STRING *str), size_t newsize)
+Parrot_gc_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str), size_t newsize)
{
- ASSERT_ARGS(Parrot_reallocate_string)
+ ASSERT_ARGS(Parrot_gc_reallocate_string_storage)
size_t copysize;
char *mem, *oldmem;
size_t new_size, needed, old_size;
@@ -949,7 +928,7 @@
/*
-=item C<void Parrot_destroy_memory_pools(PARROT_INTERP)>
+=item C<void Parrot_gc_destroy_memory_pools(PARROT_INTERP)>
Destroys the memory pool and the constant string pool. Loop through both
pools and destroy all memory blocks contained in them. Once all the
@@ -960,9 +939,9 @@
*/
void
-Parrot_destroy_memory_pools(PARROT_INTERP)
+Parrot_gc_destroy_memory_pools(PARROT_INTERP)
{
- ASSERT_ARGS(Parrot_destroy_memory_pools)
+ ASSERT_ARGS(Parrot_gc_destroy_memory_pools)
int i;
for (i = 0; i < 2; i++) {
Modified: branches/gc_api/src/gc/gc_private.h
==============================================================================
--- branches/gc_api/src/gc/gc_private.h Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/gc/gc_private.h Sat May 9 11:38:17 2009 (r38630)
@@ -347,6 +347,12 @@
void Parrot_initialize_header_pools(PARROT_INTERP)
__attribute__nonnull__(1);
+void Parrot_merge_memory_pools(
+ ARGIN(Interp *dest_interp),
+ ARGIN(Interp *source_interp))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
#define ASSERT_ARGS_free_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(pool)
#define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -382,6 +388,9 @@
#define ASSERT_ARGS_Parrot_initialize_header_pools \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_merge_memory_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(dest_interp) \
+ || PARROT_ASSERT_ARG(source_interp)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/pools.c */
Modified: branches/gc_api/src/gc/mark_sweep.c
==============================================================================
--- branches/gc_api/src/gc/mark_sweep.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/gc/mark_sweep.c Sat May 9 11:38:17 2009 (r38630)
@@ -197,7 +197,7 @@
Parrot_gc_ms_run_init(interp);
/* compact STRING pools to collect free headers and allocated buffers */
- Parrot_go_collect(interp);
+ Parrot_gc_compact_memory_pool(interp);
/* Now go trace the PMCs */
if (trace_active_PMCs(interp, (flags & GC_trace_stack_FLAG)
Modified: branches/gc_api/src/gc/pools.c
==============================================================================
--- branches/gc_api/src/gc/pools.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/gc/pools.c Sat May 9 11:38:17 2009 (r38630)
@@ -60,6 +60,30 @@
/*
+=item C<void Parrot_merge_memory_pools(Interp *dest_interp, Interp
+*source_interp)>
+
+Merge the memory pools of two interpreter structures. Merge the general
+memory pool and the constant string pools from C<source_interp> into
+C<dest_interp>.
+
+=cut
+
+*/
+
+void
+Parrot_merge_memory_pools(ARGIN(Interp *dest_interp), ARGIN(Interp *source_interp))
+{
+ ASSERT_ARGS(Parrot_merge_memory_pools)
+ merge_pools(dest_interp->arena_base->constant_string_pool,
+ source_interp->arena_base->constant_string_pool);
+
+ merge_pools(dest_interp->arena_base->memory_pool,
+ source_interp->arena_base->memory_pool);
+}
+
+/*
+
=head2 Buffer Header Functions for small-object lookup table
=over 4
Modified: branches/gc_api/src/gc/res_lea.c
==============================================================================
--- branches/gc_api/src/gc/res_lea.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/gc/res_lea.c Sat May 9 11:38:17 2009 (r38630)
@@ -33,7 +33,7 @@
/*
-=item C<void Parrot_go_collect(PARROT_INTERP)>
+=item C<void Parrot_gc_compact_memory_pool(PARROT_INTERP)>
Does nothing other than increment the interpreter's C<gc_collect_runs>
count.
@@ -43,7 +43,7 @@
*/
void
-Parrot_go_collect(PARROT_INTERP)
+Parrot_gc_compact_memory_pool(PARROT_INTERP)
{
ASSERT_ARGS(parrot_go_collect)
if (interp->arena_base->gc_sweep_block_level) {
@@ -134,7 +134,7 @@
Buffer_alloc_unit *p;
if (!PObj_bufstart(buffer)) {
- Parrot_allocate_aligned(interp, buffer, newsize);
+ Parrot_gc_allocate_aligned(interp, buffer, newsize);
/* The previous version zeroed the memory here, but I'm not
sure why. */
memset(PObj_bufstart(buffer), 0, newsize);
@@ -164,7 +164,8 @@
This was never called anyway, so it isn't implemented here.
-=item C<void Parrot_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t size)>
+=item C<void Parrot_gc_allocate_aligned(PARROT_INTERP, Buffer *buffer,
+size_t size)>
Like above, except the address of the buffer is guaranteed to be
suitably aligned for holding anything contained in UnionVal
@@ -175,7 +176,7 @@
*/
void
-Parrot_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t size)
+Parrot_gc_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t size)
{
ASSERT_ARGS(parrot_allocate_aligned)
Buffer_alloc_unit *p;
@@ -187,7 +188,7 @@
/*
-=item C<void Parrot_reallocate_string(PARROT_INTERP, STRING *str, size_t newsize)>
+=item C<void Parrot_gc_reallocate_string_storage(PARROT_INTERP, STRING *str, size_t newsize)>
Reallocates the string buffer in C<*str> and returns it. C<newsize> is the
number of bytes memory required.
@@ -197,13 +198,13 @@
*/
void
-Parrot_reallocate_string(PARROT_INTERP, STRING *str, size_t newsize)
+Parrot_gc_reallocate_string_storage(PARROT_INTERP, STRING *str, size_t newsize)
{
ASSERT_ARGS(parrot_reallocate_string)
Buffer_alloc_unit *p;
if (!PObj_bufstart(str)) {
- Parrot_allocate_string(interp, str, newsize);
+ Parrot_gc_allocate_string_storage(interp, str, newsize);
}
else if (newsize) {
p = (Buffer_alloc_unit *) xrealloc(PObj_bufallocstart(str),
@@ -215,7 +216,7 @@
/*
-=item C<void Parrot_allocate_string(PARROT_INTERP, STRING *str, size_t size)>
+=item C<void Parrot_gc_allocate_string_storage(PARROT_INTERP, STRING *str, size_t size)>
Allocates the string buffer in C<*str> and returns it. C<size> is the
number bytes of memory required.
@@ -225,9 +226,9 @@
*/
void
-Parrot_allocate_string(PARROT_INTERP, STRING *str, size_t size)
+Parrot_gc_allocate_string_storage(PARROT_INTERP, STRING *str, size_t size)
{
- ASSERT_ARGS(parrot_allocate_string)
+ ASSERT_ARGS(Parrot_gc_allocate_string_storage)
Buffer_alloc_unit *p;
p = (Buffer_alloc_unit *) xcalloc(Buffer_alloc_offset + size, 1);
p->ref_count = 0;
@@ -268,7 +269,7 @@
/*
-=item C<void Parrot_destroy_memory_pools(PARROT_INTERP)>
+=item C<void Parrot_gc_destroy_memory_pools(PARROT_INTERP)>
Does nothing.
@@ -277,7 +278,7 @@
*/
void
-Parrot_destroy_memory_pools(PARROT_INTERP)
+Parrot_gc_destroy_memory_pools(PARROT_INTERP)
{
ASSERT_ARGS(parrot_destroy_memory_pools)
}
Modified: branches/gc_api/src/interp/inter_create.c
==============================================================================
--- branches/gc_api/src/interp/inter_create.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/interp/inter_create.c Sat May 9 11:38:17 2009 (r38630)
@@ -384,8 +384,8 @@
if (interp->parent_interpreter
&& interp->thread_data
&& (interp->thread_data->state & THREAD_STATE_JOINED)) {
- Parrot_merge_header_pools(interp->parent_interpreter, interp);
- Parrot_merge_memory_pools(interp->parent_interpreter, interp);
+ Parrot_gc_merge_header_pools(interp->parent_interpreter, interp);
+ Parrot_gc_merge_memory_pools(interp->parent_interpreter, interp);
}
if (interp->arena_base->finalize_gc_system)
@@ -398,10 +398,10 @@
Parrot_destroy_constants(interp);
/* buffer headers, PMCs */
- Parrot_destroy_header_pools(interp);
+ Parrot_gc_destroy_header_pools(interp);
/* memory pools in resources */
- Parrot_destroy_memory_pools(interp);
+ Parrot_gc_destroy_memory_pools(interp);
/* mem subsystem is dead now */
mem_sys_free(interp->arena_base);
Modified: branches/gc_api/src/io/buffer.c
==============================================================================
--- branches/gc_api/src/io/buffer.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/io/buffer.c Sat May 9 11:38:17 2009 (r38630)
@@ -307,7 +307,7 @@
len = s->bufused;
if (!s->strstart)
- Parrot_allocate_string(interp, s, len);
+ Parrot_gc_allocate_string_storage(interp, s, len);
out_buf = (unsigned char *)s->strstart;
@@ -514,10 +514,10 @@
len = buffer_end - buf_start;
if (s->bufused < l) {
if (s->strstart) {
- Parrot_reallocate_string(interp, s, l);
+ Parrot_gc_reallocate_string_storage(interp, s, l);
}
else {
- Parrot_allocate_string(interp, s, l);
+ Parrot_gc_allocate_string_storage(interp, s, l);
}
}
out_buf = (unsigned char*)s->strstart + s->strlen;
@@ -533,10 +533,10 @@
}
if (s->bufused < l) {
if (s->strstart) {
- Parrot_reallocate_string(interp, s, l);
+ Parrot_gc_reallocate_string_storage(interp, s, l);
}
else {
- Parrot_allocate_string(interp, s, l);
+ Parrot_gc_allocate_string_storage(interp, s, l);
}
}
out_buf = (unsigned char*)s->strstart + s->strlen;
Modified: branches/gc_api/src/io/filehandle.c
==============================================================================
--- branches/gc_api/src/io/filehandle.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/io/filehandle.c Sat May 9 11:38:17 2009 (r38630)
@@ -126,7 +126,7 @@
else {
STRING *s = *buf;
if (s->bufused < len)
- Parrot_reallocate_string(interp, s, len);
+ Parrot_gc_reallocate_string_storage(interp, s, len);
return s;
}
}
Modified: branches/gc_api/src/list.c
==============================================================================
--- branches/gc_api/src/list.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/list.c Sat May 9 11:38:17 2009 (r38630)
@@ -367,7 +367,7 @@
chunk->n_items = 0;
chunk->next = NULL;
chunk->prev = NULL;
- Parrot_allocate_aligned(interp, (Buffer *)chunk, size);
+ Parrot_gc_allocate_aligned(interp, (Buffer *)chunk, size);
memset(PObj_bufstart((Buffer*)chunk), 0, size);
/* see also src/hash.c */
Modified: branches/gc_api/src/ops/core.ops
==============================================================================
--- branches/gc_api/src/ops/core.ops Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/ops/core.ops Sat May 9 11:38:17 2009 (r38630)
@@ -1258,7 +1258,7 @@
=cut
op collect() {
- Parrot_go_collect(interp);
+ Parrot_gc_compact_memory_pool(interp);
}
=item B<sweepoff>()
Modified: branches/gc_api/src/pmc_freeze.c
==============================================================================
--- branches/gc_api/src/pmc_freeze.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/pmc_freeze.c Sat May 9 11:38:17 2009 (r38630)
@@ -481,7 +481,7 @@
size_t new_size = (size_t) (PObj_buflen(s) * 1.5);
if (new_size < PObj_buflen(s) - need_free + 512)
new_size = PObj_buflen(s) - need_free + 512;
- Parrot_reallocate_string(interp, s, new_size);
+ Parrot_gc_reallocate_string_storage(interp, s, new_size);
PARROT_ASSERT(PObj_buflen(s) - used - len >= 15);
}
mem_sys_memcopy((void *)((ptrcast_t)s->strstart + used), b, len);
@@ -729,11 +729,11 @@
size_t new_size = (size_t) (PObj_buflen(s) * 1.5);
if (new_size < PObj_buflen(s) - need_free + 512)
new_size = PObj_buflen(s) - need_free + 512;
- Parrot_reallocate_string(interp, s, new_size);
+ Parrot_gc_reallocate_string_storage(interp, s, new_size);
PARROT_ASSERT(PObj_buflen(s) - used - len >= 15);
}
#ifndef DISABLE_GC_DEBUG
- Parrot_go_collect(interp);
+ Parrot_gc_compact_memory_pool(interp);
#endif
}
Modified: branches/gc_api/src/string/api.c
==============================================================================
--- branches/gc_api/src/string/api.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/string/api.c Sat May 9 11:38:17 2009 (r38630)
@@ -88,7 +88,7 @@
* also be sure not to allocate from the constant pool
*/
PObj_flags_CLEARALL(&for_alloc);
- Parrot_allocate_string(interp, &for_alloc, PObj_buflen(s));
+ Parrot_gc_allocate_string_storage(interp, &for_alloc, PObj_buflen(s));
/* now copy memory over */
mem_sys_memcopy(for_alloc.strstart, s->strstart, s->bufused);
@@ -147,7 +147,7 @@
/* XXX FIXME hack to avoid cross-interpreter issue until it
* is fixed correctly. */
if (n_interpreters > 1 && PObj_is_movable_TESTALL(s) &&
- !Parrot_in_memory_pool(interp, PObj_bufstart(s))) {
+ !Parrot_gc_ptr_in_memory_pool(interp, PObj_bufstart(s))) {
Parrot_str_write_COW(interp, d);
Parrot_io_eprintf(interp, "cross-interpreter copy of "
"relocatable string '%Ss' into tid %d\n",
@@ -392,7 +392,7 @@
s->charset = PARROT_DEFAULT_CHARSET;
s->encoding = CHARSET_GET_PREFERRED_ENCODING(interp, s);
- Parrot_allocate_string(interp, s,
+ Parrot_gc_allocate_string_storage(interp, s,
(size_t)string_max_bytes(interp, s, capacity));
return s;
@@ -786,7 +786,7 @@
return s;
}
- Parrot_allocate_string(interp, s, len);
+ Parrot_gc_allocate_string_storage(interp, s, len);
if (buffer) {
mem_sys_memcopy(s->strstart, buffer, len);
@@ -2334,7 +2334,7 @@
* We have to block GC here, as we have a pointer to bufstart
*/
Parrot_block_GC_sweep(interp);
- Parrot_allocate_string(interp, s, size);
+ Parrot_gc_allocate_string_storage(interp, s, size);
Parrot_unblock_GC_sweep(interp);
mem_sys_memcopy(PObj_bufstart(s), memory, size);
Modified: branches/gc_api/src/string/charset/ascii.c
==============================================================================
--- branches/gc_api/src/string/charset/ascii.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/string/charset/ascii.c Sat May 9 11:38:17 2009 (r38630)
@@ -268,7 +268,7 @@
const UINTVAL len = src->strlen;
if (dest) {
- Parrot_reallocate_string(interp, dest, len);
+ Parrot_gc_reallocate_string_storage(interp, dest, len);
}
else {
/* the string can't grow - replace inplace */
@@ -308,7 +308,7 @@
if (dest) {
dest->charset = Parrot_unicode_charset_ptr;
dest->encoding = CHARSET_GET_PREFERRED_ENCODING(interp, dest);
- Parrot_reallocate_string(interp, dest, src->strlen);
+ Parrot_gc_reallocate_string_storage(interp, dest, src->strlen);
return dest;
}
else {
@@ -913,7 +913,7 @@
if (dest) {
UINTVAL offs;
- Parrot_reallocate_string(interp, dest, src->strlen);
+ Parrot_gc_reallocate_string_storage(interp, dest, src->strlen);
dest->bufused = src->bufused;
dest->strlen = src->strlen;
for (offs = 0; offs < src->strlen; ++offs) {
@@ -946,7 +946,7 @@
if (dest) {
UINTVAL offs;
- Parrot_reallocate_string(interp, dest, src->strlen);
+ Parrot_gc_reallocate_string_storage(interp, dest, src->strlen);
dest->bufused = src->bufused;
dest->strlen = src->strlen;
for (offs = 0; offs < src->strlen; ++offs) {
Modified: branches/gc_api/src/string/charset/iso-8859-1.c
==============================================================================
--- branches/gc_api/src/string/charset/iso-8859-1.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/string/charset/iso-8859-1.c Sat May 9 11:38:17 2009 (r38630)
@@ -221,7 +221,7 @@
ENCODING_ITER_INIT(interp, src, &iter);
src_len = src->strlen;
if (dest) {
- Parrot_reallocate_string(interp, dest, src_len);
+ Parrot_gc_reallocate_string_storage(interp, dest, src_len);
dest->strlen = src_len;
}
else {
@@ -263,7 +263,7 @@
dest->charset = Parrot_unicode_charset_ptr;
dest->encoding = CHARSET_GET_PREFERRED_ENCODING(interp, dest);
- Parrot_reallocate_string(interp, dest, src->strlen);
+ Parrot_gc_reallocate_string_storage(interp, dest, src->strlen);
ENCODING_ITER_INIT(interp, dest, &iter);
for (offs = 0; offs < src->strlen; ++offs) {
const UINTVAL c = ENCODING_GET_BYTE(interp, src, offs);
@@ -272,7 +272,7 @@
UINTVAL need = (UINTVAL)((src->strlen - offs) * 1.5);
if (need < 16)
need = 16;
- Parrot_reallocate_string(interp, dest,
+ Parrot_gc_reallocate_string_storage(interp, dest,
PObj_buflen(dest) + need);
}
iter.set_and_advance(interp, &iter, c);
@@ -731,7 +731,7 @@
ASSERT_ARGS(charset_cvt_iso_8859_1_to_ascii)
UINTVAL offs;
if (dest) {
- Parrot_reallocate_string(interp, dest, src->strlen);
+ Parrot_gc_reallocate_string_storage(interp, dest, src->strlen);
dest->bufused = src->bufused;
dest->strlen = src->strlen;
}
Modified: branches/gc_api/src/string/charset/unicode.c
==============================================================================
--- branches/gc_api/src/string/charset/unicode.c Sat May 9 07:52:24 2009 (r38629)
+++ branches/gc_api/src/string/charset/unicode.c Sat May 9 11:38:17 2009 (r38630)
@@ -360,7 +360,7 @@
if (!U_SUCCESS(err)) {
err = U_ZERO_ERROR;
- Parrot_reallocate_string(interp, dest, dest->bufused);
+ Parrot_gc_reallocate_string_storage(interp, dest, dest->bufused);
dest_len = unorm_normalize((UChar *)src->strstart, src_len,
UNORM_DEFAULT, /* default is NFC */
0, /* options 0 default - no specific
@@ -464,7 +464,7 @@
&err);
if (needed > dest_len) {
- Parrot_reallocate_string(interp, src, needed * sizeof (UChar));
+ Parrot_gc_reallocate_string_storage(interp, src, needed * sizeof (UChar));
dest_len = needed;
}
@@ -539,7 +539,7 @@
if (!U_SUCCESS(err)) {
err = U_ZERO_ERROR;
- Parrot_reallocate_string(interp, src, src->bufused);
+ Parrot_gc_reallocate_string_storage(interp, src, src->bufused);
dest_len = u_strToLower((UChar *)src->strstart, dest_len,
(UChar *)src->strstart, src_len,
NULL, /* locale = default */
@@ -607,7 +607,7 @@
if (!U_SUCCESS(err)) {
err = U_ZERO_ERROR;
- Parrot_reallocate_string(interp, src, src->bufused);
+ Parrot_gc_reallocate_string_storage(interp, src, src->bufused);
dest_len = u_strToTitle((UChar *)src->strstart, dest_len,
(UChar *)src->strstart, src_len,
NULL, NULL,
More information about the parrot-commits
mailing list