[svn:parrot] r38654 - in trunk: . config/auto/sizes config/gen docs docs/book docs/book/draft docs/dev docs/pdds examples/languages/abc examples/languages/squaak include/parrot ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/library/Math src src/call src/dynpmc src/gc src/interp src/io src/ops src/pmc src/runcore src/string src/string/charset src/string/encoding t/compilers/tge t/dynpmc t/src tools/dev tools/util

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat May 9 20:02:28 UTC 2009


Author: whiteknight
Date: Sat May  9 20:02:23 2009
New Revision: 38654
URL: https://trac.parrot.org/parrot/changeset/38654

Log:
[gc_api] Behold! Parrot is entering an age of slightly less lousy GC! Merging the gc_api branch into trunk, all tests pass.

Deleted:
   trunk/include/parrot/gc_mark_sweep.h
   trunk/include/parrot/gc_pools.h
   trunk/include/parrot/resources.h
Modified:
   trunk/   (props changed)
   trunk/MANIFEST
   trunk/config/auto/sizes/intval_maxmin_c.in   (props changed)
   trunk/config/gen/parrot_include.pm
   trunk/docs/book/appb_patch_submission.pod   (props changed)
   trunk/docs/book/ch01_introduction.pod   (props changed)
   trunk/docs/book/ch03_pir.pod   (props changed)
   trunk/docs/book/ch04_compiler_tools.pod   (props changed)
   trunk/docs/book/ch07_dynpmcs.pod   (props changed)
   trunk/docs/book/ch08_dynops.pod   (props changed)
   trunk/docs/book/ch09_pasm.pod   (props changed)
   trunk/docs/book/ch10_opcode_reference.pod   (props changed)
   trunk/docs/book/draft/chXX_hlls.pod   (props changed)
   trunk/docs/book/draft/chXX_library.pod   (props changed)
   trunk/docs/book/draft/chXX_testing_and_debugging.pod   (props changed)
   trunk/docs/dev/c_functions.pod   (props changed)
   trunk/docs/dev/pmc_freeze.pod
   trunk/docs/pdds/pdd09_gc.pod
   trunk/docs/pdds/pdd30_install.pod   (props changed)
   trunk/docs/pmc.pod
   trunk/examples/languages/abc/   (props changed)
   trunk/examples/languages/squaak/   (props changed)
   trunk/include/parrot/call.h   (props changed)
   trunk/include/parrot/gc_api.h   (contents, props changed)
   trunk/include/parrot/memory.h
   trunk/include/parrot/parrot.h
   trunk/include/parrot/runcore_api.h   (props changed)
   trunk/include/parrot/runcore_trace.h   (props changed)
   trunk/include/parrot/stacks.h
   trunk/ports/cpan/pause_guide.pod   (props changed)
   trunk/ports/cygwin/parrot-1.0.0-1.cygport   (props changed)
   trunk/ports/debian/libparrot-dev.install.in   (props changed)
   trunk/ports/debian/libparrot.install.in   (props changed)
   trunk/ports/debian/parrot-doc.install.in   (props changed)
   trunk/ports/debian/parrot.install.in   (props changed)
   trunk/ports/fedora/parrot.spec.fedora   (props changed)
   trunk/ports/mandriva/parrot.spec.mandriva   (props changed)
   trunk/ports/suse/parrot.spec.suse   (props changed)
   trunk/runtime/parrot/library/Math/Rand.pir   (props changed)
   trunk/src/call/ops.c   (props changed)
   trunk/src/call/pcc.c   (props changed)
   trunk/src/dynpmc/dynlexpad.pmc
   trunk/src/dynpmc/pair.pmc
   trunk/src/gc/api.c   (contents, props changed)
   trunk/src/gc/gc_private.h
   trunk/src/gc/generational_ms.c   (contents, props changed)
   trunk/src/gc/incremental_ms.c   (contents, props changed)
   trunk/src/gc/mark_sweep.c   (contents, props changed)
   trunk/src/gc/memory.c
   trunk/src/gc/pools.c   (contents, props changed)
   trunk/src/gc/res_lea.c
   trunk/src/gc/resources.c
   trunk/src/gc/system.c   (contents, props changed)
   trunk/src/hash.c
   trunk/src/interp/inter_cb.c   (contents, props changed)
   trunk/src/interp/inter_create.c   (contents, props changed)
   trunk/src/interp/inter_misc.c   (contents, props changed)
   trunk/src/io/buffer.c
   trunk/src/io/core.c
   trunk/src/io/filehandle.c
   trunk/src/io/utf8.c
   trunk/src/key.c
   trunk/src/list.c
   trunk/src/oo.c
   trunk/src/ops/core.ops
   trunk/src/ops/string.ops
   trunk/src/packfile.c
   trunk/src/pmc.c
   trunk/src/pmc/array.pmc
   trunk/src/pmc/callsignature.pmc
   trunk/src/pmc/capture.pmc
   trunk/src/pmc/class.pmc
   trunk/src/pmc/cpointer.pmc
   trunk/src/pmc/default.pmc
   trunk/src/pmc/eval.pmc
   trunk/src/pmc/eventhandler.pmc
   trunk/src/pmc/exception.pmc
   trunk/src/pmc/exceptionhandler.pmc
   trunk/src/pmc/exporter.pmc
   trunk/src/pmc/filehandle.pmc
   trunk/src/pmc/fixedpmcarray.pmc
   trunk/src/pmc/fixedstringarray.pmc
   trunk/src/pmc/iterator.pmc
   trunk/src/pmc/namespace.pmc
   trunk/src/pmc/nci.pmc
   trunk/src/pmc/object.pmc
   trunk/src/pmc/orderedhash.pmc
   trunk/src/pmc/packfile.pmc
   trunk/src/pmc/packfileannotationkeys.pmc
   trunk/src/pmc/packfileannotations.pmc
   trunk/src/pmc/packfileconstanttable.pmc
   trunk/src/pmc/packfiledirectory.pmc
   trunk/src/pmc/packfilefixupentry.pmc
   trunk/src/pmc/packfilefixuptable.pmc
   trunk/src/pmc/packfilerawsegment.pmc
   trunk/src/pmc/packfilesegment.pmc
   trunk/src/pmc/parrotinterpreter.pmc
   trunk/src/pmc/pmcproxy.pmc
   trunk/src/pmc/retcontinuation.pmc
   trunk/src/pmc/role.pmc
   trunk/src/pmc/scalar.pmc
   trunk/src/pmc/scheduler.pmc
   trunk/src/pmc/schedulermessage.pmc
   trunk/src/pmc/socket.pmc
   trunk/src/pmc/string.pmc
   trunk/src/pmc/stringhandle.pmc
   trunk/src/pmc/sub.pmc
   trunk/src/pmc/task.pmc
   trunk/src/pmc/unmanagedstruct.pmc
   trunk/src/pmc_freeze.c
   trunk/src/runcore/cores.c   (contents, props changed)
   trunk/src/runcore/main.c   (props changed)
   trunk/src/runcore/trace.c   (props changed)
   trunk/src/stacks.c
   trunk/src/string/api.c
   trunk/src/string/charset/ascii.c
   trunk/src/string/charset/iso-8859-1.c
   trunk/src/string/charset/unicode.c
   trunk/src/string/encoding/utf16.c
   trunk/src/string/encoding/utf8.c
   trunk/src/sub.c
   trunk/src/thread.c
   trunk/src/vtables.c
   trunk/t/compilers/tge/NoneGrammar.tg   (props changed)
   trunk/t/dynpmc/pair.t   (props changed)
   trunk/t/src/embed.t   (props changed)
   trunk/tools/dev/fetch_languages.pl   (props changed)
   trunk/tools/dev/mk_gitignore.pl   (props changed)
   trunk/tools/util/perlcritic-cage.conf   (props changed)

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/MANIFEST	Sat May  9 20:02:23 2009	(r38654)
@@ -950,8 +950,6 @@
 include/parrot/exit.h                                       [main]include
 include/parrot/extend.h                                     [main]include
 include/parrot/gc_api.h                                     [main]include
-include/parrot/gc_mark_sweep.h                              [main]include
-include/parrot/gc_pools.h                                   [main]include
 include/parrot/global.h                                     [main]include
 include/parrot/global_setup.h                               [main]include
 include/parrot/hash.h                                       [main]include
@@ -981,7 +979,6 @@
 include/parrot/pmc_freeze.h                                 [main]include
 include/parrot/pobj.h                                       [main]include
 include/parrot/register.h                                   [main]include
-include/parrot/resources.h                                  [main]include
 include/parrot/runcore_api.h                                [main]include
 include/parrot/runcore_trace.h                              [main]include
 include/parrot/scheduler.h                                  [main]include

Modified: trunk/config/gen/parrot_include.pm
==============================================================================
--- trunk/config/gen/parrot_include.pm	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/config/gen/parrot_include.pm	Sat May  9 20:02:23 2009	(r38654)
@@ -38,11 +38,11 @@
         include/parrot/longopt.h
         include/parrot/multidispatch.h
         include/parrot/packfile.h
-        include/parrot/resources.h
         include/parrot/stat.h
         include/parrot/string.h
         include/parrot/pmc.h
         include/parrot/warnings.h
+        include/parrot/gc_api.h
         src/pmc/timer.pmc
         src/utils.c
     ) ];

Modified: trunk/docs/dev/pmc_freeze.pod
==============================================================================
--- trunk/docs/dev/pmc_freeze.pod	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/docs/dev/pmc_freeze.pod	Sat May  9 20:02:23 2009	(r38654)
@@ -58,7 +58,7 @@
 
 =item mark
 
-Mark all objects as being live by calling B<pobject_lives> called from GC.
+Mark all objects as being live by calling B<Parrot_gc_mark_PObj_alive> called from GC.
 While the functionality is the same, it will not be implemented on top of this
 general scheme for performance reasons. This leads to some code duplication,
 but GC is run permanently and deserves all the speed it can get.

Modified: trunk/docs/pdds/pdd09_gc.pod
==============================================================================
--- trunk/docs/pdds/pdd09_gc.pod	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/docs/pdds/pdd09_gc.pod	Sat May  9 20:02:23 2009	(r38654)
@@ -380,7 +380,7 @@
 For a concurrent collector, calls to this function may activate a concurrent
 collection thread or, if such a thread is already running, do nothing at all.
 
-The C<do_gc_mark> function is called from the C<Parrot_do_gc_run> function,
+The C<do_gc_mark> function is called from the C<Parrot_gc_mark_and_sweep> function,
 and should not usually be called directly.
 
 C<flags> is one of:
@@ -570,7 +570,7 @@
 =item PObj_custom_mark_FLAG
 
 The C<mark> vtable slot will be called during the GC mark phase. The mark
-function must call C<pobject_lives> for all non-NULL objects (Buffers and
+function must call C<Parrot_gc_mark_PObj_alive> for all non-NULL objects (Buffers and
 PMCs) that PMC refers to. This flag is typically tested and the custom mark
 VTABLE method called from C<src/gc/api.c:mark_special>.
 

Modified: trunk/docs/pmc.pod
==============================================================================
--- trunk/docs/pmc.pod	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/docs/pmc.pod	Sat May  9 20:02:23 2009	(r38654)
@@ -87,7 +87,7 @@
 =head1 PMCs and GC
 
 The GC system doesn't make any assumptions about your PMC's layout. Whenever a
-PMC is found in the root set, B<pobject_lives()> is called with that PMC.  The
+PMC is found in the root set, B<Parrot_gc_mark_PObj_alive()> is called with that PMC.  The
 PMC is responsible to mark all contained or referenced active Parrot objects
 (Buffers, STRINGs or other PMCs) when its C<mark()> VTABLE function is called.
 
@@ -107,7 +107,7 @@
 
 If your PMC contains any other B<PObj>s (STRINGs, PMCs, etc), your PMC must
 implement the B<mark()> VTABLE function and set this flag.  The B<mark()>
-VTABLE function must call B<pobject_lives()> on all B<PObj>s which your PMC
+VTABLE function must call B<Parrot_gc_mark_PObj_alive()> on all B<PObj>s which your PMC
 contains.
 
 =item PObj_active_destroy_FLAG

Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/include/parrot/gc_api.h	Sat May  9 20:02:23 2009	(r38654)
@@ -15,36 +15,117 @@
  * Please note: these objects might be bogus */
 #define GC_VERBOSE 0
 
-#include "parrot/gc_mark_sweep.h"
 #include "parrot/parrot.h"
 
-/* Macros for recursively blocking and unblocking GC mark */
-#define Parrot_block_GC_mark(interp) \
-        { \
-            (interp)->arena_base->gc_mark_block_level++; \
-            Parrot_shared_gc_block(interp); \
-        }
-
-#define Parrot_unblock_GC_mark(interp) \
-        if ((interp)->arena_base->gc_mark_block_level) { \
-            (interp)->arena_base->gc_mark_block_level--; \
-            Parrot_shared_gc_unblock(interp); \
-        }
-
-/* Macros for recursively blocking and unblocking GC sweep */
-#define Parrot_block_GC_sweep(interp) \
-        (interp)->arena_base->gc_sweep_block_level++
-
-#define Parrot_unblock_GC_sweep(interp) \
-        if ((interp)->arena_base->gc_sweep_block_level) \
-            (interp)->arena_base->gc_sweep_block_level--
-
-/* Macros for testing if the GC mark and sweep are blocked */
-#define Parrot_is_blocked_GC_mark(interp) \
-        ((interp)->arena_base->gc_mark_block_level)
+/*
+ * we need an alignment that is the same as malloc(3) have for
+ * allocating Buffer items like FLOATVAL (double)
+ * This should be either a config hint or tested
+ */
+#ifdef MALLOC_ALIGNMENT
+#  define BUFFER_ALIGNMENT MALLOC_ALIGNMENT
+#else
+/* or (2 * sizeof (size_t)) */
+#  define BUFFER_ALIGNMENT 8
+#endif
+
+#define BUFFER_ALIGN_1 (BUFFER_ALIGNMENT - 1)
+#define BUFFER_ALIGN_MASK ~BUFFER_ALIGN_1
+
+#define WORD_ALIGN_1 (sizeof (void *) - 1)
+#define WORD_ALIGN_MASK ~WORD_ALIGN_1
+
+/* pool iteration */
+typedef enum {
+    POOL_PMC    = 0x01,
+    POOL_BUFFER = 0x02,
+    POOL_CONST  = 0x04,
+    POOL_ALL    = 0x07
+} pool_iter_enum;
+
+struct Small_Object_Pool;
+struct Small_Object_Arena;
+struct Arenas;
+
+typedef int (*pool_iter_fn)(PARROT_INTERP, struct Small_Object_Pool *, int, void*);
+
+typedef struct Memory_Block {
+    size_t free;
+    size_t size;
+    struct Memory_Block *prev;
+    struct Memory_Block *next;
+    char *start;
+    char *top;
+} Memory_Block;
+
+typedef struct Memory_Pool {
+    Memory_Block *top_block;
+    void (*compact)(PARROT_INTERP, struct Memory_Pool *);
+    size_t minimum_block_size;
+    size_t total_allocated; /* total bytes allocated to this pool */
+    size_t guaranteed_reclaimable;     /* bytes that can definitely be reclaimed*/
+    size_t possibly_reclaimable;     /* bytes that can possibly be reclaimed
+                                      * (above plus COW-freed bytes) */
+    FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */
+} Memory_Pool;
+
+typedef enum {
+    GC_TRACE_FULL,
+    GC_TRACE_ROOT_ONLY,
+    GC_TRACE_SYSTEM_ONLY
+} Parrot_gc_trace_type;
+
+typedef void (*add_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, void *);
+typedef void * (*get_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
+typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
+typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *);
+
+/*
+ * macros used in arena scan code to convert from object pointers
+ * to arena pointers ...
+ */
+
+#if PARROT_GC_GMS
+#  define GC_HEADER_SIZE (sizeof (Gc_gms_hdr))
+#  define PObj_to_ARENA(o) PObj_to_GMSH(o)
+#  define ARENA_to_PObj(p) GMSH_to_PObj((Gc_gms_hdr*)(p))
+#else
+#  define GC_HEADER_SIZE 0
+#  define PObj_to_ARENA(o) (o)
+#  define ARENA_to_PObj(p) (p)
+#endif
 
-#define Parrot_is_blocked_GC_sweep(interp) \
-        ((interp)->arena_base->gc_sweep_block_level)
+/* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */
+
+typedef enum {
+    TOTAL_MEM_ALLOC = 1,
+    GC_MARK_RUNS,
+    GC_COLLECT_RUNS,
+    ACTIVE_PMCS,
+    ACTIVE_BUFFERS,
+    TOTAL_PMCS,
+    TOTAL_BUFFERS,
+    HEADER_ALLOCS_SINCE_COLLECT,
+    MEM_ALLOCS_SINCE_COLLECT,
+    TOTAL_COPIED,
+    IMPATIENT_PMCS,
+    GC_LAZY_MARK_RUNS,
+    EXTENDED_PMCS,
+    CURRENT_RUNCORE,
+
+    /* interpinfo_p constants */
+    CURRENT_SUB,
+    CURRENT_CONT,
+    CURRENT_OBJECT,
+    CURRENT_LEXPAD,
+
+    /* interpinfo_s constants */
+    EXECUTABLE_FULLNAME,
+    EXECUTABLE_BASENAME,
+    RUNTIME_PREFIX
+} Interpinfo_enum;
+
+/* &end_gen */
 
 #define GC_trace_stack_FLAG    (UINTVAL)(1 << 0)   /* trace system areas and stack */
 #define GC_trace_normal        (UINTVAL)(1 << 0)   /* the same */
@@ -55,195 +136,325 @@
 /* HEADERIZER BEGIN: src/gc/api.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-void add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
+PARROT_EXPORT
+void Parrot_block_GC_mark(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_block_GC_sweep(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*obj);
+
+PARROT_EXPORT
+unsigned int Parrot_is_blocked_GC_mark(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+unsigned int Parrot_is_blocked_GC_sweep(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_unblock_GC_mark(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void Parrot_unblock_GC_sweep(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+int Parrot_gc_active_pmcs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+int Parrot_gc_active_sized_buffers(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 add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
+void Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-Buffer * new_buffer_header(PARROT_INTERP)
+void Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP,
+    ARGOUT(Buffer *buffer),
+    size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
+
+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_gc_cleanup_next_for_GC(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_compact_memory_pool(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_completely_unblock(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+size_t Parrot_gc_count_collect_runs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+size_t Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+size_t Parrot_gc_count_mark_runs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_destroy_header_pools(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_destroy_memory_pools(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+UINTVAL Parrot_gc_extended_pmcs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_finalize(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_free_bufferlike_header(PARROT_INTERP,
+    ARGMOD(PObj *obj),
+    size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*obj);
+
+void Parrot_gc_free_pmc_ext(PARROT_INTERP, ARGMOD(PMC *p))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*p);
+
+void Parrot_gc_free_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pmc);
+
+void Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*s);
+
+int Parrot_gc_get_pmc_index(PARROT_INTERP, ARGIN(PMC* pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+size_t Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+UINTVAL Parrot_gc_impatient_pmcs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
+void Parrot_gc_initialize(PARROT_INTERP, ARGIN(void *stacktop))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
+        __attribute__nonnull__(1);
+
+size_t Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)
+        __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 * new_bufferlike_header(PARROT_INTERP, size_t size)
+void * Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size)
         __attribute__nonnull__(1);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC * new_pmc_header(PARROT_INTERP, UINTVAL flags)
+PMC * Parrot_gc_new_pmc_header(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-STRING * new_string_header(PARROT_INTERP, UINTVAL flags)
-        __attribute__nonnull__(1);
-
-void Parrot_do_gc_run(PARROT_INTERP, UINTVAL flags)
+STRING * Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 
-void Parrot_gc_free_buffer(SHIM_INTERP,
-    ARGMOD(Small_Object_Pool *pool),
-    ARGMOD(PObj *b))
+void Parrot_gc_pmc_needs_early_collection(PARROT_INTERP, ARGMOD(PMC *pmc))
+        __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*pool)
-        FUNC_MODIFIES(*b);
+        FUNC_MODIFIES(*pmc);
 
-void Parrot_gc_free_buffer_malloc(SHIM_INTERP,
-    SHIM(Small_Object_Pool *pool),
-    ARGMOD(PObj *b))
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*b);
+PARROT_WARN_UNUSED_RESULT
+int Parrot_gc_ptr_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
-void Parrot_gc_free_pmc(PARROT_INTERP,
-    SHIM(Small_Object_Pool *pool),
-    ARGMOD(PObj *p))
+int Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*p);
+        __attribute__nonnull__(2);
 
-void Parrot_gc_free_pmc_ext(PARROT_INTERP, ARGMOD(PMC *p))
+void Parrot_gc_reallocate_buffer_storage(PARROT_INTERP,
+    ARGMOD(Buffer *buffer),
+    size_t newsize)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        FUNC_MODIFIES(*p);
+        FUNC_MODIFIES(*buffer);
 
-void Parrot_gc_free_sysmem(SHIM_INTERP,
-    SHIM(Small_Object_Pool *pool),
-    ARGMOD(PObj *b))
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*b);
+void Parrot_gc_reallocate_string_storage(PARROT_INTERP,
+    ARGMOD(STRING *str),
+    size_t newsize)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*str);
+
+UINTVAL Parrot_gc_total_copied(PARROT_INTERP)
+        __attribute__nonnull__(1);
 
-void Parrot_gc_ms_run_init(PARROT_INTERP)
+size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void Parrot_gc_profile_end(PARROT_INTERP, int what)
+int Parrot_gc_total_pmcs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void Parrot_gc_profile_start(PARROT_INTERP)
+int Parrot_gc_total_sized_buffers(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-#define ASSERT_ARGS_add_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_block_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_block_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#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_is_blocked_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_is_blocked_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_unblock_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_unblock_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_active_pmcs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_active_sized_buffers \
+     __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_add_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#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_new_buffer_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_allocate_buffer_storage_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_completely_unblock __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_count_collect_runs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_count_lazy_mark_runs \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_count_mark_runs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_bufferlike_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_destroy_header_pools \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_destroy_memory_pools \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_extended_pmcs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_do_gc_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_finalize __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(pool) \
-    || PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_Parrot_gc_free_buffer_malloc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_Parrot_gc_free_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_free_bufferlike_header \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(p)
+    || PARROT_ASSERT_ARG(obj)
 #define ASSERT_ARGS_Parrot_gc_free_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(p)
-#define ASSERT_ARGS_Parrot_gc_free_sysmem __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_Parrot_gc_ms_run_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_gc_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(s)
+#define ASSERT_ARGS_Parrot_gc_get_pmc_index __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_gc_headers_alloc_since_last_collect \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_profile_end __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_impatient_pmcs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_profile_start __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_initialize __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(stacktop)
+#define ASSERT_ARGS_Parrot_gc_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-/* HEADERIZER END: src/gc/api.c */
-
-/* GC subsystem init functions */
-/* HEADERIZER BEGIN: src/gc/generational_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-PARROT_EXPORT
-void Parrot_gc_gms_init(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void parrot_gc_gms_pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*obj);
-
-void parrot_gc_gms_wb(PARROT_INTERP,
-    ARGIN(PMC *agg),
-    ARGIN(void *old),
-    ARGIN(void *_new))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        __attribute__nonnull__(4);
-
-void parrot_gc_gms_wb_key(PARROT_INTERP,
-    ARGIN(PMC *agg),
-    ARGIN(void *old),
-    ARGIN(void *old_key),
-    ARGIN(void *_new),
-    ARGIN(void *new_key))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        __attribute__nonnull__(4)
-        __attribute__nonnull__(5)
-        __attribute__nonnull__(6);
-
-#define ASSERT_ARGS_Parrot_gc_gms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#define ASSERT_ARGS_Parrot_gc_mem_alloc_since_last_collect \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_parrot_gc_gms_pobject_lives __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#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)
+#define ASSERT_ARGS_Parrot_gc_new_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       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_pmc_needs_early_collection \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(obj)
-#define ASSERT_ARGS_parrot_gc_gms_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+    || PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_gc_ptr_in_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(agg) \
-    || PARROT_ASSERT_ARG(old) \
-    || PARROT_ASSERT_ARG(_new)
-#define ASSERT_ARGS_parrot_gc_gms_wb_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(agg) \
-    || PARROT_ASSERT_ARG(old) \
-    || PARROT_ASSERT_ARG(old_key) \
-    || PARROT_ASSERT_ARG(_new) \
-    || PARROT_ASSERT_ARG(new_key)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-/* HEADERIZER END: src/gc/generational_ms.c */
-
-/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-void Parrot_gc_ims_init(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-void Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*agg)
-        FUNC_MODIFIES(*_new);
-
-#define ASSERT_ARGS_Parrot_gc_ims_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ims_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+    || 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_gc_reallocate_buffer_storage \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(buffer)
+#define ASSERT_ARGS_Parrot_gc_reallocate_string_storage \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(agg) \
-    || PARROT_ASSERT_ARG(_new)
+    || PARROT_ASSERT_ARG(str)
+#define ASSERT_ARGS_Parrot_gc_total_copied __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_total_memory_allocated \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_total_pmcs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-/* HEADERIZER END: src/gc/incremental_ms.c */
+/* HEADERIZER END: src/gc/api.c */
 
 /* write barrier */
 #if PARROT_GC_MS

Deleted: trunk/include/parrot/gc_mark_sweep.h
==============================================================================
--- trunk/include/parrot/gc_mark_sweep.h	Sat May  9 20:02:23 2009	(r38653)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,269 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2002-2008, Parrot Foundation.
- */
-
-#ifndef PARROT_GC_MARK_SWEEP_H_GUARD
-#define PARROT_GC_MARK_SWEEP_H_GUARD
-
-#  include "parrot/parrot.h"
-
-typedef struct Small_Object_Arena {
-    size_t                     used;
-    size_t                     total_objects;
-    struct Small_Object_Arena *prev;
-    struct Small_Object_Arena *next;
-    void                      *start_objects;
-} Small_Object_Arena;
-
-struct Small_Object_Pool;
-
-typedef enum {
-    GC_TRACE_FULL,
-    GC_TRACE_ROOT_ONLY,
-    GC_TRACE_SYSTEM_ONLY
-} Parrot_gc_trace_type;
-
-typedef void (*add_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, void *);
-typedef void * (*get_free_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
-typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *);
-typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *);
-
-#if PARROT_GC_GMS
-/*
- * all objects have this header in front of the actual
- * object pointer. The prev/next pointers chain all existing
- * objects for one pool (sizeclass) together.
- *
- * XXX this could lead to unaligned FLOATVALs in the adjacent PMC
- *     if that's true either insert a dummy or reorder PMC members
- *     ??? How is that possible?
- */
-typedef struct _gc_gms_hdr {
-    struct _gc_gms_hdr *prev;
-    struct _gc_gms_hdr *next;
-    struct _gc_gms_gen *gen;
-    void *gc_dummy_align;       /* see above */
-} Gc_gms_hdr;
-
-#  define PObj_to_GMSH(o) (((Gc_gms_hdr*)(o))-1)
-#  define GMSH_to_PObj(p) ((PObj*) ((p)+1))
-
-/* the structure uses 2 ptrs itself */
-#  define GC_GMS_STORE_SIZE (64-2)
-
-typedef struct _gc_gms_hdr_store {
-    struct _gc_gms_hdr_store *next;
-    Gc_gms_hdr **ptr;                           /* insert location */
-    Gc_gms_hdr * (store[GC_GMS_STORE_SIZE]);    /* array of hdr pointers */
-} Gc_gms_hdr_store;
-
-typedef struct _gc_gms_hdr_list {
-    Gc_gms_hdr_store *first;
-    Gc_gms_hdr_store *last;
-} Gc_gms_hdr_list;
-
-
-/*
- * all objects belong to one generation
- */
-typedef struct _gc_gms_gen {
-    UINTVAL gen_no;                     /* generation number */
-    UINTVAL timely_destruct_obj_sofar;  /* sum up to this generation */
-    UINTVAL black_color;                /* live color of this generation */
-    struct _gc_gms_hdr *first;          /* first header in this generation */
-    struct _gc_gms_hdr *last;           /* last header in this generation */
-    struct _gc_gms_hdr *fin;            /* need destruction/finalization */
-    struct Small_Object_Pool *pool;     /* where this generation belongs to */
-    Gc_gms_hdr_list igp;                /* IGPs for this generation */
-    UINTVAL n_possibly_dead;            /* overwritten count */
-    UINTVAL n_objects;                  /* live objects count */
-    struct _gc_gms_gen *prev;
-    struct _gc_gms_gen *next;
-} Gc_gms_gen;
-
-#endif /* PARROT_GC_GMS */
-
-/* Tracked resource pool */
-typedef struct Small_Object_Pool {
-    Small_Object_Arena *last_Arena;
-    /* Size in bytes of an individual pool item. This size may include
-     * a GC-system specific GC header.
-     * See the macros below.
-     */
-    size_t object_size;
-    size_t objects_per_alloc;
-    size_t total_objects;
-    size_t num_free_objects;    /* number of resources in the free pool */
-    int skip;
-    size_t replenish_level;
-    void *free_list;
-    /* adds a free object to the pool's free list  */
-    add_free_object_fn_type     add_free_object;
-    get_free_object_fn_type     get_free_object;
-    alloc_objects_fn_type       alloc_objects;
-    alloc_objects_fn_type       more_objects;
-    gc_object_fn_type           gc_object;
-    /* gets and removes a free object from the pool's free list */
-    /* allocates more objects */
-    struct Memory_Pool *mem_pool;
-    size_t start_arena_memory;
-    size_t end_arena_memory;
-    const char *name;
-#if PARROT_GC_GMS
-    struct _gc_gms_hdr marker;          /* limit of list */
-    struct _gc_gms_hdr *black;          /* alive */
-    struct _gc_gms_hdr *black_fin;      /* alive, needs destruction */
-    struct _gc_gms_hdr *gray;           /* to be scanned */
-    struct _gc_gms_hdr *white;          /* unprocessed */
-    struct _gc_gms_hdr *white_fin;      /* unprocesse, needs destruction */
-
-    struct _gc_gms_gen *first_gen;      /* linked list of generations */
-    struct _gc_gms_gen *last_gen;
-
-#endif
-} Small_Object_Pool;
-
-/*
- * macros used in arena scan code to convert from object pointers
- * to arena pointers ...
- */
-
-#if PARROT_GC_GMS
-#  define GC_HEADER_SIZE (sizeof (Gc_gms_hdr))
-#  define PObj_to_ARENA(o) PObj_to_GMSH(o)
-#  define ARENA_to_PObj(p) GMSH_to_PObj((Gc_gms_hdr*)(p))
-#else
-#  define GC_HEADER_SIZE 0
-#  define PObj_to_ARENA(o) (o)
-#  define ARENA_to_PObj(p) (p)
-#endif
-
-
-/* HEADERIZER BEGIN: src/gc/mark_sweep.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-PARROT_EXPORT
-void pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*obj);
-
-PARROT_WARN_UNUSED_RESULT
-INTVAL contained_in_pool(
-    ARGIN(const Small_Object_Pool *pool),
-    ARGIN(const void *ptr))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-void gc_pmc_ext_pool_init(ARGMOD(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        FUNC_MODIFIES(*pool);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * new_small_object_pool(
-    size_t object_size,
-    size_t objects_per_alloc);
-
-void Parrot_add_to_free_list(PARROT_INTERP,
-    ARGMOD(Small_Object_Pool *pool),
-    ARGMOD(Small_Object_Arena *arena))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*pool)
-        FUNC_MODIFIES(*arena);
-
-void Parrot_append_arena_in_pool(PARROT_INTERP,
-    ARGMOD(Small_Object_Pool *pool),
-    ARGMOD(Small_Object_Arena *new_arena),
-    size_t size)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*pool)
-        FUNC_MODIFIES(*new_arena);
-
-void Parrot_gc_clear_live_bits(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-void Parrot_gc_ms_init(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-void Parrot_gc_ms_run(PARROT_INTERP, UINTVAL flags)
-        __attribute__nonnull__(1);
-
-void Parrot_gc_sweep(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
-int Parrot_gc_trace_children(PARROT_INTERP, size_t how_many)
-        __attribute__nonnull__(1);
-
-int Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)
-        __attribute__nonnull__(1);
-
-int Parrot_is_const_pmc(PARROT_INTERP, ARGIN(const PMC *pmc))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-void Parrot_small_object_pool_merge(PARROT_INTERP,
-    ARGMOD(Small_Object_Pool *dest),
-    ARGMOD(Small_Object_Pool *source))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*dest)
-        FUNC_MODIFIES(*source);
-
-#define ASSERT_ARGS_pobject_lives __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(obj)
-#define ASSERT_ARGS_contained_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(pool) \
-    || PARROT_ASSERT_ARG(ptr)
-#define ASSERT_ARGS_gc_pmc_ext_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_new_small_object_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_Parrot_add_to_free_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool) \
-    || PARROT_ASSERT_ARG(arena)
-#define ASSERT_ARGS_Parrot_append_arena_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool) \
-    || PARROT_ASSERT_ARG(new_arena)
-#define ASSERT_ARGS_Parrot_gc_clear_live_bits __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_ms_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_Parrot_gc_trace_children __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_gc_trace_root __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_is_const_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pmc)
-#define ASSERT_ARGS_Parrot_small_object_pool_merge \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(dest) \
-    || PARROT_ASSERT_ARG(source)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-/* HEADERIZER END: src/gc/mark_sweep.c */
-
-#endif /* PARROT_GC_MARK_SWEEP_H_GUARD */
-
-/*
- * Local variables:
- *   c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */

Deleted: trunk/include/parrot/gc_pools.h
==============================================================================
--- trunk/include/parrot/gc_pools.h	Sat May  9 20:02:23 2009	(r38653)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,179 +0,0 @@
-/* gc_pools.h
- *  Copyright (C) 2001-2009, Parrot Foundation.
- *  SVN Info
- *     $Id$
- *  Overview:
- *     Handles pool management for GC.
- *  Data Structure and Algorithms:
- *  History:
- *  Notes:
- *  References:
- */
-
-#ifndef PARROT_GC_POOLS_H_GUARD
-#define PARROT_GC_POOLS_H_GUARD
-
-#include "parrot/parrot.h"
-
-/*
- * we need an alignment that is the same as malloc(3) have for
- * allocating Buffer items like FLOATVAL (double)
- * This should be either a config hint or tested
- */
-#ifdef MALLOC_ALIGNMENT
-#  define BUFFER_ALIGNMENT MALLOC_ALIGNMENT
-#else
-/* or (2 * sizeof (size_t)) */
-#  define BUFFER_ALIGNMENT 8
-#endif
-
-#define BUFFER_ALIGN_1 (BUFFER_ALIGNMENT - 1)
-#define BUFFER_ALIGN_MASK ~BUFFER_ALIGN_1
-
-#define WORD_ALIGN_1 (sizeof (void *) - 1)
-#define WORD_ALIGN_MASK ~WORD_ALIGN_1
-
-/* pool iteration */
-typedef enum {
-    POOL_PMC    = 0x01,
-    POOL_BUFFER = 0x02,
-    POOL_CONST  = 0x04,
-    POOL_ALL    = 0x07
-} pool_iter_enum;
-
-typedef int (*pool_iter_fn)(PARROT_INTERP, struct Small_Object_Pool *, int, void*);
-
-
-/* HEADERIZER BEGIN: src/gc/pools.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-void * get_free_buffer(PARROT_INTERP, ARGIN(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-size_t get_max_buffer_address(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-size_t get_max_pmc_address(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-size_t get_min_buffer_address(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-size_t get_min_pmc_address(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-int is_buffer_ptr(PARROT_INTERP, ARGIN(const void *ptr))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-int is_pmc_ptr(PARROT_INTERP, ARGIN(const void *ptr))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * new_buffer_pool(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * new_bufferlike_pool(PARROT_INTERP,
-    size_t actual_buffer_size)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * new_pmc_pool(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL constant)
-        __attribute__nonnull__(1);
-
-void Parrot_destroy_header_pools(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_IGNORABLE_RESULT
-int /*@alt void@*/
-Parrot_forall_header_pools(PARROT_INTERP,
-    int flag,
-    ARGIN_NULLOK(void *arg),
-    NOTNULL(pool_iter_fn func))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(4);
-
-void Parrot_initialize_header_pools(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-void Parrot_merge_header_pools(
-    ARGMOD(Interp *dest_interp),
-    ARGIN(Interp *source_interp))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*dest_interp);
-
-#define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_get_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_get_max_buffer_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_get_max_pmc_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_get_min_buffer_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_get_min_pmc_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_is_buffer_ptr __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(ptr)
-#define ASSERT_ARGS_is_pmc_ptr __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(ptr)
-#define ASSERT_ARGS_new_buffer_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_pmc_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_new_string_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_destroy_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_forall_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(func)
-#define ASSERT_ARGS_Parrot_initialize_header_pools \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_merge_header_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 */
-
-
-#endif /* PARROT_GC_POOLS_H_GUARD */
-
-/*
- * Local variables:
- *   c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */

Modified: trunk/include/parrot/memory.h
==============================================================================
--- trunk/include/parrot/memory.h	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/include/parrot/memory.h	Sat May  9 20:02:23 2009	(r38654)
@@ -111,10 +111,6 @@
     int line)
         __attribute__nonnull__(4);
 
-void mem_setup_allocator(PARROT_INTERP, ARGIN(void *stacktop))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
 #define ASSERT_ARGS_mem_sys_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_mem_sys_allocate_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_mem_sys_free __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
@@ -130,9 +126,6 @@
        PARROT_ASSERT_ARG(file)
 #define ASSERT_ARGS_mem__internal_realloc_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(file)
-#define ASSERT_ARGS_mem_setup_allocator __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(stacktop)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/memory.c */
 

Modified: trunk/include/parrot/parrot.h
==============================================================================
--- trunk/include/parrot/parrot.h	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/include/parrot/parrot.h	Sat May  9 20:02:23 2009	(r38654)
@@ -283,9 +283,6 @@
 #include "parrot/pmc.h"
 #include "parrot/events.h"
 #include "parrot/gc_api.h"
-#include "parrot/gc_mark_sweep.h"
-#include "parrot/gc_pools.h"
-#include "parrot/resources.h"
 #include "parrot/string_funcs.h"
 #include "parrot/misc.h"
 #include "parrot/sub.h"

Deleted: trunk/include/parrot/resources.h
==============================================================================
--- trunk/include/parrot/resources.h	Sat May  9 20:02:23 2009	(r38653)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,224 +0,0 @@
-/* resources.h
- *  Copyright (C) 2001-2007, Parrot Foundation.
- *  SVN Info
- *     $Id$
- *  Overview:
- *     Defines the resource allocation API
- *  Data Structure and Algorithms:
- *  History:
- *  Notes:
- *  References:
- */
-
-#ifndef PARROT_RESOURCES_H_GUARD
-#define PARROT_RESOURCES_H_GUARD
-
-#include "parrot/parrot.h"
-
-typedef struct Memory_Block {
-    size_t free;
-    size_t size;
-    struct Memory_Block *prev;
-    struct Memory_Block *next;
-    char *start;
-    char *top;
-} Memory_Block;
-
-typedef struct Memory_Pool {
-    Memory_Block *top_block;
-    void (*compact)(PARROT_INTERP, struct Memory_Pool *);
-    size_t minimum_block_size;
-    size_t total_allocated; /* total bytes allocated to this pool */
-    size_t guaranteed_reclaimable;     /* bytes that can definitely be reclaimed*/
-    size_t possibly_reclaimable;     /* bytes that can possibly be reclaimed
-                                      * (above plus COW-freed bytes) */
-    FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */
-} Memory_Pool;
-
-
-/* HEADERIZER BEGIN: src/gc/resources.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
-
-void Parrot_allocate(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*buffer);
-
-void Parrot_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)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*str);
-
-void Parrot_destroy_memory_pools(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-void Parrot_go_collect(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
-int Parrot_in_memory_pool(PARROT_INTERP, ARGIN(void *bufstart))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-void Parrot_initialize_memory_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);
-
-void Parrot_reallocate(PARROT_INTERP,
-    ARGMOD(Buffer *buffer),
-    size_t newsize)
-        __attribute__nonnull__(1)
-        __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_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(buffer)
-#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_memory_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#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 = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(bufstart)
-#define ASSERT_ARGS_Parrot_initialize_memory_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)
-#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/resources.c */
-
-typedef struct Arenas {
-    Memory_Pool *memory_pool;
-    Memory_Pool *constant_string_pool;
-    struct Small_Object_Pool *string_header_pool;
-    struct Small_Object_Pool *pmc_pool;
-    struct Small_Object_Pool *pmc_ext_pool;
-    struct Small_Object_Pool *constant_pmc_pool;
-    struct Small_Object_Pool *buffer_header_pool;
-    struct Small_Object_Pool *constant_string_header_pool;
-    struct Small_Object_Pool **sized_header_pools;
-    size_t num_sized;
-    /*
-     * function slots that each subsystem must provide
-     */
-    void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);
-    void (*finalize_gc_system) (PARROT_INTERP);
-    void (*init_pool)(PARROT_INTERP, struct Small_Object_Pool *);
-    /*
-     * statistics for GC
-     */
-    size_t  gc_mark_runs;       /* Number of times we've done a mark run*/
-    size_t  gc_lazy_mark_runs;  /* Number of successful lazy mark runs */
-    size_t  gc_collect_runs;    /* Number of times we've done a memory
-                                   compaction */
-    size_t  mem_allocs_since_last_collect;      /* The number of memory
-                                                 * allocations from the
-                                                 * system since the last
-                                                 * compaction run */
-    size_t  header_allocs_since_last_collect;   /* The number of header
-                                                 * blocks allocated from
-                                                 * the system since the last
-                                                 * GC run */
-    size_t  memory_allocated;     /* The total amount of
-                                   * allocatable memory
-                                   * allocated. Doesn't count
-                                   * memory for headers or
-                                   * internal structures or
-                                   * anything */
-    UINTVAL memory_collected;     /* Total amount of memory copied
-                                     during collection */
-    UINTVAL num_early_gc_PMCs;    /* how many PMCs want immediate destruction */
-    UINTVAL num_early_PMCs_seen;  /* how many such PMCs has GC seen */
-    UINTVAL num_extended_PMCs;    /* active PMCs having pmc_ext */
-    PMC* gc_mark_start;           /* first PMC marked during a GC run */
-    PMC* gc_mark_ptr;             /* last PMC marked during a GC run */
-    PMC* gc_trace_ptr;            /* last PMC trace_children was called on */
-    int lazy_gc;                  /* flag that indicates whether we should stop
-                                     when we've seen all impatient PMCs */
-    /*
-     * GC blocking
-     */
-    UINTVAL gc_mark_block_level;  /* How many outstanding GC block
-                                     requests are there? */
-    UINTVAL gc_sweep_block_level; /* How many outstanding GC block
-                                     requests are there? */
-    /*
-     * private data for the GC subsystem
-     */
-    void *  gc_private;           /* gc subsystem data */
-} Arenas;
-
-/* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */
-
-typedef enum {
-    TOTAL_MEM_ALLOC = 1,
-    GC_MARK_RUNS,
-    GC_COLLECT_RUNS,
-    ACTIVE_PMCS,
-    ACTIVE_BUFFERS,
-    TOTAL_PMCS,
-    TOTAL_BUFFERS,
-    HEADER_ALLOCS_SINCE_COLLECT,
-    MEM_ALLOCS_SINCE_COLLECT,
-    TOTAL_COPIED,
-    IMPATIENT_PMCS,
-    GC_LAZY_MARK_RUNS,
-    EXTENDED_PMCS,
-    CURRENT_RUNCORE,
-
-    /* interpinfo_p constants */
-    CURRENT_SUB,
-    CURRENT_CONT,
-    CURRENT_OBJECT,
-    CURRENT_LEXPAD,
-
-    /* interpinfo_s constants */
-    EXECUTABLE_FULLNAME,
-    EXECUTABLE_BASENAME,
-    RUNTIME_PREFIX
-} Interpinfo_enum;
-
-/* &end_gen */
-
-#endif /* PARROT_RESOURCES_H_GUARD */
-
-/*
- * Local variables:
- *   c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */

Modified: trunk/include/parrot/stacks.h
==============================================================================
--- trunk/include/parrot/stacks.h	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/include/parrot/stacks.h	Sat May  9 20:02:23 2009	(r38654)
@@ -24,12 +24,9 @@
     void (*cleanup)(PARROT_INTERP, ARGIN(struct Stack_Entry *));
 } Stack_Entry_t;
 
-struct Small_Object_Pool; /* forward decl */
-
 typedef struct Stack_Chunk {
     UnionVal            cache;
     Parrot_UInt         flags;
-    struct Small_Object_Pool  *pool;
     const char         *name;
     struct Stack_Chunk *prev;
     Parrot_UInt         refcount;

Modified: trunk/src/dynpmc/dynlexpad.pmc
==============================================================================
--- trunk/src/dynpmc/dynlexpad.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/dynpmc/dynlexpad.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -203,7 +203,7 @@
     VTABLE void mark() {
         PMC *std_pad = PARROT_DYNLEXPAD(SELF)->init;
         if (std_pad)
-            pobject_lives(interp, (PObj *)std_pad);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)std_pad);
         if (PARROT_DYNLEXPAD(SELF)->hash)
             parrot_mark_hash(interp, PARROT_DYNLEXPAD(SELF)->hash);
     }

Modified: trunk/src/dynpmc/pair.pmc
==============================================================================
--- trunk/src/dynpmc/pair.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/dynpmc/pair.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -87,10 +87,10 @@
         Parrot_Pair_attributes * const pair = PARROT_PAIR(SELF);
 
         if (pair->key)
-            pobject_lives(INTERP, (PObj *)pair->key);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)pair->key);
 
         if (pair->value)
-            pobject_lives(INTERP, (PObj *)pair->value);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)pair->value);
     }
 
 /*

Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/api.c	Sat May  9 20:02:23 2009	(r38654)
@@ -33,30 +33,185 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PMC_EXT * new_pmc_ext(PARROT_INTERP)
+static void cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
         __attribute__nonnull__(1);
 
-#define ASSERT_ARGS_new_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
+static void fix_pmc_syncs(
+    ARGMOD(Interp *dest_interp),
+    ARGIN(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*dest_interp);
+
+static int sweep_cb_buf(PARROT_INTERP,
+    ARGMOD(Small_Object_Pool *pool),
+    SHIM(int flag),
+    ARGIN(void *arg))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(4)
+        FUNC_MODIFIES(*pool);
+
+static int sweep_cb_pmc(PARROT_INTERP,
+    ARGMOD(Small_Object_Pool *pool),
+    SHIM(int flag),
+    SHIM(void *arg))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+#define ASSERT_ARGS_cleanup_next_for_GC_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_fix_pmc_syncs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(dest_interp) \
+    || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_sweep_cb_buf __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool) \
+    || PARROT_ASSERT_ARG(arg)
+#define ASSERT_ARGS_sweep_cb_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
 
 #if ! DISABLE_GC_DEBUG
 
-/* Set when walking the system stack */
-int CONSERVATIVE_POINTER_CHASING = 0;
+#endif
+
+/*
+
+=item C<void Parrot_gc_mark_PObj_alive(PARROT_INTERP, PObj *obj)>
+
+Marks the PObj as "alive" for the Garbage Collector. Takes a pointer to a PObj,
+and performs necessary marking to ensure the PMC and its direct children nodes
+are marked alive. Implementation is generally dependant on the particular
+garbage collector in use.
+
+Previously known as C<pobject_lives>.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
+{
+    ASSERT_ARGS(Parrot_gc_mark_PObj_alive)
+    /* TODO: Have each core register a ->pobject_lives function pointer in the
+       Arenas struct, and call that pointer directly instead of having a messy
+       set of #if preparser conditions. */
+#if PARROT_GC_GMS
+    do {
+        if (!PObj_live_TEST(obj) && \
+                PObj_to_GMSH(obj)->gen->gen_no >= interp->gc_generation) \
+            parrot_gc_gms_Parrot_gc_mark_PObj_alive(interp, obj); \
+    } while (0);
+#else /* not PARROT_GC_GMS */
+
+    /* if object is live or on free list return */
+    if (PObj_is_live_or_free_TESTALL(obj))
+        return;
+
+#  if ! DISABLE_GC_DEBUG
+#    if GC_VERBOSE
+    if (CONSERVATIVE_POINTER_CHASING)
+        fprintf(stderr, "GC Warning! Unanchored %s %p found in system areas \n",
+                PObj_is_PMC_TEST(obj) ? "PMC" : "Buffer", obj);
+
+#    endif
+#  endif
+    /* mark it live */
+    PObj_live_SET(obj);
+
+    /* if object is a PMC and contains buffers or PMCs, then attach the PMC
+     * to the chained mark list. */
+    if (PObj_is_PMC_TEST(obj)) {
+        PMC * const p = (PMC *)obj;
+
+        if (PObj_is_special_PMC_TEST(obj))
+            mark_special(interp, p);
+
+#  ifndef NDEBUG
+        else if (p->pmc_ext && PMC_metadata(p))
+            fprintf(stderr, "GC: error obj %p (%s) has properties\n",
+                    (void *)p, (char*)p->vtable->whoami->strstart);
+#  endif
+    }
+#  if GC_VERBOSE
+    /* buffer GC_DEBUG stuff */
+    if (GC_DEBUG(interp) && PObj_report_TEST(obj))
+        fprintf(stderr, "GC: buffer %p pointing to %p marked live\n",
+                obj, PObj_bufstart((Buffer *)obj));
+#  endif
+#endif  /* PARROT_GC_GMS */
+}
+
+/*
+
+=item C<void Parrot_gc_initialize(PARROT_INTERP, void *stacktop)>
+
+Initializes the memory allocator and the garbage collection subsystem.
+Calls the initialization function associated with each collector, which
+is determined at compile time.
+
+The "stacktop" parameter is required; it provides an upper bound for
+stack scanning during a garbage collection run.
+
+=cut
 
+*/
+
+void
+Parrot_gc_initialize(PARROT_INTERP, ARGIN(void *stacktop))
+{
+    ASSERT_ARGS(Parrot_gc_initialize)
+    interp->arena_base = mem_allocate_zeroed_typed(Arenas);
+    interp->arena_base->sized_header_pools = NULL;
+
+    interp->lo_var_ptr = stacktop;
+
+#if PARROT_GC_MS
+    Parrot_gc_ms_init(interp);
+#endif
+#if PARROT_GC_IMS
+    Parrot_gc_ims_init(interp);
 #endif
+#if PARROT_GC_GMS
+    Parrot_gc_gms_init(interp);
+#endif
+
+    Parrot_initialize_memory_pools(interp);
+    Parrot_initialize_header_pools(interp);
+}
+
+/*
+
+=item C<void Parrot_gc_finalize(PARROT_INTERP)>
+
+Finalize the GC system, if the current GC core has defined a finalization
+routine.
+
+=cut
+
+*/
+
+void
+Parrot_gc_finalize(PARROT_INTERP)
+{
+    if (interp->arena_base->finalize_gc_system)
+        interp->arena_base->finalize_gc_system(interp);
+}
+
 
 /*
 
-=item C<PMC * new_pmc_header(PARROT_INTERP, UINTVAL flags)>
+=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
 
@@ -65,9 +220,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC *
-new_pmc_header(PARROT_INTERP, UINTVAL flags)
+Parrot_gc_new_pmc_header(PARROT_INTERP, UINTVAL flags)
 {
-    ASSERT_ARGS(new_pmc_header)
+    ASSERT_ARGS(Parrot_gc_new_pmc_header)
     Small_Object_Pool * const pool = flags & PObj_constant_FLAG
             ? interp->arena_base->constant_pmc_pool
             : interp->arena_base->pmc_pool;
@@ -79,11 +234,12 @@
 
     /* clear flags, set is_PMC_FLAG */
     if (flags & PObj_is_PMC_EXT_FLAG) {
+        Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool;
         flags |= PObj_is_special_PMC_FLAG;
-        pmc->pmc_ext = new_pmc_ext(interp);
+        pmc->pmc_ext = (PMC_EXT *)pool->get_free_object(interp, pool);
 
         if (flags & PObj_is_PMC_shared_FLAG)
-            add_pmc_sync(interp, pmc);
+            Parrot_gc_add_pmc_sync(interp, pmc);
     }
     else
         pmc->pmc_ext = NULL;
@@ -95,35 +251,37 @@
     return pmc;
 }
 
-
 /*
 
-=item C<static PMC_EXT * new_pmc_ext(PARROT_INTERP)>
+=item C<void Parrot_gc_free_pmc_header(PARROT_INTERP, PMC *pmc)>
 
-Gets a new free C<PMC_EXT> structure from the PMC_EXT pool. A pointer to the
-new PMC_EXT is returned. Does not check to ensure the PMC_EXT is non-null
-before it is returned (yet).
+Adds the given PMC to the free list for later reuse.
 
 =cut
 
 */
 
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PMC_EXT *
-new_pmc_ext(PARROT_INTERP)
+void
+Parrot_gc_free_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
-    ASSERT_ARGS(new_pmc_ext)
-    Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool;
-    /* XXX: Should we check here to ensure the PMC_EXT is non-null
-            like we do in C<new_pmc>? */
-    return (PMC_EXT *)pool->get_free_object(interp, pool);
-}
+    ASSERT_ARGS(Parrot_gc_free_pmc_header)
+    Small_Object_Pool * const pool = (PObj_constant_TEST(pmc)) ?
+        interp->arena_base->constant_pmc_pool : interp->arena_base->pmc_pool;
 
+    if (PObj_active_destroy_TEST(pmc))
+        VTABLE_destroy(interp, pmc);
+
+    if (PObj_is_PMC_EXT_TEST(pmc))
+        Parrot_gc_free_pmc_ext(interp, pmc);
+
+    PObj_flags_SETTO((PObj *)pmc, PObj_on_free_list_FLAG);
+    pool->add_free_object(interp, pool, (PObj *)pmc);
+    pool->num_free_objects++;
+}
 
 /*
 
-=item C<void add_pmc_ext(PARROT_INTERP, PMC *pmc)>
+=item C<void Parrot_gc_add_pmc_ext(PARROT_INTERP, PMC *pmc)>
 
 Obtains a new C<PMC_EXT> structure, and attaches it to the given C<PMC>.
 Sets the necessary flags associated with the PMC_EXT structure. Ensures
@@ -134,10 +292,14 @@
 */
 
 void
-add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
+Parrot_gc_add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
-    ASSERT_ARGS(add_pmc_ext)
-    pmc->pmc_ext = new_pmc_ext(interp);
+    ASSERT_ARGS(Parrot_gc_add_pmc_ext)
+    Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool;
+    pmc->pmc_ext = (PMC_EXT *)pool->get_free_object(interp, pool);
+    if(!pmc->pmc_ext)
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
+            "Parrot VM: PMC_EXT allocation failed!\n");
     PObj_is_PMC_EXT_SET(pmc);
 
 #ifdef PARROT_GC_IMS
@@ -153,38 +315,68 @@
     PMC_next_for_GC(pmc) = PMCNULL;
 }
 
+/*
+
+=item C<void Parrot_gc_free_pmc_ext(PARROT_INTERP, PMC *p)>
+
+Frees the C<PMC_EXT> structure attached to a PMC, if it exists.
+
+=cut
+
+*/
+
+void
+Parrot_gc_free_pmc_ext(PARROT_INTERP, ARGMOD(PMC *p))
+{
+    ASSERT_ARGS(Parrot_gc_free_pmc_ext)
+    /* if the PMC has a PMC_EXT structure, return it to the pool/arena */
+    Arenas            * const arena_base = interp->arena_base;
+    Small_Object_Pool * const ext_pool   = arena_base->pmc_ext_pool;
+
+    if (PObj_is_PMC_shared_TEST(p) && PMC_sync(p)) {
+        MUTEX_DESTROY(PMC_sync(p)->pmc_lock);
+        mem_internal_free(PMC_sync(p));
+        PMC_sync(p) = NULL;
+    }
+
+    if (p->pmc_ext) {
+        ext_pool->add_free_object(interp, ext_pool, p->pmc_ext);
+        ext_pool->num_free_objects++;
+    }
+
+    p->pmc_ext = NULL;
+}
 
 /*
 
-=item C<void add_pmc_sync(PARROT_INTERP, PMC *pmc)>
+=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
 
 */
 
 void
-add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
+Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
-    ASSERT_ARGS(add_pmc_sync)
+    ASSERT_ARGS(Parrot_gc_add_pmc_sync)
     if (!PObj_is_PMC_EXT_TEST(pmc))
-        add_pmc_ext(interp, pmc);
+        Parrot_gc_add_pmc_ext(interp, pmc);
+    PMC_sync(pmc) = mem_allocate_typed(Sync);
+    if(!PMC_sync(pmc))
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
+            "Parrot VM: PMC Sync allocation failed!\n");
 
-    /* XXX: Should we test the Sync * for non-null? should we allocate these
-            from a bufferlike pool instead of directly from the system? */
-    PMC_sync(pmc)        = mem_allocate_typed(Sync);
     PMC_sync(pmc)->owner = interp;
-
     MUTEX_INIT(PMC_sync(pmc)->pmc_lock);
 }
 
-
 /*
 
-=item C<STRING * new_string_header(PARROT_INTERP, UINTVAL flags)>
+=item C<STRING * Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)>
 
 Returns a new C<STRING> header from the string pool or the constant string
 pool. Sets default flags on the string object: C<PObj_is_string_FLAG>,
@@ -198,13 +390,16 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 STRING *
-new_string_header(PARROT_INTERP, UINTVAL flags)
+Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)
 {
-    ASSERT_ARGS(new_string_header)
+    ASSERT_ARGS(Parrot_gc_new_string_header)
     STRING * const string = (STRING *)get_free_buffer(interp,
         (flags & PObj_constant_FLAG)
             ? interp->arena_base->constant_string_header_pool
             : interp->arena_base->string_header_pool);
+    if(!string)
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
+            "Parrot VM: STRING allocation failed!\n");
 
     string->strstart        = NULL;
     PObj_get_FLAGS(string) |=
@@ -213,34 +408,35 @@
     return string;
 }
 
-
 /*
 
-=item C<Buffer * new_buffer_header(PARROT_INTERP)>
+=item C<void Parrot_gc_free_string_header(PARROT_INTERP, STRING *s)>
 
-Creates and returns a new C<Buffer> from the buffer header pool.  Calls
-C<get_free_buffer> to do all the work.
+Adds the given STRING to the free list for later reuse.
 
 =cut
 
 */
 
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-Buffer *
-new_buffer_header(PARROT_INTERP)
+void
+Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
 {
-    ASSERT_ARGS(new_buffer_header)
-    return (Buffer *)get_free_buffer(interp,
-            interp->arena_base->buffer_header_pool);
+    ASSERT_ARGS(Parrot_gc_free_string_header);
+    if (!PObj_constant_TEST(s)) {
+        Small_Object_Pool * const pool = interp->arena_base->string_header_pool;
+        pool->add_free_object(interp, pool, s);
+    }
 }
 
-
 /*
 
-=item C<void * new_bufferlike_header(PARROT_INTERP, size_t size)>
+=item C<void * Parrot_gc_new_bufferlike_header(PARROT_INTERP, 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 and Stack_Chunk objects in
+src/stacks.c.
 
 =cut
 
@@ -249,272 +445,966 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 void *
-new_bufferlike_header(PARROT_INTERP, size_t size)
+Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size)
 {
-    ASSERT_ARGS(new_bufferlike_header)
+    ASSERT_ARGS(Parrot_gc_new_bufferlike_header)
     Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
 
     return get_free_buffer(interp, pool);
 }
 
+/*
+
+=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
+
+*/
+
+void
+Parrot_gc_free_bufferlike_header(PARROT_INTERP, ARGMOD(PObj *obj),
+    size_t size)
+{
+    ASSERT_ARGS(Parrot_gc_free_bufferlike_header);
+    Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
+    pool->add_free_object(interp, pool, obj);
+}
 
 /*
 
-=item C<void Parrot_gc_free_pmc(PARROT_INTERP, Small_Object_Pool *pool, PObj
-*p)>
+=item C<void Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP, Buffer
+*buffer, size_t size)>
 
-Frees a PMC that is no longer being used. Calls a custom C<destroy> VTABLE
-method if one is available. If the PMC uses a PMC_EXT structure, that is freed
-as well.
+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_gc_free_pmc(PARROT_INTERP, SHIM(Small_Object_Pool *pool),
-        ARGMOD(PObj *p))
+Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP,
+    ARGOUT(Buffer *buffer), size_t size)
 {
-    ASSERT_ARGS(Parrot_gc_free_pmc)
-    PMC    * const pmc        = (PMC *)p;
-    Arenas * const arena_base = interp->arena_base;
+    ASSERT_ARGS(Parrot_gc_allocate_buffer_storage_aligned)
+    size_t new_size;
+    char *mem;
+
+    PObj_buflen(buffer) = 0;
+    PObj_bufstart(buffer) = NULL;
+    new_size = aligned_size(buffer, size);
+    mem = (char *)mem_allocate(interp, new_size,
+        interp->arena_base->memory_pool);
+    mem = aligned_mem(buffer, mem);
+    PObj_bufstart(buffer) = mem;
+    if (PObj_is_COWable_TEST(buffer))
+        new_size -= sizeof (void*);
+    PObj_buflen(buffer) = new_size;
+}
 
-    /* TODO collect objects with finalizers */
-    if (PObj_needs_early_gc_TEST(p))
-        --arena_base->num_early_gc_PMCs;
+/*
 
-    if (PObj_active_destroy_TEST(p))
-        VTABLE_destroy(interp, pmc);
+=item C<void Parrot_gc_reallocate_buffer_storage(PARROT_INTERP, Buffer *buffer,
+size_t newsize)>
 
-    if (PObj_is_PMC_EXT_TEST(p))
-         Parrot_gc_free_pmc_ext(interp, pmc);
+Reallocate the Buffer's buffer memory to the given size. The
+allocated buffer will not shrink. If the buffer was allocated with
+L<Parrot_allocate_aligned> the new buffer will also be aligned. As with
+all reallocation, the new buffer might have moved and the additional
+memory is not cleared.
 
-#ifndef NDEBUG
+=cut
 
-    pmc->pmc_ext     = (PMC_EXT *)0xdeadbeef;
-    pmc->vtable      = (VTABLE  *)0xdeadbeef;
+*/
 
-#endif
+void
+Parrot_gc_reallocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer),
+    size_t newsize)
+{
+    ASSERT_ARGS(Parrot_gc_reallocate_buffer_storage)
+    size_t copysize;
+    char  *mem;
+    Memory_Pool * const pool = interp->arena_base->memory_pool;
+    size_t new_size, needed, old_size;
+
+    /*
+     * we don't shrink buffers
+     */
+    if (newsize <= PObj_buflen(buffer))
+        return;
+
+    /*
+     * same as below but barely used and tested - only 3 list related
+     * tests do use true reallocation
+     *
+     * list.c, which does _reallocate, has 2 reallocations
+     * normally, which play ping pong with buffers.
+     * The normal case is therefore always to allocate a new block
+     */
+    new_size = aligned_size(buffer, newsize);
+    old_size = aligned_size(buffer, PObj_buflen(buffer));
+    needed   = new_size - old_size;
+
+    if ((pool->top_block->free >= needed)
+    &&  (pool->top_block->top  == (char *)PObj_bufstart(buffer) + old_size)) {
+        pool->top_block->free -= needed;
+        pool->top_block->top  += needed;
+        PObj_buflen(buffer) = newsize;
+        return;
+    }
+
+    copysize = PObj_buflen(buffer);
+
+    if (!PObj_COW_TEST(buffer))
+        pool->guaranteed_reclaimable += copysize;
+
+    pool->possibly_reclaimable += copysize;
+    mem                         = (char *)mem_allocate(interp, new_size, pool);
+    mem                         = aligned_mem(buffer, mem);
 
+    /* We shouldn't ever have a 0 from size, but we do. If we can track down
+     * those bugs, this can be removed which would make things cheaper */
+    if (copysize)
+        memcpy(mem, PObj_bufstart(buffer), copysize);
+
+    PObj_bufstart(buffer) = mem;
+
+    if (PObj_is_COWable_TEST(buffer))
+        new_size -= sizeof (void *);
+
+    PObj_buflen(buffer) = new_size;
 }
 
 /*
 
-=item C<void Parrot_gc_free_pmc_ext(PARROT_INTERP, PMC *p)>
+=item C<void Parrot_gc_allocate_string_storage(PARROT_INTERP, STRING *str,
+size_t size)>
 
-Frees the C<PMC_EXT> structure attached to a PMC, if it exists.
+Allocate the STRING's buffer memory to the given size. The allocated
+buffer maybe slightly bigger than the given C<size>. This function
+sets also C<< str->strstart >> to the new buffer location, C<< str->bufused >>
+is B<not> changed.
 
 =cut
 
 */
 
 void
-Parrot_gc_free_pmc_ext(PARROT_INTERP, ARGMOD(PMC *p))
+Parrot_gc_allocate_string_storage(PARROT_INTERP, ARGOUT(STRING *str),
+    size_t size)
 {
-    ASSERT_ARGS(Parrot_gc_free_pmc_ext)
-    /* if the PMC has a PMC_EXT structure, return it to the pool/arena */
-    Arenas            * const arena_base = interp->arena_base;
-    Small_Object_Pool * const ext_pool   = arena_base->pmc_ext_pool;
+    ASSERT_ARGS(Parrot_gc_allocate_string_storage)
+    size_t       new_size;
+    Memory_Pool *pool;
+    char        *mem;
+
+    PObj_buflen(str)   = 0;
+    PObj_bufstart(str) = NULL;
+
+    /* there's no sense in allocating zero memory, when the overhead of
+     * allocating a string is one pointer; this can fill the pools in an
+     * uncompactable way.  See RT #42320.
+     */
+    if (size == 0)
+        return;
 
-    if (PObj_is_PMC_shared_TEST(p) && PMC_sync(p)) {
-        MUTEX_DESTROY(PMC_sync(p)->pmc_lock);
-        mem_internal_free(PMC_sync(p));
-        PMC_sync(p) = NULL;
+    pool     = PObj_constant_TEST(str)
+                ? interp->arena_base->constant_string_pool
+                : interp->arena_base->memory_pool;
+
+    new_size = aligned_string_size(size);
+    mem      = (char *)mem_allocate(interp, new_size, pool);
+    mem     += sizeof (void*);
+
+    PObj_bufstart(str) = str->strstart = mem;
+    PObj_buflen(str)   = new_size - sizeof (void*);
+}
+
+/*
+
+=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
+new buffer location, C<str-E<gt>bufused> is B<not> changed.
+
+=cut
+
+*/
+
+void
+Parrot_gc_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str),
+    size_t newsize)
+{
+    ASSERT_ARGS(Parrot_gc_reallocate_string_storage)
+    size_t copysize;
+    char *mem, *oldmem;
+    size_t new_size, needed, old_size;
+
+    Memory_Pool * const pool =
+        PObj_constant_TEST(str)
+            ? interp->arena_base->constant_string_pool
+            : interp->arena_base->memory_pool;
+
+    /* if the requested size is smaller then buflen, we are done */
+    if (newsize <= PObj_buflen(str))
+        return;
+
+    /*
+     * first check, if we can reallocate:
+     * - if the passed strings buffer is the last string in the pool and
+     * - if there is enough size, we can just move the pool's top pointer
+     */
+    new_size = aligned_string_size(newsize);
+    old_size = aligned_string_size(PObj_buflen(str));
+    needed   = new_size - old_size;
+
+    if (pool->top_block->free >= needed
+    &&  pool->top_block->top  == (char *)PObj_bufstart(str) + old_size) {
+        pool->top_block->free -= needed;
+        pool->top_block->top  += needed;
+        PObj_buflen(str) = new_size - sizeof (void*);
+        return;
     }
 
-    if (p->pmc_ext)
-        ext_pool->add_free_object(interp, ext_pool, p->pmc_ext);
+    PARROT_ASSERT(str->bufused <= newsize);
 
-    ext_pool->num_free_objects++;
+    /* only copy used memory, not total string buffer */
+    copysize = str->bufused;
 
-    p->pmc_ext = NULL;
+    if (!PObj_COW_TEST(str))
+        pool->guaranteed_reclaimable += PObj_buflen(str);
+
+    pool->possibly_reclaimable += PObj_buflen(str);
+
+    mem = (char *)mem_allocate(interp, new_size, pool);
+    mem += sizeof (void *);
+
+    /* copy mem from strstart, *not* bufstart */
+    oldmem             = str->strstart;
+    PObj_bufstart(str) = (void *)mem;
+    str->strstart      = mem;
+    PObj_buflen(str)   = new_size - sizeof (void*);
+
+    /* We shouldn't ever have a 0 from size, but we do. If we can track down
+     * those bugs, this can be removed which would make things cheaper */
+    if (copysize)
+        memcpy(mem, oldmem, copysize);
 }
 
 /*
 
-=item C<void Parrot_gc_free_sysmem(PARROT_INTERP, Small_Object_Pool *pool, PObj
-*b)>
+=item C<void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)>
 
-If the PMC uses memory allocated directly from the system, this function
-frees that memory.
+Calls the configured garbage collector to find and reclaim unused
+headers. Performs a complete mark & sweep run of the GC.
 
 =cut
 
 */
 
 void
-Parrot_gc_free_sysmem(SHIM_INTERP, SHIM(Small_Object_Pool *pool),
-        ARGMOD(PObj *b))
+Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
 {
-    ASSERT_ARGS(Parrot_gc_free_sysmem)
-    /* has sysmem allocated, e.g. Parrot_str_pin */
-    if (PObj_sysmem_TEST(b) && PObj_bufstart(b))
-        mem_sys_free(PObj_bufstart(b));
+    ASSERT_ARGS(Parrot_gc_mark_and_sweep)
+    interp->arena_base->do_gc_mark(interp, flags);
+    parrot_gc_context(interp);
+}
+
+/*
+
+=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
+
+*/
 
-    PObj_bufstart(b) = NULL;
-    PObj_buflen(b)   = 0;
+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<void Parrot_gc_free_buffer_malloc(PARROT_INTERP, Small_Object_Pool
-*pool, PObj *b)>
+=item C<void Parrot_gc_merge_header_pools(Interp *dest_interp, Interp
+*source_interp)>
 
-Frees the given buffer, returning the storage space to the operating system
-and removing it from Parrot's memory management system. If the buffer is COW,
-The buffer is not freed if the reference count is greater then 1.
+Merges the header pools of C<source_interp> into those of C<dest_interp>.
+(Used to deal with shared objects left after interpreter destruction.)
 
 =cut
 
 */
 
 void
-Parrot_gc_free_buffer_malloc(SHIM_INTERP, SHIM(Small_Object_Pool *pool),
-        ARGMOD(PObj *b))
+Parrot_gc_merge_header_pools(ARGMOD(Interp *dest_interp),
+    ARGIN(Interp *source_interp))
 {
-    ASSERT_ARGS(Parrot_gc_free_buffer_malloc)
-    /* free allocated space at (int *)bufstart - 1, but not if it used COW or is
-     * external */
-    PObj_buflen(b) = 0;
+    ASSERT_ARGS(Parrot_gc_merge_header_pools)
 
-    if (!PObj_bufstart(b) || PObj_is_external_or_free_TESTALL(b))
-        return;
+    Arenas * const dest_arena   = dest_interp->arena_base;
+    Arenas * const source_arena = source_interp->arena_base;
+    UINTVAL        i;
+
+    /* heavily borrowed from forall_header_pools */
+    fix_pmc_syncs(dest_interp, source_arena->constant_pmc_pool);
+    Parrot_small_object_pool_merge(dest_interp, dest_arena->constant_pmc_pool,
+            source_arena->constant_pmc_pool);
+
+    fix_pmc_syncs(dest_interp, source_arena->pmc_pool);
+    Parrot_small_object_pool_merge(dest_interp, dest_arena->pmc_pool,
+            source_arena->pmc_pool);
+
+    Parrot_small_object_pool_merge(dest_interp,
+            dest_arena->constant_string_header_pool,
+            source_arena->constant_string_header_pool);
+
+    Parrot_small_object_pool_merge(dest_interp,
+            dest_arena->pmc_ext_pool, source_arena->pmc_ext_pool);
+
+    for (i = 0; i < source_arena->num_sized; ++i) {
+        if (!source_arena->sized_header_pools[i])
+            continue;
+
+        if (i >= dest_arena->num_sized
+        || !dest_arena->sized_header_pools[i]) {
+            Small_Object_Pool *ignored = get_bufferlike_pool(dest_interp,
+                    i * sizeof (void *));
+            UNUSED(ignored);
+            PARROT_ASSERT(dest_arena->sized_header_pools[i]);
+        }
+
+        Parrot_small_object_pool_merge(dest_interp,
+            dest_arena->sized_header_pools[i],
+            source_arena->sized_header_pools[i]);
+    }
+}
+
+/*
+
+=item C<static void fix_pmc_syncs(Interp *dest_interp, Small_Object_Pool *pool)>
+
+Walks through the given arena, looking for all live and shared PMCs,
+transferring their sync values to the destination interpreter.
+
+=cut
+
+*/
 
-    if (PObj_COW_TEST(b)) {
-        INTVAL * const refcount = PObj_bufrefcountptr(b);
+static void
+fix_pmc_syncs(ARGMOD(Interp *dest_interp), ARGIN(Small_Object_Pool *pool))
+{
+    ASSERT_ARGS(fix_pmc_syncs)
+    Small_Object_Arena *cur_arena;
+    const UINTVAL       object_size = pool->object_size;
+
+    for (cur_arena = pool->last_Arena; cur_arena; cur_arena = cur_arena->prev) {
+        PMC   *p = (PMC *)((char*)cur_arena->start_objects + GC_HEADER_SIZE);
+        size_t i;
+
+        for (i = 0; i < cur_arena->used; i++) {
+            if (!PObj_on_free_list_TEST(p) && PObj_is_PMC_TEST(p)) {
+                if (PObj_is_PMC_shared_TEST(p))
+                    PMC_sync(p)->owner = dest_interp;
+                else
+                    Parrot_ex_throw_from_c_args(dest_interp, NULL,
+                        EXCEPTION_INTERP_ERROR,
+                        "Unshared PMC still alive after interpreter"
+                        "destruction. address=%p, base_type=%d\n",
+                        p, p->vtable->base_type);
+            }
 
-        if (--(*refcount) == 0) {
-            mem_sys_free(refcount); /* the actual bufstart */
+            p = (PMC *)((char *)p + object_size);
         }
     }
-    else
-        mem_sys_free(PObj_bufrefcountptr(b));
 }
 
 /*
 
-=item C<void Parrot_gc_free_buffer(PARROT_INTERP, Small_Object_Pool *pool, PObj
-*b)>
+=item C<void Parrot_gc_destroy_header_pools(PARROT_INTERP)>
 
-Frees a buffer, returning it to the memory pool for Parrot to possibly
-reuse later.
+Performs a garbage collection sweep on all pools, then frees them.  Calls
+C<Parrot_forall_header_pools> to loop over all the pools, passing
+C<sweep_cb_pmc> and C<sweep_cb_buf> callback routines. Frees the array of sized
+header pointers in the C<Arenas> structure too.
 
 =cut
 
 */
 
 void
-Parrot_gc_free_buffer(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGMOD(PObj *b))
+Parrot_gc_destroy_header_pools(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_gc_destroy_header_pools)
+    INTVAL pass;
+
+    /* const/non const COW strings life in different pools
+     * so in first pass
+     * COW refcount is done, in 2. refcounting
+     * in 3rd freeing
+     */
+#ifdef GC_IS_MALLOC
+    const INTVAL start = 0;
+#else
+    const INTVAL start = 2;
+#endif
+
+    Parrot_forall_header_pools(interp, POOL_PMC, NULL, sweep_cb_pmc);
+    Parrot_forall_header_pools(interp, POOL_PMC | POOL_CONST, NULL,
+            sweep_cb_pmc);
+
+    for (pass = start; pass <= 2; pass++) {
+        Parrot_forall_header_pools(interp, POOL_BUFFER | POOL_CONST,
+                (void *)pass, sweep_cb_buf);
+    }
+
+    free_pool(interp->arena_base->pmc_ext_pool);
+    interp->arena_base->pmc_ext_pool = NULL;
+
+    mem_internal_free(interp->arena_base->sized_header_pools);
+    interp->arena_base->sized_header_pools = NULL;
+}
+
+/*
+
+=item C<static int sweep_cb_pmc(PARROT_INTERP, Small_Object_Pool *pool, int
+flag, void *arg)>
+
+Performs a garbage collection sweep of the given pmc pool, then frees it. Calls
+C<Parrot_gc_sweep> to perform the sweep, and C<free_pool> to free the pool and
+all its arenas. Always returns C<0>.
+
+=cut
+
+*/
+
+static int
+sweep_cb_pmc(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
+        SHIM(int flag), SHIM(void *arg))
 {
-    ASSERT_ARGS(Parrot_gc_free_buffer)
-    Memory_Pool * const mem_pool = (Memory_Pool *)pool->mem_pool;
+    Parrot_gc_sweep(interp, pool);
+    free_pool(pool);
+    return 0;
+}
+
+/*
+
+=item C<static int sweep_cb_buf(PARROT_INTERP, Small_Object_Pool *pool, int
+flag, void *arg)>
 
-    /* XXX Jarkko reported that on irix pool->mem_pool was NULL, which really
-     * shouldn't happen */
-    if (mem_pool) {
-        if (!PObj_COW_TEST(b))
-            mem_pool->guaranteed_reclaimable += PObj_buflen(b);
+Performs a final garbage collection sweep, then frees the pool. Calls
+C<Parrot_gc_sweep> to perform the sweep, and C<free_pool> to free the pool and
+all its arenas.
 
-         mem_pool->possibly_reclaimable += PObj_buflen(b);
+=cut
+
+*/
+
+static int
+sweep_cb_buf(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), SHIM(int flag),
+        ARGIN(void *arg))
+{
+#ifdef GC_IS_MALLOC
+    const int pass = (int)(INTVAL)arg;
+
+    if (pass == 0)
+        clear_cow(interp, pool, 1);
+    else if (pass == 1)
+        used_cow(interp, pool, 1);
+    else
+#endif
+
+    {
+        UNUSED(arg);
+        Parrot_gc_sweep(interp, pool);
+        free_pool(pool);
     }
 
-    PObj_buflen(b)        = 0;
+    return 0;
 }
 
 /*
 
-=item C<void Parrot_gc_profile_start(PARROT_INTERP)>
+=item C<void Parrot_gc_destroy_memory_pools(PARROT_INTERP)>
 
-Records the start time of a GC mark run when profiling is enabled.
+Destroys the memory pool and the constant string pool. Loop through both
+pools and destroy all memory blocks contained in them. Once all the
+blocks are freed, free the pools themselves.
 
 =cut
 
 */
 
 void
-Parrot_gc_profile_start(PARROT_INTERP)
+Parrot_gc_destroy_memory_pools(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_gc_destroy_memory_pools)
+    int i;
+
+    for (i = 0; i < 2; i++) {
+        Memory_Pool * const pool = i ?
+                interp->arena_base->constant_string_pool :
+                interp->arena_base->memory_pool;
+        Memory_Block *cur_block;
+
+        cur_block = pool->top_block;
+
+        while (cur_block) {
+            Memory_Block * const next_block = cur_block->prev;
+            mem_internal_free(cur_block);
+            cur_block = next_block;
+        }
+
+        mem_internal_free(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<int Parrot_gc_ptr_is_pmc(PARROT_INTERP, void *ptr)>
+
+Determines if a given pointer is a PMC or not. It is a PMC if it is properly
+contained in one of this interpreters PMC pools.
+
+=cut
+
+*/
+
+int
+Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr))
+{
+    return contained_in_pool(interp->arena_base->pmc_pool, ptr) ||
+           contained_in_pool(interp->arena_base->constant_pmc_pool, ptr);
+}
+
+/*
+
+=item C<int Parrot_gc_get_pmc_index(PARROT_INTERP, PMC* pmc)>
+
+Gets the index of the PMC in the pool. The first PMC in the first pool is 1,
+the second is 2, etc.
+
+=cut
+
+*/
+
+int
+Parrot_gc_get_pmc_index(PARROT_INTERP, ARGIN(PMC* pmc))
 {
-    ASSERT_ARGS(Parrot_gc_profile_start)
-    if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG))
-        interp->profile->gc_time = Parrot_floatval_time();
+    ASSERT_ARGS(Parrot_gc_get_pmc_index)
+    UINTVAL id = 1;     /* first PMC in first arena */
+    Small_Object_Arena *arena;
+    Small_Object_Pool *pool;
+
+    pmc = (PMC*)PObj_to_ARENA(pmc);
+    pool = interp->arena_base->pmc_pool;
+    for (arena = pool->last_Arena; arena; arena = arena->prev) {
+        const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
+        if (ptr_diff >= 0 && ptr_diff <
+                (ptrdiff_t)(arena->used * pool->object_size)) {
+            PARROT_ASSERT(ptr_diff % pool->object_size == 0);
+            id += ptr_diff / pool->object_size;
+            return id;
+        }
+        id += arena->total_objects;
+    }
+
+    pool = interp->arena_base->constant_pmc_pool;
+    for (arena = pool->last_Arena; arena; arena = arena->prev) {
+        const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
+        if (ptr_diff >= 0 && ptr_diff <
+                (ptrdiff_t)(arena->used * pool->object_size)) {
+            PARROT_ASSERT(ptr_diff % pool->object_size == 0);
+            id += ptr_diff / pool->object_size;
+            return id;
+        }
+        id += arena->total_objects;
+    }
+
+    Parrot_ex_throw_from_c_args(interp, NULL, 1, "Couldn't find PMC in arenas");
 }
 
 /*
 
-=item C<void Parrot_gc_profile_end(PARROT_INTERP, int what)>
+=item C<void Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)>
 
-Records the end time of the GC mark run part C<what> run when profiling is
-enabled. Also record start time of next part.
+Cleans up the C<next_for_GC> pointers. Sets all of them in the PMC and Constant
+PMC pools to NULL.
 
 =cut
 
 */
 
 void
-Parrot_gc_profile_end(PARROT_INTERP, int what)
+Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)
 {
-    ASSERT_ARGS(Parrot_gc_profile_end)
-    if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG)) {
-        RunProfile * const profile = interp->profile;
-        const FLOATVAL     now     = Parrot_floatval_time();
+    ASSERT_ARGS(Parrot_gc_cleanup_next_for_GC)
+    cleanup_next_for_GC_pool(interp->arena_base->pmc_pool);
+    cleanup_next_for_GC_pool(interp->arena_base->constant_pmc_pool);
+}
 
-        profile->data[what].numcalls++;
-        profile->data[what].time += now - profile->gc_time;
+/*
 
-        /*
-         * we've recorded the time of a GC piece from
-         * gc_time until now, so add this to the start of the
-         * currently executing opcode, which hasn't run this
-         * interval.
-         */
-        profile->starttime += now - profile->gc_time;
+=item C<static void cleanup_next_for_GC_pool(Small_Object_Pool *pool)>
+
+Sets all the C<next_for_GC> pointers to C<NULL>.
+
+=cut
 
-        /* prepare start for next step */
-        profile->gc_time    = now;
+*/
+
+static void
+cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
+{
+    ASSERT_ARGS(cleanup_next_for_GC_pool)
+    Small_Object_Arena *arena;
+
+    for (arena = pool->last_Arena; arena; arena = arena->prev) {
+        PMC *p = (PMC *)arena->start_objects;
+        UINTVAL i;
+
+        for (i = 0; i < arena->used; i++) {
+            if (!PObj_on_free_list_TEST(p)) {
+                if (p->pmc_ext)
+                    PMC_next_for_GC(p) = PMCNULL;
+            }
+            p++;
+        }
     }
 }
 
 /*
 
-=item C<void Parrot_gc_ms_run_init(PARROT_INTERP)>
+=item C<int Parrot_gc_active_sized_buffers(PARROT_INTERP)>
 
-Prepares the collector for a mark & sweep GC run. This is the
-initializer function for the MS garbage collector.
+Returns the number of actively used sized buffers.
 
 =cut
 
 */
 
+int
+Parrot_gc_active_sized_buffers(PARROT_INTERP)
+{
+    int j, ret = 0;
+    const Arenas * const arena_base = interp->arena_base;
+    for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
+        Small_Object_Pool * const header_pool =
+            arena_base->sized_header_pools[j];
+        if (header_pool)
+            ret += header_pool->total_objects -
+                header_pool->num_free_objects;
+    }
+    return ret;
+}
+
+/*
+
+=item C<int Parrot_gc_total_sized_buffers(PARROT_INTERP)>
+
+Returns the total number of sized buffers that we are managing.
+
+=cut
+
+*/
+
+int
+Parrot_gc_total_sized_buffers(PARROT_INTERP)
+{
+    int j, ret = 0;
+    const Arenas * const arena_base = interp->arena_base;
+    for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
+        Small_Object_Pool * const header_pool =
+            arena_base->sized_header_pools[j];
+        if (header_pool)
+            ret += header_pool->total_objects;
+    }
+    return ret;
+}
+
+/*
+
+=item C<int Parrot_gc_active_pmcs(PARROT_INTERP)>
+
+Return the number of actively used PMCs.
+
+=cut
+
+*/
+
+int
+Parrot_gc_active_pmcs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->pmc_pool->total_objects -
+           arena_base->pmc_pool->num_free_objects;
+}
+
+/*
+
+=item C<int Parrot_gc_total_pmcs(PARROT_INTERP)>
+
+Return the total number of PMCs that we are managing.
+
+=cut
+
+*/
+
+int
+Parrot_gc_total_pmcs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->pmc_pool->total_objects;
+}
+
+/*
+
+=item C<size_t Parrot_gc_count_mark_runs(PARROT_INTERP)>
+
+Return the number of mark runs the GC has performed.
+
+=item C<size_t Parrot_gc_count_collect_runs(PARROT_INTERP)>
+
+Return the number of collect runs the GC has performed.
+
+=item C<size_t Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)>
+
+Return the number of lazy mark runs the GC has performed.
+
+=item C<size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)>
+
+Return the total number of memory allocations made by the GC.
+
+=item C<size_t Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)>
+
+Return the number of new headers allocated since the last collection run.
+
+=item C<size_t Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)>
+
+Return the number of memory allocations made since the last collection run.
+
+=item C<UINTVAL Parrot_gc_total_copied(PARROT_INTERP)>
+
+=item C<UINTVAL Parrot_gc_impatient_pmcs(PARROT_INTERP)>
+
+Returns the number of PMCs that are marked as needing timely destruction.
+
+=item C<UINTVAL Parrot_gc_extended_pmcs(PARROT_INTERP)>
+
+Returns the number of extended PMCs.
+
+=cut
+
+*/
+
+size_t
+Parrot_gc_count_mark_runs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->gc_mark_runs;
+}
+
+size_t
+Parrot_gc_count_collect_runs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->gc_collect_runs;
+}
+
+size_t
+Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->gc_lazy_mark_runs;;
+}
+
+size_t
+Parrot_gc_total_memory_allocated(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->memory_allocated;
+}
+
+size_t
+Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->header_allocs_since_last_collect;
+}
+
+size_t
+Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->mem_allocs_since_last_collect;
+}
+
+UINTVAL
+Parrot_gc_total_copied(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->memory_collected;
+}
+
+UINTVAL
+Parrot_gc_impatient_pmcs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->num_early_gc_PMCs;
+}
+
+UINTVAL
+Parrot_gc_extended_pmcs(PARROT_INTERP)
+{
+    const Arenas * const arena_base = interp->arena_base;
+    return arena_base->num_extended_PMCs;
+}
+
+/*
+
+=item C<void Parrot_block_GC_mark(PARROT_INTERP)>
+
+Blocks the GC from performing it's mark phase.
+
+=item C<void Parrot_unblock_GC_mark(PARROT_INTERP)>
+
+Unblocks the GC mark.
+
+=item C<void Parrot_block_GC_sweep(PARROT_INTERP)>
+
+Blocks the GC from performing it's sweep phase.
+
+=item C<void Parrot_unblock_GC_sweep(PARROT_INTERP)>
+
+Unblocks GC sweep.
+
+=item C<unsigned int Parrot_is_blocked_GC_mark(PARROT_INTERP)>
+
+Determines if the GC mark is currently blocked.
+
+=item C<unsigned int Parrot_is_blocked_GC_sweep(PARROT_INTERP)>
+
+Determines if the GC sweep is currently blocked.
+
+=item C<void Parrot_gc_completely_unblock(PARROT_INTERP)>
+
+Completely unblock the GC mark and sweep. This is only used at interpreter
+destruction, using it anywhere else will cause problems.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_block_GC_mark(PARROT_INTERP)
+{
+    interp->arena_base->gc_mark_block_level++;
+    Parrot_shared_gc_block(interp);
+}
+
+PARROT_EXPORT
+void
+Parrot_unblock_GC_mark(PARROT_INTERP)
+{
+    if (interp->arena_base->gc_mark_block_level) {
+        interp->arena_base->gc_mark_block_level--;
+        Parrot_shared_gc_unblock(interp);
+    }
+}
+
+PARROT_EXPORT
+void
+Parrot_block_GC_sweep(PARROT_INTERP)
+{
+    interp->arena_base->gc_sweep_block_level++;
+}
+
+PARROT_EXPORT
 void
-Parrot_gc_ms_run_init(PARROT_INTERP)
+Parrot_unblock_GC_sweep(PARROT_INTERP)
 {
-    ASSERT_ARGS(Parrot_gc_ms_run_init)
-    Arenas * const arena_base       = interp->arena_base;
+    if (interp->arena_base->gc_sweep_block_level)
+        interp->arena_base->gc_sweep_block_level--;
+}
 
-    arena_base->gc_trace_ptr        = NULL;
-    arena_base->gc_mark_start       = NULL;
-    arena_base->num_early_PMCs_seen = 0;
-    arena_base->num_extended_PMCs   = 0;
+PARROT_EXPORT
+unsigned int
+Parrot_is_blocked_GC_mark(PARROT_INTERP)
+{
+    return interp->arena_base->gc_mark_block_level;
 }
 
+PARROT_EXPORT
+unsigned int
+Parrot_is_blocked_GC_sweep(PARROT_INTERP)
+{
+    return interp->arena_base->gc_sweep_block_level;
+}
+
+void
+Parrot_gc_completely_unblock(PARROT_INTERP)
+{
+    interp->arena_base->gc_mark_block_level  = 0;
+    interp->arena_base->gc_sweep_block_level = 0;
+}
 
 /*
 
-=item C<void Parrot_do_gc_run(PARROT_INTERP, UINTVAL flags)>
+=item C<void Parrot_gc_pmc_needs_early_collection(PARROT_INTERP, PMC *pmc)>
 
-Calls the configured garbage collector to find and reclaim unused
-headers.
+Mark a PMC as needing timely destruction
 
 =cut
 
 */
 
 void
-Parrot_do_gc_run(PARROT_INTERP, UINTVAL flags)
+Parrot_gc_pmc_needs_early_collection(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
-    ASSERT_ARGS(Parrot_do_gc_run)
-    interp->arena_base->do_gc_mark(interp, flags);
-    parrot_gc_context(interp);
+    PObj_needs_early_gc_SET(pmc);
+    ++interp->arena_base->num_early_gc_PMCs;
 }
 
 /*

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/gc_private.h	Sat May  9 20:02:23 2009	(r38654)
@@ -48,6 +48,171 @@
     PObj *next_ptr;
 } GC_MS_PObj_Wrapper;
 
+typedef struct Small_Object_Arena {
+    size_t                     used;
+    size_t                     total_objects;
+    struct Small_Object_Arena *prev;
+    struct Small_Object_Arena *next;
+    void                      *start_objects;
+} Small_Object_Arena;
+
+#if PARROT_GC_GMS
+/*
+ * all objects have this header in front of the actual
+ * object pointer. The prev/next pointers chain all existing
+ * objects for one pool (sizeclass) together.
+ *
+ * XXX this could lead to unaligned FLOATVALs in the adjacent PMC
+ *     if that's true either insert a dummy or reorder PMC members
+ *     ??? How is that possible?
+ */
+typedef struct _gc_gms_hdr {
+    struct _gc_gms_hdr *prev;
+    struct _gc_gms_hdr *next;
+    struct _gc_gms_gen *gen;
+    void *gc_dummy_align;       /* see above */
+} Gc_gms_hdr;
+
+#  define PObj_to_GMSH(o) (((Gc_gms_hdr*)(o))-1)
+#  define GMSH_to_PObj(p) ((PObj*) ((p)+1))
+
+/* the structure uses 2 ptrs itself */
+#  define GC_GMS_STORE_SIZE (64-2)
+
+typedef struct _gc_gms_hdr_store {
+    struct _gc_gms_hdr_store *next;
+    Gc_gms_hdr **ptr;                           /* insert location */
+    Gc_gms_hdr * (store[GC_GMS_STORE_SIZE]);    /* array of hdr pointers */
+} Gc_gms_hdr_store;
+
+typedef struct _gc_gms_hdr_list {
+    Gc_gms_hdr_store *first;
+    Gc_gms_hdr_store *last;
+} Gc_gms_hdr_list;
+
+
+/*
+ * all objects belong to one generation
+ */
+typedef struct _gc_gms_gen {
+    UINTVAL gen_no;                     /* generation number */
+    UINTVAL timely_destruct_obj_sofar;  /* sum up to this generation */
+    UINTVAL black_color;                /* live color of this generation */
+    struct _gc_gms_hdr *first;          /* first header in this generation */
+    struct _gc_gms_hdr *last;           /* last header in this generation */
+    struct _gc_gms_hdr *fin;            /* need destruction/finalization */
+    struct Small_Object_Pool *pool;     /* where this generation belongs to */
+    Gc_gms_hdr_list igp;                /* IGPs for this generation */
+    UINTVAL n_possibly_dead;            /* overwritten count */
+    UINTVAL n_objects;                  /* live objects count */
+    struct _gc_gms_gen *prev;
+    struct _gc_gms_gen *next;
+} Gc_gms_gen;
+
+#endif /* PARROT_GC_GMS */
+
+/* Tracked resource pool */
+typedef struct Small_Object_Pool {
+    Small_Object_Arena *last_Arena;
+    /* Size in bytes of an individual pool item. This size may include
+     * a GC-system specific GC header.
+     * See the macros below.
+     */
+    size_t object_size;
+    size_t objects_per_alloc;
+    size_t total_objects;
+    size_t num_free_objects;    /* number of resources in the free pool */
+    int skip;
+    size_t replenish_level;
+    void *free_list;
+    /* adds a free object to the pool's free list  */
+    add_free_object_fn_type     add_free_object;
+    get_free_object_fn_type     get_free_object;
+    alloc_objects_fn_type       alloc_objects;
+    alloc_objects_fn_type       more_objects;
+    gc_object_fn_type           gc_object;
+    /* gets and removes a free object from the pool's free list */
+    /* allocates more objects */
+    struct Memory_Pool *mem_pool;
+    size_t start_arena_memory;
+    size_t end_arena_memory;
+    const char *name;
+#if PARROT_GC_GMS
+    struct _gc_gms_hdr marker;          /* limit of list */
+    struct _gc_gms_hdr *black;          /* alive */
+    struct _gc_gms_hdr *black_fin;      /* alive, needs destruction */
+    struct _gc_gms_hdr *gray;           /* to be scanned */
+    struct _gc_gms_hdr *white;          /* unprocessed */
+    struct _gc_gms_hdr *white_fin;      /* unprocesse, needs destruction */
+
+    struct _gc_gms_gen *first_gen;      /* linked list of generations */
+    struct _gc_gms_gen *last_gen;
+
+#endif
+} Small_Object_Pool;
+
+typedef struct Arenas {
+    Memory_Pool *memory_pool;
+    Memory_Pool *constant_string_pool;
+    struct Small_Object_Pool *string_header_pool;
+    struct Small_Object_Pool *pmc_pool;
+    struct Small_Object_Pool *pmc_ext_pool;
+    struct Small_Object_Pool *constant_pmc_pool;
+    struct Small_Object_Pool *buffer_header_pool;
+    struct Small_Object_Pool *constant_string_header_pool;
+    struct Small_Object_Pool **sized_header_pools;
+    size_t num_sized;
+    /*
+     * function slots that each subsystem must provide
+     */
+    void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);
+    void (*finalize_gc_system) (PARROT_INTERP);
+    void (*init_pool)(PARROT_INTERP, struct Small_Object_Pool *);
+    /*
+     * statistics for GC
+     */
+    size_t  gc_mark_runs;       /* Number of times we've done a mark run*/
+    size_t  gc_lazy_mark_runs;  /* Number of successful lazy mark runs */
+    size_t  gc_collect_runs;    /* Number of times we've done a memory
+                                   compaction */
+    size_t  mem_allocs_since_last_collect;      /* The number of memory
+                                                 * allocations from the
+                                                 * system since the last
+                                                 * compaction run */
+    size_t  header_allocs_since_last_collect;   /* The number of header
+                                                 * blocks allocated from
+                                                 * the system since the last
+                                                 * GC run */
+    size_t  memory_allocated;     /* The total amount of
+                                   * allocatable memory
+                                   * allocated. Doesn't count
+                                   * memory for headers or
+                                   * internal structures or
+                                   * anything */
+    UINTVAL memory_collected;     /* Total amount of memory copied
+                                     during collection */
+    UINTVAL num_early_gc_PMCs;    /* how many PMCs want immediate destruction */
+    UINTVAL num_early_PMCs_seen;  /* how many such PMCs has GC seen */
+    UINTVAL num_extended_PMCs;    /* active PMCs having pmc_ext */
+    PMC* gc_mark_start;           /* first PMC marked during a GC run */
+    PMC* gc_mark_ptr;             /* last PMC marked during a GC run */
+    PMC* gc_trace_ptr;            /* last PMC trace_children was called on */
+    int lazy_gc;                  /* flag that indicates whether we should stop
+                                     when we've seen all impatient PMCs */
+    /*
+     * GC blocking
+     */
+    UINTVAL gc_mark_block_level;  /* How many outstanding GC block
+                                     requests are there? */
+    UINTVAL gc_sweep_block_level; /* How many outstanding GC block
+                                     requests are there? */
+    /*
+     * private data for the GC subsystem
+     */
+    void *  gc_private;           /* gc subsystem data */
+} Arenas;
+
+
 /* HEADERIZER BEGIN: src/gc/system.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
@@ -64,6 +229,498 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/system.c */
 
+/* HEADERIZER BEGIN: src/gc/generational_ms.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_EXPORT
+void Parrot_gc_gms_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP,
+    ARGMOD(PObj *obj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*obj);
+
+void parrot_gc_gms_wb(PARROT_INTERP,
+    ARGIN(PMC *agg),
+    ARGIN(void *old),
+    ARGIN(void *_new))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+void parrot_gc_gms_wb_key(PARROT_INTERP,
+    ARGIN(PMC *agg),
+    ARGIN(void *old),
+    ARGIN(void *old_key),
+    ARGIN(void *_new),
+    ARGIN(void *new_key))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4)
+        __attribute__nonnull__(5)
+        __attribute__nonnull__(6);
+
+#define ASSERT_ARGS_Parrot_gc_gms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_parrot_gc_gms_Parrot_gc_mark_PObj_alive \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(obj)
+#define ASSERT_ARGS_parrot_gc_gms_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(old) \
+    || PARROT_ASSERT_ARG(_new)
+#define ASSERT_ARGS_parrot_gc_gms_wb_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(old) \
+    || PARROT_ASSERT_ARG(old_key) \
+    || PARROT_ASSERT_ARG(_new) \
+    || PARROT_ASSERT_ARG(new_key)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/generational_ms.c */
+
+/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+void Parrot_gc_ims_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*agg)
+        FUNC_MODIFIES(*_new);
+
+#define ASSERT_ARGS_Parrot_gc_ims_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ims_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(_new)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/incremental_ms.c */
+
+/* HEADERIZER BEGIN: src/gc/mark_sweep.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_WARN_UNUSED_RESULT
+INTVAL contained_in_pool(
+    ARGIN(const Small_Object_Pool *pool),
+    ARGIN(const void *ptr))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+void gc_pmc_ext_pool_init(ARGMOD(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        FUNC_MODIFIES(*pool);
+
+void mark_special(PARROT_INTERP, ARGIN(PMC *obj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_MALLOC
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * new_small_object_pool(
+    size_t object_size,
+    size_t objects_per_alloc);
+
+void Parrot_add_to_free_list(PARROT_INTERP,
+    ARGMOD(Small_Object_Pool *pool),
+    ARGMOD(Small_Object_Arena *arena))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*pool)
+        FUNC_MODIFIES(*arena);
+
+void Parrot_append_arena_in_pool(PARROT_INTERP,
+    ARGMOD(Small_Object_Pool *pool),
+    ARGMOD(Small_Object_Arena *new_arena),
+    size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*pool)
+        FUNC_MODIFIES(*new_arena);
+
+void Parrot_gc_clear_live_bits(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_ms_free_pmc(PARROT_INTERP,
+    SHIM(Small_Object_Pool *pool),
+    ARGMOD(PObj *p))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*p);
+
+void Parrot_gc_ms_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_ms_run(PARROT_INTERP, UINTVAL flags)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_ms_run_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_sweep(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+int Parrot_gc_trace_children(PARROT_INTERP, size_t how_many)
+        __attribute__nonnull__(1);
+
+int Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)
+        __attribute__nonnull__(1);
+
+int Parrot_is_const_pmc(PARROT_INTERP, ARGIN(const PMC *pmc))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+void Parrot_small_object_pool_merge(PARROT_INTERP,
+    ARGMOD(Small_Object_Pool *dest),
+    ARGMOD(Small_Object_Pool *source))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*dest)
+        FUNC_MODIFIES(*source);
+
+#define ASSERT_ARGS_contained_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(pool) \
+    || PARROT_ASSERT_ARG(ptr)
+#define ASSERT_ARGS_gc_pmc_ext_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_mark_special __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(obj)
+#define ASSERT_ARGS_new_small_object_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
+#define ASSERT_ARGS_Parrot_add_to_free_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool) \
+    || PARROT_ASSERT_ARG(arena)
+#define ASSERT_ARGS_Parrot_append_arena_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool) \
+    || PARROT_ASSERT_ARG(new_arena)
+#define ASSERT_ARGS_Parrot_gc_clear_live_bits __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ms_free_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(p)
+#define ASSERT_ARGS_Parrot_gc_ms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ms_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ms_run_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_Parrot_gc_trace_children __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_trace_root __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_is_const_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_small_object_pool_merge \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(dest) \
+    || PARROT_ASSERT_ARG(source)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/mark_sweep.c */
+
+/* HEADERIZER BEGIN: src/gc/pools.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+void free_pool(ARGMOD(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        FUNC_MODIFIES(*pool);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+void * get_free_buffer(PARROT_INTERP, ARGIN(Small_Object_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+size_t get_max_buffer_address(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+size_t get_max_pmc_address(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+size_t get_min_buffer_address(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+size_t get_min_pmc_address(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+int is_buffer_ptr(PARROT_INTERP, ARGIN(const void *ptr))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+int is_pmc_ptr(PARROT_INTERP, ARGIN(const void *ptr))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * new_buffer_pool(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * new_bufferlike_pool(PARROT_INTERP,
+    size_t actual_buffer_size)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * new_pmc_pool(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL constant)
+        __attribute__nonnull__(1);
+
+PARROT_IGNORABLE_RESULT
+int /*@alt void@*/
+Parrot_forall_header_pools(PARROT_INTERP,
+    int flag,
+    ARGIN_NULLOK(void *arg),
+    NOTNULL(pool_iter_fn func))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(4);
+
+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 = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_get_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_get_max_buffer_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_get_max_pmc_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_get_min_buffer_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_get_min_pmc_address __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_is_buffer_ptr __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(ptr)
+#define ASSERT_ARGS_is_pmc_ptr __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(ptr)
+#define ASSERT_ARGS_new_buffer_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_new_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_new_pmc_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_new_string_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_forall_header_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(func)
+#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 */
+
+/* HEADERIZER BEGIN: src/gc/resources.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+char * aligned_mem(ARGIN(const Buffer *buffer), ARGIN(char *mem))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_PURE_FUNCTION
+PARROT_WARN_UNUSED_RESULT
+size_t aligned_size(ARGIN(const Buffer *buffer), size_t len)
+        __attribute__nonnull__(1);
+
+PARROT_CONST_FUNCTION
+PARROT_WARN_UNUSED_RESULT
+size_t aligned_string_size(size_t len);
+
+void compact_pool(PARROT_INTERP, ARGMOD(Memory_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_MALLOC
+PARROT_CANNOT_RETURN_NULL
+void * mem_allocate(PARROT_INTERP, size_t size, ARGMOD(Memory_Pool *pool))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*pool);
+
+void merge_pools(ARGMOD(Memory_Pool *dest), ARGMOD(Memory_Pool *source))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*dest)
+        FUNC_MODIFIES(*source);
+
+void Parrot_allocate(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
+
+void Parrot_gc_profile_end(PARROT_INTERP, int what)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_profile_start(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_initialize_memory_pools(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+#define ASSERT_ARGS_aligned_mem __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(buffer) \
+    || PARROT_ASSERT_ARG(mem)
+#define ASSERT_ARGS_aligned_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(buffer)
+#define ASSERT_ARGS_aligned_string_size __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
+#define ASSERT_ARGS_compact_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_mem_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(pool)
+#define ASSERT_ARGS_merge_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(dest) \
+    || PARROT_ASSERT_ARG(source)
+#define ASSERT_ARGS_Parrot_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(buffer)
+#define ASSERT_ARGS_Parrot_gc_profile_end __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_profile_start __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_initialize_memory_pools \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/resources.c */
+
+/* GC subsystem init functions */
+/* HEADERIZER BEGIN: src/gc/generational_ms.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_EXPORT
+void Parrot_gc_gms_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*obj);
+
+void parrot_gc_gms_wb(PARROT_INTERP,
+    ARGIN(PMC *agg),
+    ARGIN(void *old),
+    ARGIN(void *_new))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+void parrot_gc_gms_wb_key(PARROT_INTERP,
+    ARGIN(PMC *agg),
+    ARGIN(void *old),
+    ARGIN(void *old_key),
+    ARGIN(void *_new),
+    ARGIN(void *new_key))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4)
+        __attribute__nonnull__(5)
+        __attribute__nonnull__(6);
+
+#define ASSERT_ARGS_Parrot_gc_gms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_parrot_gc_gms_Parrot_gc_mark_PObj_alive __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(obj)
+#define ASSERT_ARGS_parrot_gc_gms_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(old) \
+    || PARROT_ASSERT_ARG(_new)
+#define ASSERT_ARGS_parrot_gc_gms_wb_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(old) \
+    || PARROT_ASSERT_ARG(old_key) \
+    || PARROT_ASSERT_ARG(_new) \
+    || PARROT_ASSERT_ARG(new_key)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/generational_ms.c */
+
+/* HEADERIZER BEGIN: src/gc/incremental_ms.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+void Parrot_gc_ims_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_gc_ims_wb(PARROT_INTERP, ARGMOD(PMC *agg), ARGMOD(PMC *_new))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*agg)
+        FUNC_MODIFIES(*_new);
+
+#define ASSERT_ARGS_Parrot_gc_ims_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_gc_ims_wb __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(agg) \
+    || PARROT_ASSERT_ARG(_new)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/gc/incremental_ms.c */
+
+
 #endif /* PARROT_GC_PRIVATE_H_GUARD */
 
 /*

Modified: trunk/src/gc/generational_ms.c
==============================================================================
--- trunk/src/gc/generational_ms.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/generational_ms.c	Sat May  9 20:02:23 2009	(r38654)
@@ -112,7 +112,6 @@
 
 #include "parrot/parrot.h"
 #include "parrot/gc_api.h"
-#include "parrot/gc_mark_sweep.h"
 
 #if PARROT_GC_GMS
 
@@ -120,7 +119,7 @@
     UINTVAL current_gen_no;             /* the nursery generation number */
 } Gc_gms_private;
 
-/* HEADERIZER HFILE: include/parrot/gc_api.h */
+/* HEADERIZER HFILE: src/gc/gc_private.h */
 
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -744,7 +743,7 @@
     if (pool->skip)
         pool->skip = 0;
     else if (pool->last_Arena) {
-        Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+        Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
         if (pool->num_free_objects <= pool->replenish_level)
             pool->skip = 1;
     }
@@ -1452,9 +1451,9 @@
 
 /*
 
-=item C<void parrot_gc_gms_pobject_lives(PARROT_INTERP, PObj *obj)>
+=item C<void parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, PObj *obj)>
 
-Set the object live - called by the pobject_lives macro
+Set the object live - called by the Parrot_gc_mark_PObj_alive macro
 
 =cut
 
@@ -1462,9 +1461,9 @@
 
 PARROT_EXPORT
 void
-parrot_gc_gms_pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
+parrot_gc_gms_Parrot_gc_mark_PObj_alive(PARROT_INTERP, ARGMOD(PObj *obj))
 {
-    ASSERT_ARGS(parrot_gc_gms_pobject_lives)
+    ASSERT_ARGS(parrot_gc_gms_Parrot_gc_mark_PObj_alive)
     Gc_gms_hdr *h;
     int priority;
 
@@ -1545,7 +1544,7 @@
         const Gc_gms_hdr **p;
         for (p = s->store; p < s->ptr; ++p) {
             Gc_gms_hdr * const h = *p;
-            pobject_lives(interp, GMSH_to_PObj(h));
+            Parrot_gc_mark_PObj_alive(interp, GMSH_to_PObj(h));
         }
     }
     return 0;
@@ -1598,7 +1597,7 @@
                 arena_base->num_early_gc_PMCs) {
             return 1;
         }
-        /* TODO propagate flag in pobject_lives */
+        /* TODO propagate flag in Parrot_gc_mark_PObj_alive */
         arena_base->gc_trace_ptr = current;
         if (!PObj_needs_early_gc_TEST(current))
             PObj_high_priority_gc_CLEAR(current);
@@ -1815,7 +1814,7 @@
 
 =item C<static void parrot_gc_gms_run(PARROT_INTERP, UINTVAL flags)>
 
-Interface to C<Parrot_do_gc_run>. C<flags> is one of:
+Interface to C<Parrot_gc_mark_and_sweep>. C<flags> is one of:
 
   GC_lazy_FLAG   ... timely destruction
   GC_finish_FLAG ... run a final sweep to destruct objects at

Modified: trunk/src/gc/incremental_ms.c
==============================================================================
--- trunk/src/gc/incremental_ms.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/incremental_ms.c	Sat May  9 20:02:23 2009	(r38654)
@@ -330,9 +330,9 @@
 
 #include "parrot/parrot.h"
 #include "parrot/gc_api.h"
-#include "parrot/gc_mark_sweep.h"
+#include "gc_private.h"
 
-/* HEADERIZER HFILE: include/parrot/gc_api.h */
+/* HEADERIZER HFILE: src/gc/gc_private.h */
 
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -1011,7 +1011,7 @@
 
 =item C<static void parrot_gc_ims_run(PARROT_INTERP, UINTVAL flags)>
 
-Interface to C<Parrot_do_gc_run>. C<flags> is one of:
+Interface to C<Parrot_gc_mark_and_sweep>. C<flags> is one of:
 
   GC_lazy_FLAG   ... timely destruction
   GC_finish_FLAG ... run until live bits are clear
@@ -1132,10 +1132,10 @@
     IMS_DEBUG((stderr, "%d agg %p mark %p\n",
                 ((Gc_ims_private *)interp->arena_base->
                 gc_private)->state, agg, _new));
-    pobject_lives(interp, (PObj*)_new);
+    Parrot_gc_mark_PObj_alive(interp, (PObj*)_new);
 #else
     PObj_get_FLAGS(agg) &= ~ (PObj_live_FLAG|PObj_custom_GC_FLAG);
-    pobject_lives(interp, (PObj*)agg);
+    Parrot_gc_mark_PObj_alive(interp, (PObj*)agg);
 #endif
 }
 

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/mark_sweep.c	Sat May  9 20:02:23 2009	(r38654)
@@ -20,10 +20,9 @@
 */
 
 #include "parrot/parrot.h"
-#include "parrot/gc_mark_sweep.h"
 #include "gc_private.h"
 
-/* HEADERIZER HFILE: include/parrot/gc_mark_sweep.h */
+/* HEADERIZER HFILE: src/gc/gc_private.h */
 
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -71,10 +70,6 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pool);
 
-static void mark_special(PARROT_INTERP, ARGIN(PMC *obj))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
 static void more_traceable_objects(PARROT_INTERP,
     ARGMOD(Small_Object_Pool *pool))
         __attribute__nonnull__(1)
@@ -113,9 +108,6 @@
     || PARROT_ASSERT_ARG(pool)
 #define ASSERT_ARGS_gc_ms_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_mark_special __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(obj)
 #define ASSERT_ARGS_more_traceable_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pool)
@@ -138,6 +130,9 @@
 
 #define POOL_MAX_BYTES                         65536 * 128
 
+/* Set when walking the system stack */
+int CONSERVATIVE_POINTER_CHASING = 0;
+
 /*
 
 =item C<void Parrot_gc_ms_run(PARROT_INTERP, UINTVAL flags)>
@@ -182,7 +177,7 @@
         /* keep the scheduler and its kids alive for Task-like PMCs to destroy
          * themselves; run a sweep to collect them */
         if (interp->scheduler) {
-            pobject_lives(interp, (PObj *)interp->scheduler);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->scheduler);
             VTABLE_mark(interp, interp->scheduler);
             Parrot_gc_sweep(interp, interp->arena_base->pmc_pool);
         }
@@ -202,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)
@@ -299,12 +294,12 @@
     }
 
     /* mark it as used  */
-    pobject_lives(interp, (PObj *)interp->iglobals);
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->iglobals);
 
     /* mark the current continuation */
     obj = (PObj *)interp->current_cont;
     if (obj && obj != (PObj *)NEED_CONTINUATION)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     /* mark the current context. */
     ctx = CONTEXT(interp);
@@ -325,11 +320,11 @@
     mark_vtables(interp);
 
     /* mark the root_namespace */
-    pobject_lives(interp, (PObj *)interp->root_namespace);
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->root_namespace);
 
     /* mark the concurrency scheduler */
     if (interp->scheduler)
-        pobject_lives(interp, (PObj *)interp->scheduler);
+        Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->scheduler);
 
     /* s. packfile.c */
     mark_const_subs(interp);
@@ -338,11 +333,11 @@
     mark_object_cache(interp);
 
     /* Now mark the class hash */
-    pobject_lives(interp, (PObj *)interp->class_hash);
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->class_hash);
 
     /* Mark the registry */
     PARROT_ASSERT(interp->gc_registry);
-    pobject_lives(interp, (PObj *)interp->gc_registry);
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)interp->gc_registry);
 
     /* Mark the MMD cache. */
     if (interp->op_mmd_cache)
@@ -366,6 +361,69 @@
     return 1;
 }
 
+/*
+
+=item C<void Parrot_gc_ms_run_init(PARROT_INTERP)>
+
+Prepares the collector for a mark & sweep GC run. This is the
+initializer function for the MS garbage collector.
+
+=cut
+
+*/
+
+void
+Parrot_gc_ms_run_init(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_gc_ms_run_init)
+    Arenas * const arena_base       = interp->arena_base;
+
+    arena_base->gc_trace_ptr        = NULL;
+    arena_base->gc_mark_start       = NULL;
+    arena_base->num_early_PMCs_seen = 0;
+    arena_base->num_extended_PMCs   = 0;
+}
+
+
+/*
+
+=item C<void Parrot_gc_ms_free_pmc(PARROT_INTERP, Small_Object_Pool *pool, PObj
+*p)>
+
+Frees a PMC that is no longer being used. Calls a custom C<destroy> VTABLE
+method if one is available. If the PMC uses a PMC_EXT structure, that is freed
+as well.
+
+=cut
+
+*/
+
+void
+Parrot_gc_ms_free_pmc(PARROT_INTERP, SHIM(Small_Object_Pool *pool),
+        ARGMOD(PObj *p))
+{
+    ASSERT_ARGS(Parrot_gc_ms_free_pmc)
+    PMC    * const pmc        = (PMC *)p;
+    Arenas * const arena_base = interp->arena_base;
+
+    /* TODO collect objects with finalizers */
+    if (PObj_needs_early_gc_TEST(p))
+        --arena_base->num_early_gc_PMCs;
+
+    if (PObj_active_destroy_TEST(p))
+        VTABLE_destroy(interp, pmc);
+
+    if (PObj_is_PMC_EXT_TEST(p))
+         Parrot_gc_free_pmc_ext(interp, pmc);
+
+#ifndef NDEBUG
+
+    pmc->pmc_ext     = (PMC_EXT *)0xdeadbeef;
+    pmc->vtable      = (VTABLE  *)0xdeadbeef;
+
+#endif
+
+}
 
 /*
 
@@ -445,7 +503,8 @@
                     }
                 }
 
-                gc_object(interp, pool, b);
+                if(gc_object)
+                    gc_object(interp, pool, b);
 
                 pool->add_free_object(interp, pool, b);
             }
@@ -459,69 +518,6 @@
 
 
 
-/*
-
-=item C<void pobject_lives(PARROT_INTERP, PObj *obj)>
-
-Marks the PObj as "alive" for the Garbage Collector. Takes a pointer to a PObj,
-and performs necessary marking to ensure the PMC and its direct children nodes
-are marked alive. Implementation is generally dependant on the particular
-garbage collector in use.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-pobject_lives(PARROT_INTERP, ARGMOD(PObj *obj))
-{
-    ASSERT_ARGS(pobject_lives)
-#if PARROT_GC_GMS
-    do {
-        if (!PObj_live_TEST(obj) && \
-                PObj_to_GMSH(obj)->gen->gen_no >= interp->gc_generation) \
-            parrot_gc_gms_pobject_lives(interp, obj); \
-    } while (0);
-#else /* not PARROT_GC_GMS */
-
-    /* if object is live or on free list return */
-    if (PObj_is_live_or_free_TESTALL(obj))
-        return;
-
-#  if ! DISABLE_GC_DEBUG
-#    if GC_VERBOSE
-    if (CONSERVATIVE_POINTER_CHASING)
-        fprintf(stderr, "GC Warning! Unanchored %s %p found in system areas \n",
-                PObj_is_PMC_TEST(obj) ? "PMC" : "Buffer", obj);
-
-#    endif
-#  endif
-    /* mark it live */
-    PObj_live_SET(obj);
-
-    /* if object is a PMC and contains buffers or PMCs, then attach the PMC
-     * to the chained mark list. */
-    if (PObj_is_PMC_TEST(obj)) {
-        PMC * const p = (PMC *)obj;
-
-        if (PObj_is_special_PMC_TEST(obj))
-            mark_special(interp, p);
-
-#  ifndef NDEBUG
-        else if (p->pmc_ext && PMC_metadata(p))
-            fprintf(stderr, "GC: error obj %p (%s) has properties\n",
-                    (void *)p, (char*)p->vtable->whoami->strstart);
-#  endif
-    }
-#  if GC_VERBOSE
-    /* buffer GC_DEBUG stuff */
-    if (GC_DEBUG(interp) && PObj_report_TEST(obj))
-        fprintf(stderr, "GC: buffer %p pointing to %p marked live\n",
-                obj, PObj_bufstart((Buffer *)obj));
-#  endif
-#endif  /* PARROT_GC_GMS */
-}
 
 /*
 
@@ -586,7 +582,7 @@
 
 /*
 
-=item C<static void mark_special(PARROT_INTERP, PMC *obj)>
+=item C<void mark_special(PARROT_INTERP, PMC *obj)>
 
 Marks the children of a special PMC. Handles the marking necessary
 for shared PMCs, and ensures timely marking of high-priority PMCs.
@@ -597,7 +593,7 @@
 
 */
 
-static void
+void
 mark_special(PARROT_INTERP, ARGIN(PMC *obj))
 {
     ASSERT_ARGS(mark_special)
@@ -701,14 +697,14 @@
         Small_Object_Arena * const arena = pool->last_Arena;
         if (arena) {
             if (arena->used == arena->total_objects)
-                Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+                Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 
             if (pool->num_free_objects <= pool->replenish_level)
                 pool->skip = 1;
         }
     }
 
-    /* requires that num_free_objects be updated in Parrot_do_gc_run. If gc
+    /* requires that num_free_objects be updated in Parrot_gc_mark_and_sweep. If gc
      * is disabled, then we must check the free list directly. */
     if (!pool->free_list)
         (*pool->alloc_objects) (interp, pool);
@@ -998,7 +994,7 @@
 
         /* mark properties */
         if (PMC_metadata(current))
-            pobject_lives(interp, (PObj *)PMC_metadata(current));
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)PMC_metadata(current));
 
          if (PObj_custom_mark_TEST(current)) {
             PARROT_ASSERT(!PObj_on_free_list_TEST(current));

Modified: trunk/src/gc/memory.c
==============================================================================
--- trunk/src/gc/memory.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/memory.c	Sat May  9 20:02:23 2009	(r38654)
@@ -343,44 +343,6 @@
 
 /*
 
-=item C<void mem_setup_allocator(PARROT_INTERP, void *stacktop)>
-
-Initializes the memory allocator and the garbage collection subsystem.
-Calls the initialization function associated with each collector, which
-is determined at compile time.
-
-The "stacktop" parameter is required; it provides an upper bound for
-stack scanning during a garbage collection run.
-
-=cut
-
-*/
-
-void
-mem_setup_allocator(PARROT_INTERP, ARGIN(void *stacktop))
-{
-    ASSERT_ARGS(mem_setup_allocator)
-    interp->arena_base = mem_allocate_zeroed_typed(Arenas);
-    interp->arena_base->sized_header_pools = NULL;
-
-    interp->lo_var_ptr = stacktop;
-
-#if PARROT_GC_MS
-    Parrot_gc_ms_init(interp);
-#endif
-#if PARROT_GC_IMS
-    Parrot_gc_ims_init(interp);
-#endif
-#if PARROT_GC_GMS
-    Parrot_gc_gms_init(interp);
-#endif
-
-    Parrot_initialize_memory_pools(interp);
-    Parrot_initialize_header_pools(interp);
-}
-
-/*
-
 =back
 
 =cut

Modified: trunk/src/gc/pools.c
==============================================================================
--- trunk/src/gc/pools.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/pools.c	Sat May  9 20:02:23 2009	(r38654)
@@ -15,53 +15,32 @@
 */
 
 #include "parrot/parrot.h"
-#include "parrot/gc_pools.h"
+#include "gc_private.h"
 
-/* HEADERIZER HFILE: include/parrot/gc_pools.h */
+/* HEADERIZER HFILE: src/gc/gc_private.h */
 
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-static void fix_pmc_syncs(
-    ARGMOD(Interp *dest_interp),
-    ARGIN(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*dest_interp);
-
-static void free_pool(ARGMOD(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        FUNC_MODIFIES(*pool);
-
-static int sweep_cb_buf(PARROT_INTERP,
-    ARGMOD(Small_Object_Pool *pool),
-    SHIM(int flag),
-    ARGIN(void *arg))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(4)
-        FUNC_MODIFIES(*pool);
-
-static int sweep_cb_pmc(PARROT_INTERP,
+static void Parrot_gc_free_buffer(SHIM_INTERP,
     ARGMOD(Small_Object_Pool *pool),
-    SHIM(int flag),
-    SHIM(void *arg))
-        __attribute__nonnull__(1)
+    ARGMOD(PObj *b))
         __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
-#define ASSERT_ARGS_fix_pmc_syncs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(dest_interp) \
-    || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_free_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_sweep_cb_buf __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool) \
-    || PARROT_ASSERT_ARG(arg)
-#define ASSERT_ARGS_sweep_cb_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool)
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*pool)
+        FUNC_MODIFIES(*b);
+
+static void Parrot_gc_free_buffer_malloc(SHIM_INTERP,
+    SHIM(Small_Object_Pool *pool),
+    ARGMOD(PObj *b))
+        __attribute__nonnull__(3)
+        FUNC_MODIFIES(*b);
+
+#define ASSERT_ARGS_Parrot_gc_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(pool) \
+    || PARROT_ASSERT_ARG(b)
+#define ASSERT_ARGS_Parrot_gc_free_buffer_malloc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(b)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
 
@@ -76,7 +55,32 @@
 #  define STRING_HEADERS_PER_ALLOC 10240 / sizeof (STRING)
 #endif /* GC_IS_MALLOC */
 
-#  define CONSTANT_PMC_HEADERS_PER_ALLOC 64
+#define CONSTANT_PMC_HEADERS_PER_ALLOC 64
+#define GET_SIZED_POOL_IDX(x) ((x) / sizeof (void *))
+
+/*
+
+=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);
+}
 
 /*
 
@@ -141,7 +145,7 @@
         new_small_object_pool(sizeof (PMC), num_headers);
 
     pmc_pool->mem_pool   = NULL;
-    pmc_pool->gc_object  = Parrot_gc_free_pmc;
+    pmc_pool->gc_object  = Parrot_gc_ms_free_pmc;
 
     (interp->arena_base->init_pool)(interp, pmc_pool);
     return pmc_pool;
@@ -172,7 +176,7 @@
     Small_Object_Pool * const pool =
             new_small_object_pool(buffer_size, num_headers);
 
-    pool->gc_object = Parrot_gc_free_sysmem;
+    pool->gc_object = NULL;
     pool->mem_pool  = interp->arena_base->memory_pool;
     (interp->arena_base->init_pool)(interp, pool);
     return pool;
@@ -208,6 +212,72 @@
     return pool;
 }
 
+/*
+
+=item C<static void Parrot_gc_free_buffer_malloc(PARROT_INTERP,
+Small_Object_Pool *pool, PObj *b)>
+
+Frees the given buffer, returning the storage space to the operating system
+and removing it from Parrot's memory management system. If the buffer is COW,
+The buffer is not freed if the reference count is greater then 1.
+
+=cut
+
+*/
+
+static void
+Parrot_gc_free_buffer_malloc(SHIM_INTERP, SHIM(Small_Object_Pool *pool),
+        ARGMOD(PObj *b))
+{
+    ASSERT_ARGS(Parrot_gc_free_buffer_malloc)
+    /* free allocated space at (int *)bufstart - 1, but not if it used COW or is
+     * external */
+    PObj_buflen(b) = 0;
+
+    if (!PObj_bufstart(b) || PObj_is_external_or_free_TESTALL(b))
+        return;
+
+    if (PObj_COW_TEST(b)) {
+        INTVAL * const refcount = PObj_bufrefcountptr(b);
+
+        if (--(*refcount) == 0) {
+            mem_sys_free(refcount); /* the actual bufstart */
+        }
+    }
+    else
+        mem_sys_free(PObj_bufrefcountptr(b));
+}
+
+/*
+
+=item C<static void Parrot_gc_free_buffer(PARROT_INTERP, Small_Object_Pool
+*pool, PObj *b)>
+
+Frees a buffer, returning it to the memory pool for Parrot to possibly
+reuse later.
+
+=cut
+
+*/
+
+static void
+Parrot_gc_free_buffer(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGMOD(PObj *b))
+{
+    ASSERT_ARGS(Parrot_gc_free_buffer)
+    Memory_Pool * const mem_pool = (Memory_Pool *)pool->mem_pool;
+
+    /* XXX Jarkko reported that on irix pool->mem_pool was NULL, which really
+     * shouldn't happen */
+    if (mem_pool) {
+        if (!PObj_COW_TEST(b))
+            mem_pool->guaranteed_reclaimable += PObj_buflen(b);
+
+         mem_pool->possibly_reclaimable += PObj_buflen(b);
+    }
+
+    PObj_buflen(b)        = 0;
+}
+
 
 /*
 
@@ -261,8 +331,7 @@
     ASSERT_ARGS(get_bufferlike_pool)
     Small_Object_Pool **sized_pools = interp->arena_base->sized_header_pools;
     const UINTVAL       num_old     = interp->arena_base->num_sized;
-    const UINTVAL       idx         =
-                            (buffer_size - sizeof (Buffer)) / sizeof (void *);
+    const UINTVAL       idx         = GET_SIZED_POOL_IDX(buffer_size);
 
     /* Expands the array of sized resource pools, if necessary */
     if (num_old <= idx) {
@@ -601,7 +670,7 @@
 
 /*
 
-=item C<static void free_pool(Small_Object_Pool *pool)>
+=item C<void free_pool(Small_Object_Pool *pool)>
 
 Frees a pool and all of its arenas. Loops through the list of arenas backwards
 and returns each to the memory manager. Then, frees the pool structure itself.
@@ -610,7 +679,7 @@
 
 */
 
-static void
+void
 free_pool(ARGMOD(Small_Object_Pool *pool))
 {
     ASSERT_ARGS(free_pool)
@@ -625,210 +694,6 @@
     mem_internal_free(pool);
 }
 
-
-/*
-
-=item C<static int sweep_cb_buf(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Performs a final garbage collection sweep, then frees the pool. Calls
-C<Parrot_gc_sweep> to perform the sweep, and C<free_pool> to free the pool and
-all its arenas.
-
-=cut
-
-*/
-
-static int
-sweep_cb_buf(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool), SHIM(int flag),
-        ARGIN(void *arg))
-{
-#ifdef GC_IS_MALLOC
-    const int pass = (int)(INTVAL)arg;
-
-    if (pass == 0)
-        clear_cow(interp, pool, 1);
-    else if (pass == 1)
-        used_cow(interp, pool, 1);
-    else
-#endif
-
-    {
-        UNUSED(arg);
-        Parrot_gc_sweep(interp, pool);
-        free_pool(pool);
-    }
-
-    return 0;
-}
-
-
-/*
-
-=item C<static int sweep_cb_pmc(PARROT_INTERP, Small_Object_Pool *pool, int
-flag, void *arg)>
-
-Performs a garbage collection sweep of the given pmc pool, then frees it. Calls
-C<Parrot_gc_sweep> to perform the sweep, and C<free_pool> to free the pool and
-all its arenas. Always returns C<0>.
-
-=cut
-
-*/
-
-static int
-sweep_cb_pmc(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool),
-        SHIM(int flag), SHIM(void *arg))
-{
-    Parrot_gc_sweep(interp, pool);
-    free_pool(pool);
-    return 0;
-}
-
-
-/*
-
-=item C<void Parrot_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
-C<sweep_cb_pmc> and C<sweep_cb_buf> callback routines. Frees the array of sized
-header pointers in the C<Arenas> structure too.
-
-=cut
-
-*/
-
-void
-Parrot_destroy_header_pools(PARROT_INTERP)
-{
-    ASSERT_ARGS(Parrot_destroy_header_pools)
-    INTVAL pass;
-
-    /* const/non const COW strings life in different pools
-     * so in first pass
-     * COW refcount is done, in 2. refcounting
-     * in 3rd freeing
-     */
-#ifdef GC_IS_MALLOC
-    const INTVAL start = 0;
-#else
-    const INTVAL start = 2;
-#endif
-
-    Parrot_forall_header_pools(interp, POOL_PMC, NULL, sweep_cb_pmc);
-    Parrot_forall_header_pools(interp, POOL_PMC | POOL_CONST, NULL,
-            sweep_cb_pmc);
-
-    for (pass = start; pass <= 2; pass++) {
-        Parrot_forall_header_pools(interp, POOL_BUFFER | POOL_CONST,
-                (void *)pass, sweep_cb_buf);
-    }
-
-    free_pool(interp->arena_base->pmc_ext_pool);
-    interp->arena_base->pmc_ext_pool = NULL;
-
-    mem_internal_free(interp->arena_base->sized_header_pools);
-    interp->arena_base->sized_header_pools = NULL;
-}
-
-
-/*
-
-=item C<static void fix_pmc_syncs(Interp *dest_interp, Small_Object_Pool *pool)>
-
-Walks through the given arena, looking for all live and shared PMCs,
-transferring their sync values to the destination interpreter.
-
-=cut
-
-*/
-
-static void
-fix_pmc_syncs(ARGMOD(Interp *dest_interp), ARGIN(Small_Object_Pool *pool))
-{
-    ASSERT_ARGS(fix_pmc_syncs)
-    Small_Object_Arena *cur_arena;
-    const UINTVAL       object_size = pool->object_size;
-
-    for (cur_arena = pool->last_Arena; cur_arena; cur_arena = cur_arena->prev) {
-        PMC   *p = (PMC *)((char*)cur_arena->start_objects + GC_HEADER_SIZE);
-        size_t i;
-
-        for (i = 0; i < cur_arena->used; i++) {
-            if (!PObj_on_free_list_TEST(p) && PObj_is_PMC_TEST(p)) {
-                if (PObj_is_PMC_shared_TEST(p))
-                    PMC_sync(p)->owner = dest_interp;
-                else
-                    Parrot_ex_throw_from_c_args(dest_interp, NULL,
-                        EXCEPTION_INTERP_ERROR,
-                        "Unshared PMC still alive after interpreter"
-                        "destruction. address=%p, base_type=%d\n",
-                        p, p->vtable->base_type);
-            }
-
-            p = (PMC *)((char *)p + object_size);
-        }
-    }
-}
-
-
-/*
-
-=item C<void Parrot_merge_header_pools(Interp *dest_interp, Interp
-*source_interp)>
-
-Merges the header pools of C<source_interp> into those of C<dest_interp>.
-(Used to deal with shared objects left after interpreter destruction.)
-
-=cut
-
-*/
-
-void
-Parrot_merge_header_pools(ARGMOD(Interp *dest_interp), ARGIN(Interp *source_interp))
-{
-    ASSERT_ARGS(Parrot_merge_header_pools)
-
-    Arenas * const dest_arena   = dest_interp->arena_base;
-    Arenas * const source_arena = source_interp->arena_base;
-    UINTVAL        i;
-
-    /* heavily borrowed from forall_header_pools */
-    fix_pmc_syncs(dest_interp, source_arena->constant_pmc_pool);
-    Parrot_small_object_pool_merge(dest_interp, dest_arena->constant_pmc_pool,
-            source_arena->constant_pmc_pool);
-
-    fix_pmc_syncs(dest_interp, source_arena->pmc_pool);
-    Parrot_small_object_pool_merge(dest_interp, dest_arena->pmc_pool,
-            source_arena->pmc_pool);
-
-    Parrot_small_object_pool_merge(dest_interp,
-            dest_arena->constant_string_header_pool,
-            source_arena->constant_string_header_pool);
-
-    Parrot_small_object_pool_merge(dest_interp,
-            dest_arena->pmc_ext_pool, source_arena->pmc_ext_pool);
-
-    for (i = 0; i < source_arena->num_sized; ++i) {
-        if (!source_arena->sized_header_pools[i])
-            continue;
-
-        if (i >= dest_arena->num_sized
-        || !dest_arena->sized_header_pools[i]) {
-            Small_Object_Pool *ignored = get_bufferlike_pool(dest_interp,
-                    i * sizeof (void *) + sizeof (Buffer));
-            UNUSED(ignored);
-            PARROT_ASSERT(dest_arena->sized_header_pools[i]);
-        }
-
-        Parrot_small_object_pool_merge(dest_interp,
-            dest_arena->sized_header_pools[i],
-            source_arena->sized_header_pools[i]);
-    }
-}
-
-
 /*
 
 =back

Modified: trunk/src/gc/res_lea.c
==============================================================================
--- trunk/src/gc/res_lea.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/res_lea.c	Sat May  9 20:02:23 2009	(r38654)
@@ -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) {
@@ -117,7 +117,7 @@
 
 /*
 
-=item C<void Parrot_reallocate(PARROT_INTERP, Buffer *buffer, size_t newsize)>
+=item C<void Parrot_gc_reallocate_buffer_storage(PARROT_INTERP, Buffer *buffer, size_t newsize)>
 
 COWable objects (strings or Buffers) use an INTVAL before C<bufstart> for
 refcounting in GC.
@@ -127,14 +127,14 @@
 */
 
 void
-Parrot_reallocate(PARROT_INTERP, Buffer *buffer, size_t newsize)
+Parrot_gc_reallocate_buffer_storage(PARROT_INTERP, Buffer *buffer, size_t newsize)
 {
     ASSERT_ARGS(parrot_reallocate)
     const size_t oldlen = PObj_buflen(buffer);
     Buffer_alloc_unit *p;
 
     if (!PObj_bufstart(buffer)) {
-        Parrot_allocate_aligned(interp, buffer, newsize);
+        Parrot_gc_allocate_buffer_storage_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_buffer_storage_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_buffer_storage_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)
 }
@@ -288,7 +289,7 @@
 
 =head1 SEE ALSO
 
-F<config/auto/gc.pl>, F<src/malloc.c>, F<include/parrot/resources.h>.
+F<config/auto/gc.pl>, F<src/malloc.c>
 
 =cut
 

Modified: trunk/src/gc/resources.c
==============================================================================
--- trunk/src/gc/resources.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/resources.c	Sat May  9 20:02:23 2009	(r38654)
@@ -19,7 +19,8 @@
 */
 
 #include "parrot/parrot.h"
-#include "parrot/resources.h"
+#include "gc_private.h"
+
 
 #define RECLAMATION_FACTOR 0.20
 #define WE_WANT_EVER_GROWING_ALLOCATIONS 0
@@ -32,26 +33,11 @@
 
 typedef void (*compact_f) (Interp *, Memory_Pool *);
 
-/* HEADERIZER HFILE: include/parrot/resources.h */
+/* HEADERIZER HFILE: src/gc/gc_private.h */
 
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-static char * aligned_mem(ARGIN(const Buffer *buffer), ARGIN(char *mem))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_PURE_FUNCTION
-PARROT_WARN_UNUSED_RESULT
-static size_t aligned_size(ARGIN(const Buffer *buffer), size_t len)
-        __attribute__nonnull__(1);
-
-PARROT_CONST_FUNCTION
-PARROT_WARN_UNUSED_RESULT
-static size_t aligned_string_size(size_t len);
-
 static void alloc_new_block(PARROT_INTERP,
     size_t size,
     ARGMOD(Memory_Pool *pool),
@@ -67,44 +53,16 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-static void compact_pool(PARROT_INTERP, ARGMOD(Memory_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
 static void debug_print_buf(PARROT_INTERP, ARGIN(const PObj *b))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * mem_allocate(PARROT_INTERP,
-    size_t size,
-    ARGMOD(Memory_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*pool);
-
-static void merge_pools(
-    ARGMOD(Memory_Pool *dest),
-    ARGMOD(Memory_Pool *source))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*dest)
-        FUNC_MODIFIES(*source);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
 static Memory_Pool * new_memory_pool(
     size_t min_block,
     NULLOK(compact_f compact));
 
-#define ASSERT_ARGS_aligned_mem __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(buffer) \
-    || PARROT_ASSERT_ARG(mem)
-#define ASSERT_ARGS_aligned_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(buffer)
-#define ASSERT_ARGS_aligned_string_size __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_alloc_new_block __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pool) \
@@ -112,18 +70,9 @@
 #define ASSERT_ARGS_buffer_location __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_compact_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool)
 #define ASSERT_ARGS_debug_print_buf __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(b)
-#define ASSERT_ARGS_mem_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pool)
-#define ASSERT_ARGS_merge_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(dest) \
-    || PARROT_ASSERT_ARG(source)
 #define ASSERT_ARGS_new_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
@@ -191,8 +140,7 @@
 
 /*
 
-=item C<static void * mem_allocate(PARROT_INTERP, size_t size, Memory_Pool
-*pool)>
+=item C<void * mem_allocate(PARROT_INTERP, size_t size, Memory_Pool *pool)>
 
 Allocates memory for headers.
 
@@ -229,7 +177,7 @@
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void *
+void *
 mem_allocate(PARROT_INTERP, size_t size, ARGMOD(Memory_Pool *pool))
 {
     ASSERT_ARGS(mem_allocate)
@@ -249,7 +197,7 @@
          */
         if (!interp->arena_base->gc_mark_block_level
         &&   interp->arena_base->mem_allocs_since_last_collect) {
-            Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+            Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #if !PARROT_GC_IMS
             /* Compact the pool if allowed and worthwhile */
             if (pool->compact) {
@@ -353,7 +301,7 @@
 
 =over 4
 
-=item C<static void compact_pool(PARROT_INTERP, Memory_Pool *pool)>
+=item C<void compact_pool(PARROT_INTERP, Memory_Pool *pool)>
 
 Compact the string buffer pool. Does not perform a GC scan, or mark items
 as being alive in any way.
@@ -362,7 +310,7 @@
 
 */
 
-static void
+void
 compact_pool(PARROT_INTERP, ARGMOD(Memory_Pool *pool))
 {
     ASSERT_ARGS(compact_pool)
@@ -590,26 +538,7 @@
 
 /*
 
-=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<static size_t aligned_size(const Buffer *buffer, size_t len)>
+=item C<size_t aligned_size(const Buffer *buffer, size_t len)>
 
 Determines the size of Buffer C<buffer> which has nominal length C<len>.
 The actual size in RAM of the Buffer might be different because of
@@ -621,7 +550,7 @@
 
 PARROT_PURE_FUNCTION
 PARROT_WARN_UNUSED_RESULT
-static size_t
+size_t
 aligned_size(ARGIN(const Buffer *buffer), size_t len)
 {
     ASSERT_ARGS(aligned_size)
@@ -636,7 +565,7 @@
 
 /*
 
-=item C<static char * aligned_mem(const Buffer *buffer, char *mem)>
+=item C<char * aligned_mem(const Buffer *buffer, char *mem)>
 
 Returns a pointer to the aligned allocated storage for Buffer C<buffer>,
 which might not be the same as the pointer to C<buffeR> because of
@@ -648,7 +577,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-static char *
+char *
 aligned_mem(ARGIN(const Buffer *buffer), ARGIN(char *mem))
 {
     ASSERT_ARGS(aligned_mem)
@@ -665,7 +594,7 @@
 
 /*
 
-=item C<static size_t aligned_string_size(size_t len)>
+=item C<size_t aligned_string_size(size_t len)>
 
 Determines the size of a string of length C<len> in RAM, accounting for
 alignment.
@@ -677,7 +606,7 @@
 /* XXX Looks like we can lose buffer here */
 PARROT_CONST_FUNCTION
 PARROT_WARN_UNUSED_RESULT
-static size_t
+size_t
 aligned_string_size(size_t len)
 {
     ASSERT_ARGS(aligned_string_size)
@@ -688,185 +617,12 @@
 
 /*
 
-=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;
-}
-
-
-/*
-
 =back
 
 =head2 Parrot Re/Allocate Code
 
 =over 4
 
-=item C<void Parrot_reallocate(PARROT_INTERP, Buffer *buffer, size_t newsize)>
-
-Reallocate the Buffer's buffer memory to the given size. The
-allocated buffer will not shrink. If the buffer was allocated with
-L<Parrot_allocate_aligned> the new buffer will also be aligned. As with
-all reallocation, the new buffer might have moved and the additional
-memory is not cleared.
-
-=cut
-
-*/
-
-void
-Parrot_reallocate(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t newsize)
-{
-    ASSERT_ARGS(Parrot_reallocate)
-    size_t copysize;
-    char  *mem;
-    Memory_Pool * const pool = interp->arena_base->memory_pool;
-    size_t new_size, needed, old_size;
-
-    /*
-     * we don't shrink buffers
-     */
-    if (newsize <= PObj_buflen(buffer))
-        return;
-
-    /*
-     * same as below but barely used and tested - only 3 list related
-     * tests do use true reallocation
-     *
-     * list.c, which does _reallocate, has 2 reallocations
-     * normally, which play ping pong with buffers.
-     * The normal case is therefore always to allocate a new block
-     */
-    new_size = aligned_size(buffer, newsize);
-    old_size = aligned_size(buffer, PObj_buflen(buffer));
-    needed   = new_size - old_size;
-
-    if ((pool->top_block->free >= needed)
-    &&  (pool->top_block->top  == (char *)PObj_bufstart(buffer) + old_size)) {
-        pool->top_block->free -= needed;
-        pool->top_block->top  += needed;
-        PObj_buflen(buffer) = newsize;
-        return;
-    }
-
-    copysize = PObj_buflen(buffer);
-
-    if (!PObj_COW_TEST(buffer))
-        pool->guaranteed_reclaimable += copysize;
-
-    pool->possibly_reclaimable += copysize;
-    mem                         = (char *)mem_allocate(interp, new_size, pool);
-    mem                         = aligned_mem(buffer, mem);
-
-    /* We shouldn't ever have a 0 from size, but we do. If we can track down
-     * those bugs, this can be removed which would make things cheaper */
-    if (copysize)
-        memcpy(mem, PObj_bufstart(buffer), copysize);
-
-    PObj_bufstart(buffer) = mem;
-
-    if (PObj_is_COWable_TEST(buffer))
-        new_size -= sizeof (void *);
-
-    PObj_buflen(buffer) = new_size;
-}
-
-
-/*
-
-=item C<void Parrot_reallocate_string(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
-new buffer location, C<str-E<gt>bufused> is B<not> changed.
-
-=cut
-
-*/
-
-void
-Parrot_reallocate_string(PARROT_INTERP, ARGMOD(STRING *str), size_t newsize)
-{
-    ASSERT_ARGS(Parrot_reallocate_string)
-    size_t copysize;
-    char *mem, *oldmem;
-    size_t new_size, needed, old_size;
-
-    Memory_Pool * const pool =
-        PObj_constant_TEST(str)
-            ? interp->arena_base->constant_string_pool
-            : interp->arena_base->memory_pool;
-
-    /* if the requested size is smaller then buflen, we are done */
-    if (newsize <= PObj_buflen(str))
-        return;
-
-    /*
-     * first check, if we can reallocate:
-     * - if the passed strings buffer is the last string in the pool and
-     * - if there is enough size, we can just move the pool's top pointer
-     */
-    new_size = aligned_string_size(newsize);
-    old_size = aligned_string_size(PObj_buflen(str));
-    needed   = new_size - old_size;
-
-    if (pool->top_block->free >= needed
-    &&  pool->top_block->top  == (char *)PObj_bufstart(str) + old_size) {
-        pool->top_block->free -= needed;
-        pool->top_block->top  += needed;
-        PObj_buflen(str) = new_size - sizeof (void*);
-        return;
-    }
-
-    PARROT_ASSERT(str->bufused <= newsize);
-
-    /* only copy used memory, not total string buffer */
-    copysize = str->bufused;
-
-    if (!PObj_COW_TEST(str))
-        pool->guaranteed_reclaimable += PObj_buflen(str);
-
-    pool->possibly_reclaimable += PObj_buflen(str);
-
-    mem = (char *)mem_allocate(interp, new_size, pool);
-    mem += sizeof (void *);
-
-    /* copy mem from strstart, *not* bufstart */
-    oldmem             = str->strstart;
-    PObj_bufstart(str) = (void *)mem;
-    str->strstart      = mem;
-    PObj_buflen(str)   = new_size - sizeof (void*);
-
-    /* We shouldn't ever have a 0 from size, but we do. If we can track down
-     * those bugs, this can be removed which would make things cheaper */
-    if (copysize)
-        memcpy(mem, oldmem, copysize);
-}
-
-/*
 
 =item C<void Parrot_allocate(PARROT_INTERP, Buffer *buffer, size_t size)>
 
@@ -890,82 +646,6 @@
     PObj_buflen(buffer) = size;
 }
 
-
-/*
-
-=item C<void Parrot_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.
-
-=cut
-
-*/
-
-void
-Parrot_allocate_aligned(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
-{
-    ASSERT_ARGS(Parrot_allocate_aligned)
-    size_t new_size;
-    char *mem;
-
-    PObj_buflen(buffer) = 0;
-    PObj_bufstart(buffer) = NULL;
-    new_size = aligned_size(buffer, size);
-    mem = (char *)mem_allocate(interp, new_size,
-        interp->arena_base->memory_pool);
-    mem = aligned_mem(buffer, mem);
-    PObj_bufstart(buffer) = mem;
-    if (PObj_is_COWable_TEST(buffer))
-        new_size -= sizeof (void*);
-    PObj_buflen(buffer) = new_size;
-}
-
-/*
-
-=item C<void Parrot_allocate_string(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
-sets also C<< str->strstart >> to the new buffer location, C<< str->bufused >>
-is B<not> changed.
-
-=cut
-
-*/
-
-void
-Parrot_allocate_string(PARROT_INTERP, ARGOUT(STRING *str), size_t size)
-{
-    ASSERT_ARGS(Parrot_allocate_string)
-    size_t       new_size;
-    Memory_Pool *pool;
-    char        *mem;
-
-    PObj_buflen(str)   = 0;
-    PObj_bufstart(str) = NULL;
-
-    /* there's no sense in allocating zero memory, when the overhead of
-     * allocating a string is one pointer; this can fill the pools in an
-     * uncompactable way.  See RT #42320.
-     */
-    if (size == 0)
-        return;
-
-    pool     = PObj_constant_TEST(str)
-                ? interp->arena_base->constant_string_pool
-                : interp->arena_base->memory_pool;
-
-    new_size = aligned_string_size(size);
-    mem      = (char *)mem_allocate(interp, new_size, pool);
-    mem     += sizeof (void*);
-
-    PObj_bufstart(str) = str->strstart = mem;
-    PObj_buflen(str)   = new_size - sizeof (void*);
-}
-
 /*
 
 =item C<static Memory_Pool * new_memory_pool(size_t min_block, compact_f
@@ -1025,45 +705,10 @@
     alloc_new_block(interp, POOL_SIZE, arena_base->constant_string_pool, "init");
 }
 
-/*
-
-=item C<void Parrot_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
-blocks are freed, free the pools themselves.
-
-=cut
-
-*/
-
-void
-Parrot_destroy_memory_pools(PARROT_INTERP)
-{
-    ASSERT_ARGS(Parrot_destroy_memory_pools)
-    int i;
-
-    for (i = 0; i < 2; i++) {
-        Memory_Pool * const pool = i ?
-                interp->arena_base->constant_string_pool :
-                interp->arena_base->memory_pool;
-        Memory_Block *cur_block;
-
-        cur_block = pool->top_block;
-
-        while (cur_block) {
-            Memory_Block * const next_block = cur_block->prev;
-            mem_internal_free(cur_block);
-            cur_block = next_block;
-        }
-
-        mem_internal_free(pool);
-    }
-}
 
 /*
 
-=item C<static void merge_pools(Memory_Pool *dest, Memory_Pool *source)>
+=item C<void merge_pools(Memory_Pool *dest, Memory_Pool *source)>
 
 Merge two memory pools together. Do this by moving all memory blocks
 from the C<*source> pool into the C<*dest> pool. The C<source> pool
@@ -1073,7 +718,7 @@
 
 */
 
-static void
+void
 merge_pools(ARGMOD(Memory_Pool *dest), ARGMOD(Memory_Pool *source))
 {
     ASSERT_ARGS(merge_pools)
@@ -1108,35 +753,65 @@
 
 /*
 
-=item C<void Parrot_merge_memory_pools(Interp *dest_interp, Interp
-*source_interp)>
+=item C<void Parrot_gc_profile_start(PARROT_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>.
+Records the start time of a GC mark run when profiling is enabled.
 
 =cut
 
 */
 
 void
-Parrot_merge_memory_pools(ARGIN(Interp *dest_interp), ARGIN(Interp *source_interp))
+Parrot_gc_profile_start(PARROT_INTERP)
 {
-    ASSERT_ARGS(Parrot_merge_memory_pools)
-    merge_pools(dest_interp->arena_base->constant_string_pool,
-                source_interp->arena_base->constant_string_pool);
+    ASSERT_ARGS(Parrot_gc_profile_start)
+    if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG))
+        interp->profile->gc_time = Parrot_floatval_time();
+}
+
+/*
+
+=item C<void Parrot_gc_profile_end(PARROT_INTERP, int what)>
+
+Records the end time of the GC mark run part C<what> run when profiling is
+enabled. Also record start time of next part.
+
+=cut
 
-    merge_pools(dest_interp->arena_base->memory_pool,
-                source_interp->arena_base->memory_pool);
+*/
+
+void
+Parrot_gc_profile_end(PARROT_INTERP, int what)
+{
+    ASSERT_ARGS(Parrot_gc_profile_end)
+    if (Interp_flags_TEST(interp, PARROT_PROFILE_FLAG)) {
+        RunProfile * const profile = interp->profile;
+        const FLOATVAL     now     = Parrot_floatval_time();
+
+        profile->data[what].numcalls++;
+        profile->data[what].time += now - profile->gc_time;
+
+        /*
+         * we've recorded the time of a GC piece from
+         * gc_time until now, so add this to the start of the
+         * currently executing opcode, which hasn't run this
+         * interval.
+         */
+        profile->starttime += now - profile->gc_time;
+
+        /* prepare start for next step */
+        profile->gc_time    = now;
+    }
 }
 
+
 /*
 
 =back
 
 =head1 SEE ALSO
 
-F<include/parrot/resources.h>, F<src/gc/memory.c>.
+F<src/gc/memory.c>.
 
 =head1 HISTORY
 

Modified: trunk/src/gc/system.c
==============================================================================
--- trunk/src/gc/system.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/gc/system.c	Sat May  9 20:02:23 2009	(r38654)
@@ -293,16 +293,16 @@
              * free headers... */
             if (pmc_min <= ptr && ptr < pmc_max &&
                     is_pmc_ptr(interp, (void *)ptr)) {
-                /* ...so ensure that pobject_lives checks PObj_on_free_list_FLAG
+                /* ...so ensure that Parrot_gc_mark_PObj_alive checks PObj_on_free_list_FLAG
                  * before adding it to the next_for_GC list, to have
                  * vtable->mark() called. */
-                pobject_lives(interp, (PObj *)ptr);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)ptr);
             }
             else if (buffer_min <= ptr && ptr < buffer_max &&
                     is_buffer_ptr(interp, (void *)ptr)) {
-                /* ...and since pobject_lives doesn't care about bufstart, it
+                /* ...and since Parrot_gc_mark_PObj_alive doesn't care about bufstart, it
                  * doesn't really matter if it sets a flag */
-                pobject_lives(interp, (PObj *)ptr);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)ptr);
             }
         }
     }

Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/hash.c	Sat May  9 20:02:23 2009	(r38654)
@@ -438,7 +438,7 @@
                     hash, (int)entries);
 
             PARROT_ASSERT(bucket->key);
-            pobject_lives(interp, (PObj *)bucket->key);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)bucket->key);
 
             bucket = bucket->next;
         }
@@ -474,7 +474,7 @@
                         hash, (int)entries);
 
             PARROT_ASSERT(bucket->value);
-            pobject_lives(interp, (PObj *)bucket->value);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)bucket->value);
 
             bucket = bucket->next;
         }
@@ -510,10 +510,10 @@
                         hash, (int)entries);
 
             PARROT_ASSERT(bucket->key);
-            pobject_lives(interp, (PObj *)bucket->key);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)bucket->key);
 
             PARROT_ASSERT(bucket->value);
-            pobject_lives(interp, (PObj *)bucket->value);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)bucket->value);
 
             bucket = bucket->next;
         }

Modified: trunk/src/interp/inter_cb.c
==============================================================================
--- trunk/src/interp/inter_cb.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/interp/inter_cb.c	Sat May  9 20:02:23 2009	(r38654)
@@ -186,7 +186,7 @@
             continue;
         interp = interpreter_array[i];
         if (interp)
-            if (contained_in_pool(interp->arena_base->pmc_pool, user_data))
+            if (Parrot_gc_ptr_is_pmc(interp, user_data))
                 break;
     }
     UNLOCK(interpreter_array_mutex);

Modified: trunk/src/interp/inter_create.c
==============================================================================
--- trunk/src/interp/inter_create.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/interp/inter_create.c	Sat May  9 20:02:23 2009	(r38654)
@@ -151,7 +151,7 @@
     interp->recursion_limit = RECURSION_LIMIT;
 
     /* Must initialize flags here so the GC_DEBUG stuff is available before
-     * mem_setup_allocator() is called. */
+     * Parrot_gc_initialize() is called. */
     interp->flags = flags;
 
     /* PANIC will fail until this is done */
@@ -168,7 +168,7 @@
     }
 
     /* Set up the memory allocation system */
-    mem_setup_allocator(interp, (void*)&stacktop);
+    Parrot_gc_initialize(interp, (void*)&stacktop);
     Parrot_block_GC_mark(interp);
     Parrot_block_GC_sweep(interp);
 
@@ -334,8 +334,7 @@
      * Need to turn off GC blocking, else things stay alive and IO
      * handles aren't closed
      */
-    interp->arena_base->gc_mark_block_level  = 0;
-    interp->arena_base->gc_sweep_block_level = 0;
+    Parrot_gc_completely_unblock(interp);
 
     if (Interp_trace_TEST(interp, ~0)) {
         Parrot_io_eprintf(interp, "FileHandle objects (like stdout and stderr)"
@@ -348,7 +347,7 @@
     if (interp->thread_data)
         interp->thread_data->state |= THREAD_STATE_SUSPENDED_GC;
 
-    Parrot_do_gc_run(interp, GC_finish_FLAG);
+    Parrot_gc_mark_and_sweep(interp, GC_finish_FLAG);
 
     /*
      * that doesn't get rid of constant PMCs like these in vtable->data
@@ -384,12 +383,11 @@
     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_header_pools(interp->parent_interpreter, interp);
     }
 
-    if (interp->arena_base->finalize_gc_system)
-        interp->arena_base->finalize_gc_system(interp);
+    Parrot_gc_finalize(interp);
 
     /* MMD cache */
     Parrot_mmd_cache_destroy(interp, interp->op_mmd_cache);
@@ -398,10 +396,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: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/interp/inter_misc.c	Sat May  9 20:02:23 2009	(r38654)
@@ -211,7 +211,6 @@
     ASSERT_ARGS(interpinfo)
     INTVAL ret = 0;
     int j;
-    Arenas *arena_base = interp->arena_base;
 
     switch (what) {
         case TOTAL_MEM_ALLOC:
@@ -220,57 +219,43 @@
             interp->memory_allocated = mallinfo().uordblks;
 #  endif
 #endif
-            ret = arena_base->memory_allocated;
+            ret = Parrot_gc_total_memory_allocated(interp);
             break;
         case GC_MARK_RUNS:
-            ret = arena_base->gc_mark_runs;
+            ret = Parrot_gc_count_mark_runs(interp);
             break;
         case GC_LAZY_MARK_RUNS:
-            ret = arena_base->gc_lazy_mark_runs;
+            ret = Parrot_gc_count_lazy_mark_runs(interp);
             break;
         case GC_COLLECT_RUNS:
-            ret = arena_base->gc_collect_runs;
+            ret = Parrot_gc_count_collect_runs(interp);
             break;
         case ACTIVE_PMCS:
-            ret = arena_base->pmc_pool->total_objects -
-                arena_base->pmc_pool->num_free_objects;
+            ret = Parrot_gc_active_pmcs(interp);
             break;
         case ACTIVE_BUFFERS:
-            ret = 0;
-            for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
-                Small_Object_Pool * const header_pool =
-                    arena_base->sized_header_pools[j];
-                if (header_pool)
-                    ret += header_pool->total_objects -
-                        header_pool->num_free_objects;
-            }
+            ret = Parrot_gc_active_sized_buffers(interp);
             break;
         case TOTAL_PMCS:
-            ret = arena_base->pmc_pool->total_objects;
+            ret = Parrot_gc_total_pmcs(interp);
             break;
         case TOTAL_BUFFERS:
-            ret = 0;
-            for (j = 0; j < (INTVAL)arena_base->num_sized; j++) {
-                Small_Object_Pool * const header_pool =
-                    arena_base->sized_header_pools[j];
-                if (header_pool)
-                    ret += header_pool->total_objects;
-            }
+            ret = Parrot_gc_total_sized_buffers(interp);
             break;
         case HEADER_ALLOCS_SINCE_COLLECT:
-            ret = arena_base->header_allocs_since_last_collect;
+            ret = Parrot_gc_headers_alloc_since_last_collect(interp);
             break;
         case MEM_ALLOCS_SINCE_COLLECT:
-            ret = arena_base->mem_allocs_since_last_collect;
+            ret = Parrot_gc_mem_alloc_since_last_collect(interp);
             break;
         case TOTAL_COPIED:
-            ret = arena_base->memory_collected;
+            ret = Parrot_gc_total_copied(interp);
             break;
         case IMPATIENT_PMCS:
-            ret = arena_base->num_early_gc_PMCs;
+            ret = Parrot_gc_impatient_pmcs(interp);
             break;
         case EXTENDED_PMCS:
-            ret = arena_base->num_extended_PMCs;
+            ret = Parrot_gc_extended_pmcs(interp);
             break;
         case CURRENT_RUNCORE:
             ret = interp->run_core;

Modified: trunk/src/io/buffer.c
==============================================================================
--- trunk/src/io/buffer.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/io/buffer.c	Sat May  9 20:02:23 2009	(r38654)
@@ -299,7 +299,7 @@
         return Parrot_io_readline_buffer(interp, filehandle, buf);
 
     if (*buf == NULL) {
-        *buf = new_string_header(interp, 0);
+        *buf = Parrot_gc_new_string_header(interp, 0);
         (*buf)->bufused = len = 2048;
     }
 
@@ -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;
 
@@ -478,7 +478,7 @@
     STRING *s;
 
     if (*buf == NULL) {
-        *buf = new_string_header(interp, 0);
+        *buf = Parrot_gc_new_string_header(interp, 0);
     }
     s = *buf;
     s->strlen = 0;
@@ -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: trunk/src/io/core.c
==============================================================================
--- trunk/src/io/core.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/io/core.c	Sat May  9 20:02:23 2009	(r38654)
@@ -126,7 +126,7 @@
      */
     for (i = 0; i < 3; i++) {
         if (table[i]) {
-            pobject_lives(interp, (PObj *)table[i]);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)table[i]);
         }
     }
 }

Modified: trunk/src/io/filehandle.c
==============================================================================
--- trunk/src/io/filehandle.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/io/filehandle.c	Sat May  9 20:02:23 2009	(r38654)
@@ -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: trunk/src/io/utf8.c
==============================================================================
--- trunk/src/io/utf8.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/io/utf8.c	Sat May  9 20:02:23 2009	(r38654)
@@ -119,7 +119,7 @@
         return Parrot_io_write_buffer(interp, filehandle, s);
 
     dest = Parrot_utf8_encoding_ptr->to_encoding(interp, s,
-            new_string_header(interp, 0));
+            Parrot_gc_new_string_header(interp, 0));
     return Parrot_io_write_buffer(interp, filehandle, dest);
 }
 

Modified: trunk/src/key.c
==============================================================================
--- trunk/src/key.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/key.c	Sat May  9 20:02:23 2009	(r38654)
@@ -612,7 +612,7 @@
 
     if (flags == KEY_string_FLAG) {
         GETATTR_Key_str_key(interp, key, str_key);
-        pobject_lives(interp, (PObj *)str_key);
+        Parrot_gc_mark_PObj_alive(interp, (PObj *)str_key);
     }
 
     /*
@@ -626,7 +626,7 @@
     /* if iteration hasn't started, above flag isn't set yet */
     GETATTR_Key_next_key(interp, key, next_key);
     if (next_key && (void *)next_key != (void *)INITBucketIndex)
-        pobject_lives(interp, (PObj *)next_key);
+        Parrot_gc_mark_PObj_alive(interp, (PObj *)next_key);
 
 }
 

Modified: trunk/src/list.c
==============================================================================
--- trunk/src/list.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/list.c	Sat May  9 20:02:23 2009	(r38654)
@@ -361,13 +361,13 @@
 
     Parrot_block_GC_mark(interp);
     /*Parrot_block_GC_sweep(interp); - why */
-    chunk = (List_chunk *)new_bufferlike_header(interp, sizeof (*chunk));
+    chunk = (List_chunk *)Parrot_gc_new_bufferlike_header(interp, sizeof (*chunk));
     chunk->items = items;
     chunk->n_chunks = 0;
     chunk->n_items  = 0;
     chunk->next     = NULL;
     chunk->prev     = NULL;
-    Parrot_allocate_aligned(interp, (Buffer *)chunk, size);
+    Parrot_gc_allocate_buffer_storage_aligned(interp, (Buffer *)chunk, size);
     memset(PObj_bufstart((Buffer*)chunk), 0, size);
 
     /* see also src/hash.c */
@@ -489,7 +489,7 @@
              * but: if bigger, split them in a next pass
              * TODO test the logic that solves the above problem */
             if (prev->items + chunk->items > MAX_ITEMS) {
-                Parrot_reallocate(interp, (Buffer *)prev,
+                Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev,
                         MAX_ITEMS * list->item_size);
                 if (list->container) {
                     GC_WRITE_BARRIER(interp, list->container, 0, prev);
@@ -509,7 +509,7 @@
                 prev->items = MAX_ITEMS;
             }
             else {
-                Parrot_reallocate(interp, (Buffer *)prev,
+                Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev,
                         (prev->items + chunk->items) * list->item_size);
                 if (list->container) {
                     GC_WRITE_BARRIER(interp, list->container, 0, prev);
@@ -594,18 +594,18 @@
 
     /* allocate a new chunk_list buffer, if old one has moved or is too small */
     len = list->n_chunks;
-    if (list->collect_runs != interp->arena_base->gc_collect_runs ||
+    if (list->collect_runs != Parrot_gc_count_collect_runs(interp) ||
             len > chunk_list_size(list)) {
         /* round up to reasonable size */
         len = 1 << (ld(len) + 1);
         if (len < 4)
             len = 4;
-        Parrot_reallocate(interp, (Buffer *)list,
+        Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)list,
                 len * sizeof (List_chunk *));
         if (list->container) {
             GC_WRITE_BARRIER(interp, list->container, 0, list);
         }
-        list->collect_runs = interp->arena_base->gc_collect_runs;
+        list->collect_runs = Parrot_gc_count_collect_runs(interp);
     }
 
     /* reset type, actual state of chunks will show, what we really have */
@@ -937,7 +937,7 @@
     UINTVAL i;
 
 #ifndef GC_IS_MALLOC
-    if (list->collect_runs != interp->arena_base->gc_collect_runs)
+    if (list->collect_runs != Parrot_gc_count_collect_runs(interp))
         rebuild_chunk_list(interp, list);
 #endif
 #ifdef SLOW_AND_BORING
@@ -1057,7 +1057,7 @@
     /* allocate space at idx */
     if (chunk->items <= MAX_ITEMS) {
         /* it fits, just allocate */
-        Parrot_reallocate(interp, (Buffer *)chunk,
+        Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)chunk,
                 chunk->items * list->item_size);
         if (list->container) {
             GC_WRITE_BARRIER(interp, list->container, 0, chunk);
@@ -1074,7 +1074,7 @@
         const INTVAL n1 = chunk->items - n2 - n3;
 
         chunk->items = n2;
-        Parrot_reallocate(interp, (Buffer *)chunk,
+        Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)chunk,
                 chunk->items * list->item_size);
         if (list->container) {
             GC_WRITE_BARRIER(interp, list->container, 0, chunk);
@@ -1274,7 +1274,7 @@
 list_new(PARROT_INTERP, PARROT_DATA_TYPE type)
 {
     ASSERT_ARGS(list_new)
-    List * const list = (List *)new_bufferlike_header(interp, sizeof (*list));
+    List * const list = (List *)Parrot_gc_new_bufferlike_header(interp, sizeof (*list));
 
     list->item_type = type;
     switch (type) {
@@ -1540,7 +1540,7 @@
     List_chunk *chunk;
 
     for (chunk = list->first; chunk; chunk = chunk->next) {
-        pobject_lives(interp, (PObj *)chunk);
+        Parrot_gc_mark_PObj_alive(interp, (PObj *)chunk);
         if (list->item_type == enum_type_PMC ||
                 list->item_type == enum_type_STRING) {
             if (!(chunk->flags & sparse)) {
@@ -1549,14 +1549,14 @@
 
                 for (i = 0; i < chunk->items; i++, ++p) {
                     if (*p)
-                        pobject_lives(interp, *p);
+                        Parrot_gc_mark_PObj_alive(interp, *p);
                 }
             }
 
         }
     }
 
-    pobject_lives(interp, (PObj *)list);
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)list);
 }
 
 /*

Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/oo.c	Sat May  9 20:02:23 2009	(r38654)
@@ -624,7 +624,7 @@
         for (entry = 0; entry < TBL_SIZE; ++entry) {
             Meth_cache_entry *e = mc->idx[type][entry];
             while (e) {
-                pobject_lives(interp, (PObj *)e->pmc);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)e->pmc);
                 e = e->next;
             }
         }

Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/ops/core.ops	Sat May  9 20:02:23 2009	(r38654)
@@ -1245,10 +1245,10 @@
 
 op sweep(inconst INT) {
     if ($1)
-        Parrot_do_gc_run(interp, 0);
+        Parrot_gc_mark_and_sweep(interp, 0);
     else
-        if (interp->arena_base->num_early_gc_PMCs)
-            Parrot_do_gc_run(interp, GC_lazy_FLAG);
+        if (Parrot_gc_impatient_pmcs(interp))
+            Parrot_gc_mark_and_sweep(interp, GC_lazy_FLAG);
 }
 
 =item B<collect>()
@@ -1258,7 +1258,7 @@
 =cut
 
 op collect() {
-    Parrot_go_collect(interp);
+    Parrot_gc_compact_memory_pool(interp);
 }
 
 =item B<sweepoff>()
@@ -1309,8 +1309,7 @@
 =cut
 
 op needs_destroy(invar PMC) {
-     PObj_needs_early_gc_SET($1);
-     ++interp->arena_base->num_early_gc_PMCs;
+     Parrot_gc_pmc_needs_early_collection(interp, $1);
 }
 
 =back

Modified: trunk/src/ops/string.ops
==============================================================================
--- trunk/src/ops/string.ops	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/ops/string.ops	Sat May  9 20:02:23 2009	(r38654)
@@ -551,7 +551,7 @@
 }
 
 op trans_charset(out STR, in STR, in INT) {
-    STRING *dest = new_string_header(interp, 0);
+    STRING *dest = Parrot_gc_new_string_header(interp, 0);
     $1 = Parrot_str_change_charset(interp, $2, $3, dest);
 }
 
@@ -607,7 +607,7 @@
 }
 
 op trans_encoding(out STR, in STR, in INT) {
-    STRING * const dest = new_string_header(interp, 0);
+    STRING * const dest = Parrot_gc_new_string_header(interp, 0);
     $1 = Parrot_str_change_encoding(interp, $2, $3, dest);
 }
 

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/packfile.c	Sat May  9 20:02:23 2009	(r38654)
@@ -802,7 +802,7 @@
         if (constants[i]->type == PFC_PMC) {
             PMC * const pmc = constants[i]->u.key;
             if (pmc)
-                pobject_lives(interp, (PObj *)pmc);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)pmc);
         }
     }
 }

Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc.c	Sat May  9 20:02:23 2009	(r38654)
@@ -41,15 +41,6 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
-static void pmc_free_to_pool(PARROT_INTERP,
-    ARGMOD(PMC *pmc),
-    ARGMOD(Small_Object_Pool *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*pmc)
-        FUNC_MODIFIES(*pool);
-
 #define ASSERT_ARGS_create_class_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_get_new_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -57,10 +48,6 @@
 #define ASSERT_ARGS_pmc_free __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pmc)
-#define ASSERT_ARGS_pmc_free_to_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(pmc) \
-    || PARROT_ASSERT_ARG(pool)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
 
@@ -196,7 +183,7 @@
     if (new_vtable->flags & VTABLE_PMC_NEEDS_EXT) {
         /* If we need an ext area, go allocate one */
         if (!has_ext)
-            add_pmc_ext(interp, pmc);
+            Parrot_gc_add_pmc_ext(interp, pmc);
 
         new_flags = PObj_is_PMC_EXT_FLAG;
     }
@@ -265,7 +252,7 @@
 
         /* LOCK */
         if (!pmc) {
-            pmc            = new_pmc_header(interp, PObj_constant_FLAG);
+            pmc = Parrot_gc_new_pmc_header(interp, PObj_constant_FLAG);
             PARROT_ASSERT(pmc);
 
             pmc->vtable    = vtable;
@@ -303,7 +290,7 @@
             flags |= PObj_is_PMC_shared_FLAG;
     }
 
-    pmc            = new_pmc_header(interp, flags);
+    pmc            = Parrot_gc_new_pmc_header(interp, flags);
     pmc->vtable    = vtable;
 
 #if GC_VERBOSE
@@ -474,31 +461,6 @@
 
 /*
 
-=item C<static void pmc_free_to_pool(PARROT_INTERP, PMC *pmc, Small_Object_Pool
-*pool)>
-
-=cut
-
-*/
-
-static void
-pmc_free_to_pool(PARROT_INTERP, ARGMOD(PMC *pmc),
-    ARGMOD(Small_Object_Pool *pool))
-{
-    ASSERT_ARGS(pmc_free_to_pool)
-    if (PObj_active_destroy_TEST(pmc))
-        VTABLE_destroy(interp, pmc);
-
-    if (PObj_is_PMC_EXT_TEST(pmc))
-        Parrot_gc_free_pmc_ext(interp, pmc);
-
-    PObj_flags_SETTO((PObj *)pmc, PObj_on_free_list_FLAG);
-    pool->add_free_object(interp, pool, (PObj *)pmc);
-    pool->num_free_objects++;
-}
-
-/*
-
 =item C<void temporary_pmc_free(PARROT_INTERP, PMC *pmc)>
 
 Frees a new temporary PMC created by C<temporary_pmc_new()>.  Do not call this
@@ -514,8 +476,7 @@
 temporary_pmc_free(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
     ASSERT_ARGS(temporary_pmc_free)
-    Small_Object_Pool *pool = interp->arena_base->constant_pmc_pool;
-    pmc_free_to_pool(interp, pmc, pool);
+    Parrot_gc_free_pmc_header(interp, pmc);
 }
 
 /*
@@ -530,8 +491,7 @@
 pmc_free(PARROT_INTERP, ARGMOD(PMC *pmc))
 {
     ASSERT_ARGS(pmc_free)
-    Small_Object_Pool *pool = interp->arena_base->pmc_pool;
-    pmc_free_to_pool(interp, pmc, pool);
+    Parrot_gc_free_pmc_header(interp, pmc);
 
 }
 

Modified: trunk/src/pmc/array.pmc
==============================================================================
--- trunk/src/pmc/array.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/array.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -119,15 +119,7 @@
 */
 
     void class_init() {
-        /* class_init_code; called for side effects */
-        Small_Object_Pool *List_chunks =
-            get_bufferlike_pool(INTERP, sizeof (List_chunk));
-        Small_Object_Pool *Lists       =
-            get_bufferlike_pool(INTERP, sizeof (List));
-
-        /* XXX until there's a function to allocate a pool in an arena */
-        UNUSED(List_chunks);
-        UNUSED(Lists);
+
     }
 
 /*

Modified: trunk/src/pmc/callsignature.pmc
==============================================================================
--- trunk/src/pmc/callsignature.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/callsignature.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -191,15 +191,15 @@
         if (attrs) {
 
             if (attrs->array)
-                pobject_lives(interp, (PObj*)attrs->array);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->array);
             if (attrs->hash)
-                pobject_lives(interp, (PObj*)attrs->hash);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->hash);
             if (attrs->returns)
-                pobject_lives(interp, (PObj*)attrs->returns);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->returns);
             if (attrs->type_tuple)
-                pobject_lives(interp, (PObj*)attrs->type_tuple);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->type_tuple);
             if (attrs->short_sig)
-                pobject_lives(interp, (PObj*)attrs->short_sig);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)attrs->short_sig);
         }
 
         if (!data)
@@ -207,7 +207,7 @@
 
         for (i = attrs->data_size - 1; i >= 0; --i)
             if (data[i])
-                pobject_lives(interp, (PObj *)data[i]);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)data[i]);
     }
 
 

Modified: trunk/src/pmc/capture.pmc
==============================================================================
--- trunk/src/pmc/capture.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/capture.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -525,7 +525,7 @@
 
         for (i = PARROT_CAPTURE(SELF)->data_size - 1; i >= 0; --i)
             if (data[i])
-                pobject_lives(interp, (PObj *)data[i]);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)data[i]);
     }
 
 /*

Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/class.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -596,31 +596,31 @@
     VTABLE void mark() {
         Parrot_Class_attributes * const _class = PARROT_CLASS(SELF);
         if (_class->name)
-            pobject_lives(interp, (PObj *)_class->name);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->name);
         if (_class->fullname)
-            pobject_lives(interp, (PObj *)_class->fullname);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->fullname);
         if (_class->_namespace)
-            pobject_lives(interp, (PObj *)_class->_namespace);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->_namespace);
         if (_class->parents)
-            pobject_lives(interp, (PObj *)_class->parents);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->parents);
         if (_class->all_parents)
-            pobject_lives(interp, (PObj *)_class->all_parents);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->all_parents);
         if (_class->roles)
-            pobject_lives(interp, (PObj *)_class->roles);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->roles);
         if (_class->methods)
-            pobject_lives(interp, (PObj *)_class->methods);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->methods);
         if (_class->vtable_overrides)
-            pobject_lives(interp, (PObj *)_class->vtable_overrides);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->vtable_overrides);
         if (_class->parent_overrides)
-            pobject_lives(interp, (PObj *)_class->parent_overrides);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->parent_overrides);
         if (_class->attrib_metadata)
-            pobject_lives(interp, (PObj *)_class->attrib_metadata);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->attrib_metadata);
         if (_class->attrib_index)
-            pobject_lives(interp, (PObj *)_class->attrib_index);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->attrib_index);
         if (_class->attrib_cache)
-            pobject_lives(interp, (PObj *)_class->attrib_cache);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->attrib_cache);
         if (_class->resolve_method)
-            pobject_lives(interp, (PObj *)_class->resolve_method);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_class->resolve_method);
     }
 
 

Modified: trunk/src/pmc/cpointer.pmc
==============================================================================
--- trunk/src/pmc/cpointer.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/cpointer.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -88,18 +88,18 @@
         Parrot_CPointer_attributes * const data = PARROT_CPOINTER(SELF);
 
         if (data->sig)
-            pobject_lives(interp, (PObj *)data->sig);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data->sig);
 
         if (data->pointer) {
             if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "P"))) {
                 PMC ** const pmc_pointer = (PMC **) data->pointer;
                 PARROT_ASSERT(*pmc_pointer);
-                pobject_lives(interp, (PObj *) *pmc_pointer);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *) *pmc_pointer);
             }
             else if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "S"))) {
                 STRING ** const str_pointer = (STRING **) data->pointer;
                 PARROT_ASSERT(*str_pointer);
-                pobject_lives(interp, (PObj *) *str_pointer);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *) *str_pointer);
             }
         }
     }

Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/default.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -231,7 +231,7 @@
     PMC *prop;
 
     if (!self->pmc_ext)
-        add_pmc_ext(interp, self);
+        Parrot_gc_add_pmc_ext(interp, self);
 
     PMC_metadata(self) = prop = pmc_new(interp, enum_class_Hash);
     GC_WRITE_BARRIER(interp, self, NULL, prop);
@@ -436,7 +436,7 @@
 
     VTABLE PMC *getprops() {
         if (!SELF->pmc_ext)
-            add_pmc_ext(INTERP, SELF);
+            Parrot_gc_add_pmc_ext(INTERP, SELF);
 
         if (!PMC_metadata(SELF)) {
             if (has_pending_std_props(SELF))
@@ -1109,7 +1109,7 @@
         /* default - initialize the PMC */
         if (info->extra_flags == EXTRA_IS_PROP_HASH) {
             if (!SELF->pmc_ext)
-                add_pmc_ext(INTERP, SELF);
+                Parrot_gc_add_pmc_ext(INTERP, SELF);
 
             info->thaw_ptr  = &PMC_metadata(SELF);
             info->container = SELF;

Modified: trunk/src/pmc/eval.pmc
==============================================================================
--- trunk/src/pmc/eval.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/eval.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -121,7 +121,7 @@
             PMC      *sub = ct->constants[ci]->u.key;
 
             if (!PMC_IS_NULL(sub))
-                pobject_lives(interp, (PObj *)sub);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)sub);
         }
     }
 }

Modified: trunk/src/pmc/eventhandler.pmc
==============================================================================
--- trunk/src/pmc/eventhandler.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/eventhandler.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -133,13 +133,13 @@
 
         if (e) {
             if (e->type)
-                pobject_lives(INTERP, (PObj *)e->type);
+                Parrot_gc_mark_PObj_alive(INTERP, (PObj *)e->type);
 
             if (! PMC_IS_NULL(e->interp))
-                pobject_lives(INTERP, (PObj *)e->interp);
+                Parrot_gc_mark_PObj_alive(INTERP, (PObj *)e->interp);
 
             if (! PMC_IS_NULL(e->code))
-                pobject_lives(INTERP, (PObj *)e->code);
+                Parrot_gc_mark_PObj_alive(INTERP, (PObj *)e->code);
         }
     }
 

Modified: trunk/src/pmc/exception.pmc
==============================================================================
--- trunk/src/pmc/exception.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/exception.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -152,15 +152,15 @@
     VTABLE void mark() {
         Parrot_Exception_attributes * const core_struct = PARROT_EXCEPTION(SELF);
         if (core_struct->message)
-            pobject_lives(interp, (PObj *)core_struct->message);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->message);
         if (core_struct->payload)
-            pobject_lives(interp, (PObj *)core_struct->payload);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->payload);
         if (core_struct->resume)
-            pobject_lives(interp, (PObj *)core_struct->resume);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->resume);
         if (core_struct->backtrace)
-            pobject_lives(interp, (PObj *)core_struct->backtrace);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->backtrace);
         if (core_struct->handler_iter)
-            pobject_lives(interp, (PObj *)core_struct->handler_iter);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handler_iter);
     }
 
 /*

Modified: trunk/src/pmc/exceptionhandler.pmc
==============================================================================
--- trunk/src/pmc/exceptionhandler.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/exceptionhandler.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -74,9 +74,9 @@
         Parrot_ExceptionHandler_attributes * const core_struct =
             PARROT_EXCEPTIONHANDLER(SELF);
         if (core_struct->handled_types)
-            pobject_lives(interp, (PObj *)core_struct->handled_types);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types);
         if (core_struct->handled_types_except)
-            pobject_lives(interp, (PObj *)core_struct->handled_types_except);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types_except);
     }
 
     VTABLE PMC *clone() {

Modified: trunk/src/pmc/exporter.pmc
==============================================================================
--- trunk/src/pmc/exporter.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/exporter.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -153,11 +153,11 @@
         Parrot_Exporter_attributes *exp = PARROT_EXPORTER(SELF);
 
         if (exp->ns_src)
-            pobject_lives(interp, (PObj *)exp->ns_src);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)exp->ns_src);
         if (exp->ns_dest)
-            pobject_lives(interp, (PObj *)exp->ns_dest);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)exp->ns_dest);
         if (exp->globals)
-            pobject_lives(interp, (PObj *)exp->globals);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)exp->globals);
     }
 
 

Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/filehandle.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -124,11 +124,11 @@
     VTABLE void mark() {
         Parrot_FileHandle_attributes * const data_struct = PARROT_FILEHANDLE(SELF);
         if (data_struct->mode)
-            pobject_lives(interp, (PObj *)data_struct->mode);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->mode);
         if (data_struct->filename)
-            pobject_lives(interp, (PObj *)data_struct->filename);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->filename);
         if (data_struct->encoding)
-            pobject_lives(interp, (PObj *)data_struct->encoding);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->encoding);
     }
 
 /*
@@ -509,7 +509,7 @@
 #if ! DISABLE_GC_DEBUG
         /* trigger GC for debug - but not during tests */
         if (0 && GC_DEBUG(interp))
-            Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+            Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #endif
 
         if (Parrot_io_is_encoding(interp, SELF, CONST_STRING(interp, "utf8")))

Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/fixedpmcarray.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -800,7 +800,7 @@
 
         for (i = PMC_size(SELF) - 1; i >= 0; --i)
             if (data[i])
-                pobject_lives(interp, (PObj *)data[i]);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)data[i]);
     }
 
 

Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/fixedstringarray.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -129,7 +129,7 @@
 
             for (i = 0; i < size; i++) {
                 if (str_array[i])
-                    pobject_lives(INTERP, (PObj *) str_array[i]);
+                    Parrot_gc_mark_PObj_alive(INTERP, (PObj *) str_array[i]);
             }
         }
     }

Modified: trunk/src/pmc/iterator.pmc
==============================================================================
--- trunk/src/pmc/iterator.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/iterator.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -145,11 +145,11 @@
         PMC *key;
         GET_ATTR_key(INTERP, SELF, key);
         if (key)
-             pobject_lives(INTERP, (PObj *)key);
+             Parrot_gc_mark_PObj_alive(INTERP, (PObj *)key);
 
         /* the aggregate */
         if (SELF.get_pmc() != PMCNULL)
-             pobject_lives(INTERP, (PObj *)SELF.get_pmc());
+             Parrot_gc_mark_PObj_alive(INTERP, (PObj *)SELF.get_pmc());
     }
 
 /*

Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/namespace.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -167,15 +167,15 @@
         Parrot_NameSpace_attributes * const nsinfo = PARROT_NAMESPACE(SELF);
         SUPER();
         if (nsinfo->parent)
-            pobject_lives(INTERP, (PObj *)nsinfo->parent);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)nsinfo->parent);
         if (nsinfo->name)
-            pobject_lives(INTERP, (PObj *)nsinfo->name);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)nsinfo->name);
         if (nsinfo->_class)
-            pobject_lives(INTERP, (PObj *)nsinfo->_class);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)nsinfo->_class);
         if (nsinfo->vtable)
-            pobject_lives(INTERP, (PObj *)nsinfo->vtable);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)nsinfo->vtable);
         if (nsinfo->methods)
-            pobject_lives(INTERP, (PObj *)nsinfo->methods);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)nsinfo->methods);
     }
 
 /*

Modified: trunk/src/pmc/nci.pmc
==============================================================================
--- trunk/src/pmc/nci.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/nci.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -210,9 +210,9 @@
             Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
 
             if (nci_info->signature)
-                pobject_lives(interp, (PObj*)nci_info->signature);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->signature);
             if (nci_info->pcc_params_signature)
-                pobject_lives(interp, (PObj*)nci_info->pcc_params_signature);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)nci_info->pcc_params_signature);
         }
     }
 

Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/object.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -189,9 +189,9 @@
             Parrot_Object_attributes * const obj = PARROT_OBJECT(SELF);
 
             if (obj->_class)
-                pobject_lives(interp, (PObj*)obj->_class);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)obj->_class);
             if (obj->attrib_store)
-                pobject_lives(interp, (PObj*)obj->attrib_store);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)obj->attrib_store);
         }
     }
 
@@ -812,7 +812,7 @@
         VTABLE_set_integer_native(INTERP, _true, 1);
         VTABLE_setprop(INTERP, ret, CONST_STRING(interp, "_ro"), _true);
         SELF->vtable->pmc_class = master->vtables[type_num]->pmc_class;
-        add_pmc_sync(INTERP, ret);
+        Parrot_gc_add_pmc_sync(INTERP, ret);
         PObj_is_PMC_shared_SET(ret);
 
         data = PARROT_CLASS(classobj)->parents;

Modified: trunk/src/pmc/orderedhash.pmc
==============================================================================
--- trunk/src/pmc/orderedhash.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/orderedhash.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -67,9 +67,9 @@
             while (b) {
 
                 if (b->key) {
-                    pobject_lives(interp, (PObj *)b->key);
+                    Parrot_gc_mark_PObj_alive(interp, (PObj *)b->key);
                     if (b->value)
-                        pobject_lives(interp, (PObj *)b->value);
+                        Parrot_gc_mark_PObj_alive(interp, (PObj *)b->value);
                 }
 
                 b = b->next;

Modified: trunk/src/pmc/packfile.pmc
==============================================================================
--- trunk/src/pmc/packfile.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfile.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -115,9 +115,9 @@
         Parrot_Packfile_attributes * attrs = PARROT_PACKFILE(SELF);
 
         if (attrs->uuid)
-            pobject_lives(INTERP, (PObj *)attrs->uuid);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->uuid);
         if (attrs->directory)
-            pobject_lives(INTERP, (PObj *)attrs->directory);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)attrs->directory);
     }
 /*
 

Modified: trunk/src/pmc/packfileannotationkeys.pmc
==============================================================================
--- trunk/src/pmc/packfileannotationkeys.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfileannotationkeys.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -86,11 +86,11 @@
                 PARROT_PACKFILEANNOTATIONKEYS(SELF);
 
         if (attrs->const_table)
-            pobject_lives(interp, (PObj *)attrs->const_table);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->const_table);
         if (attrs->names)
-            pobject_lives(interp, (PObj *)attrs->names);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->names);
         if (attrs->types)
-            pobject_lives(interp, (PObj *)attrs->types);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->types);
     }
 
 /*

Modified: trunk/src/pmc/packfileannotations.pmc
==============================================================================
--- trunk/src/pmc/packfileannotations.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfileannotations.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -72,9 +72,9 @@
                 PARROT_PACKFILEANNOTATIONS(SELF);
 
         if (attrs->annotations)
-            pobject_lives(interp, (PObj *)attrs->annotations);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->annotations);
         if (attrs->keys)
-            pobject_lives(interp, (PObj *)attrs->keys);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->keys);
     }
 
 /*

Modified: trunk/src/pmc/packfileconstanttable.pmc
==============================================================================
--- trunk/src/pmc/packfileconstanttable.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfileconstanttable.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -69,9 +69,9 @@
                 PARROT_PACKFILECONSTANTTABLE(SELF);
 
         if (attrs->constants)
-            pobject_lives(interp, (PObj *)attrs->constants);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->constants);
         if (attrs->types)
-            pobject_lives(interp, (PObj *)attrs->types);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->types);
     }
 
 /*

Modified: trunk/src/pmc/packfiledirectory.pmc
==============================================================================
--- trunk/src/pmc/packfiledirectory.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfiledirectory.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -65,7 +65,7 @@
                 PARROT_PACKFILEDIRECTORY(SELF);
 
         if (attrs->hash)
-            pobject_lives(interp, (PObj *)attrs->hash);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->hash);
     }
 
 /*

Modified: trunk/src/pmc/packfilefixupentry.pmc
==============================================================================
--- trunk/src/pmc/packfilefixupentry.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfilefixupentry.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -61,7 +61,7 @@
                 PARROT_PACKFILEFIXUPENTRY(SELF);
 
         if (attrs->name)
-            pobject_lives(interp, (PObj *)attrs->name);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->name);
     }
 
 /*

Modified: trunk/src/pmc/packfilefixuptable.pmc
==============================================================================
--- trunk/src/pmc/packfilefixuptable.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfilefixuptable.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -65,7 +65,7 @@
                 PARROT_PACKFILEFIXUPTABLE(SELF);
 
         if (attrs->entries)
-            pobject_lives(interp, (PObj *)attrs->entries);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->entries);
     }
 
 /*

Modified: trunk/src/pmc/packfilerawsegment.pmc
==============================================================================
--- trunk/src/pmc/packfilerawsegment.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfilerawsegment.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -65,7 +65,7 @@
                 PARROT_PACKFILERAWSEGMENT(SELF);
 
         if (attrs->opcodes)
-            pobject_lives(interp, (PObj *)attrs->opcodes);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->opcodes);
     }
 
 /*

Modified: trunk/src/pmc/packfilesegment.pmc
==============================================================================
--- trunk/src/pmc/packfilesegment.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/packfilesegment.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -67,7 +67,7 @@
                 PARROT_PACKFILESEGMENT(SELF);
 
         if (attrs->directory)
-            pobject_lives(interp, (PObj *)attrs->directory);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->directory);
     }
 
 /*

Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/parrotinterpreter.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -68,7 +68,7 @@
     if (flags & PARROT_CLONE_HLL) {
         /* we'd like to share the HLL data. Give it a PMC_sync structure
            if it doesn't have one already */
-        add_pmc_sync(s, s->HLL_info);
+        Parrot_gc_add_pmc_sync(s, s->HLL_info);
         d->HLL_info = s->HLL_info;
         Parrot_regenerate_HLL_namespaces(d);
     }
@@ -757,7 +757,7 @@
     }
 
     METHOD run_gc() {
-        Parrot_do_gc_run(PMC_interp(SELF), 0);
+        Parrot_gc_mark_and_sweep(PMC_interp(SELF), 0);
     }
 
 /*

Modified: trunk/src/pmc/pmcproxy.pmc
==============================================================================
--- trunk/src/pmc/pmcproxy.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/pmcproxy.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -229,29 +229,29 @@
         Parrot_Class_attributes * const _pmc = PARROT_CLASS(SELF);
 
         if (_pmc->name)
-            pobject_lives(interp, (PObj *)_pmc->name);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->name);
         if (_pmc->_namespace)
-            pobject_lives(interp, (PObj *)_pmc->_namespace);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->_namespace);
         if (_pmc->parents)
-            pobject_lives(interp, (PObj *)_pmc->parents);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->parents);
         if (_pmc->all_parents)
-            pobject_lives(interp, (PObj *)_pmc->all_parents);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->all_parents);
         if (_pmc->roles)
-            pobject_lives(interp, (PObj *)_pmc->roles);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->roles);
         if (_pmc->methods)
-            pobject_lives(interp, (PObj *)_pmc->methods);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->methods);
         if (_pmc->vtable_overrides)
-            pobject_lives(interp, (PObj *)_pmc->vtable_overrides);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->vtable_overrides);
         if (_pmc->parent_overrides)
-            pobject_lives(interp, (PObj *)_pmc->parent_overrides);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->parent_overrides);
         if (_pmc->attrib_metadata)
-            pobject_lives(interp, (PObj *)_pmc->attrib_metadata);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->attrib_metadata);
         if (_pmc->attrib_index)
-            pobject_lives(interp, (PObj *)_pmc->attrib_index);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->attrib_index);
         if (_pmc->attrib_cache)
-            pobject_lives(interp, (PObj *)_pmc->attrib_cache);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->attrib_cache);
         if (_pmc->resolve_method)
-            pobject_lives(interp, (PObj *)_pmc->resolve_method);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)_pmc->resolve_method);
     }
 
 /*

Modified: trunk/src/pmc/retcontinuation.pmc
==============================================================================
--- trunk/src/pmc/retcontinuation.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/retcontinuation.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -97,17 +97,10 @@
         Parrot_free_context(INTERP, from_ctx, 1);
 
         /* the continuation is dead - delete and destroy it */
-        VTABLE_destroy(interp, SELF);
-        {
-            Arenas            *arena_base = interp->arena_base;
-            Small_Object_Pool *pool       = arena_base->pmc_pool;
-            Small_Object_Pool *ext_pool   = arena_base->pmc_ext_pool;
-            ext_pool->add_free_object(interp, ext_pool,
-                    (PObj *)SELF->pmc_ext);
-            PObj_flags_SETTO((PObj *)SELF, PObj_on_free_list_FLAG);
-            pool->add_free_object(interp, pool, (PObj *)SELF);
-            pool->num_free_objects++;
-        }
+        /* This line causes a failure in t/pmc/packfiledirectory.t. No idea
+           what the relationship is between this line of code and that test
+           failure. Will look into it later */
+        /* Parrot_gc_free_pmc_header(interp, SELF); */
 
         if (INTERP->code != seg)
             Parrot_switch_to_cs(INTERP, seg, 1);

Modified: trunk/src/pmc/role.pmc
==============================================================================
--- trunk/src/pmc/role.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/role.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -273,15 +273,15 @@
         Parrot_Role_attributes * const role = PARROT_ROLE(SELF);
 
         if (role->name)
-            pobject_lives(interp, (PObj *)role->name);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)role->name);
         if (role->_namespace)
-            pobject_lives(interp, (PObj *)role->_namespace);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)role->_namespace);
         if (role->roles)
-            pobject_lives(interp, (PObj *)role->roles);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)role->roles);
         if (role->methods)
-            pobject_lives(interp, (PObj *)role->methods);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)role->methods);
         if (role->attrib_metadata)
-            pobject_lives(interp, (PObj *)role->attrib_metadata);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)role->attrib_metadata);
     }
 
 /*

Modified: trunk/src/pmc/scalar.pmc
==============================================================================
--- trunk/src/pmc/scalar.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/scalar.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -1380,7 +1380,7 @@
         VTABLE_setprop(INTERP, ret, CONST_STRING(INTERP, "_ro"), _true);
 
         /* now share; we add a PMC_EXT so we can identify the owning interp */
-        add_pmc_sync(INTERP, ret);
+        Parrot_gc_add_pmc_sync(INTERP, ret);
         PObj_is_PMC_shared_SET(ret);
 
         /* XXX FIXME workaround lack of metadata sharing*/

Modified: trunk/src/pmc/scheduler.pmc
==============================================================================
--- trunk/src/pmc/scheduler.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/scheduler.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -267,15 +267,15 @@
             Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
 
             if (core_struct->task_list)
-                pobject_lives(interp, (PObj *)core_struct->task_list);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->task_list);
             if (core_struct->task_index)
-                pobject_lives(interp, (PObj *)core_struct->task_index);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->task_index);
             if (core_struct->wait_index)
-                pobject_lives(interp, (PObj *)core_struct->wait_index);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->wait_index);
             if (core_struct->handlers)
-                pobject_lives(interp, (PObj *)core_struct->handlers);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handlers);
             if (core_struct->messages)
-                pobject_lives(interp, (PObj *)core_struct->messages);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->messages);
         }
     }
 

Modified: trunk/src/pmc/schedulermessage.pmc
==============================================================================
--- trunk/src/pmc/schedulermessage.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/schedulermessage.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -216,7 +216,7 @@
                 PARROT_SCHEDULERMESSAGE(SELF);
 
             if (core_struct->data)
-                pobject_lives(interp, (PObj*)core_struct->data);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)core_struct->data);
         }
     }
 

Modified: trunk/src/pmc/socket.pmc
==============================================================================
--- trunk/src/pmc/socket.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/socket.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -82,10 +82,10 @@
 
         if (data) {
             if (data->local)
-                pobject_lives(interp, (PObj *)data->local);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)data->local);
 
             if (data->remote)
-                pobject_lives(interp, (PObj *)data->remote);
+                Parrot_gc_mark_PObj_alive(interp, (PObj *)data->remote);
         }
     }
 /*

Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/string.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -98,7 +98,7 @@
         GET_ATTR_str_val(INTERP, SELF, str_val);
 
         if (str_val)
-            pobject_lives(INTERP, (PObj *)str_val);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)str_val);
     }
 
 /*

Modified: trunk/src/pmc/stringhandle.pmc
==============================================================================
--- trunk/src/pmc/stringhandle.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/stringhandle.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -95,13 +95,13 @@
     VTABLE void mark() {
         Parrot_StringHandle_attributes * const data_struct = PARROT_STRINGHANDLE(SELF);
         if (data_struct->stringhandle)
-            pobject_lives(interp, (PObj *)data_struct->stringhandle);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->stringhandle);
         if (data_struct->mode)
-            pobject_lives(interp, (PObj *)data_struct->mode);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->mode);
         if (data_struct->encoding)
-            pobject_lives(interp, (PObj *)data_struct->encoding);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->encoding);
         if (data_struct->filename)
-            pobject_lives(interp, (PObj *)data_struct->filename);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->filename);
     }
 
 /*

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/sub.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -470,23 +470,23 @@
             return;
 
         if (sub->name)
-            pobject_lives(INTERP, (PObj *) sub->name);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->name);
         if (sub->method_name)
-            pobject_lives(INTERP, (PObj *) sub->method_name);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->method_name);
         if (sub->ns_entry_name)
-            pobject_lives(INTERP, (PObj *) sub->ns_entry_name);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->ns_entry_name);
         if (!PMC_IS_NULL(sub->namespace_name))
-            pobject_lives(INTERP, (PObj *) sub->namespace_name);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->namespace_name);
         if (!PMC_IS_NULL(sub->multi_signature))
-            pobject_lives(INTERP, (PObj *) sub->multi_signature);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->multi_signature);
         if (!PMC_IS_NULL(sub->lex_info))
-            pobject_lives(INTERP, (PObj *) sub->lex_info);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->lex_info);
         if (!PMC_IS_NULL(sub->outer_sub))
-            pobject_lives(INTERP, (PObj *) sub->outer_sub);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->outer_sub);
         if (!PMC_IS_NULL(sub->eval_pmc))
-            pobject_lives(INTERP, (PObj *) sub->eval_pmc);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->eval_pmc);
         if (sub->subid)
-            pobject_lives(INTERP, (PObj *) sub->subid);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *) sub->subid);
         if (sub->ctx)
             mark_context(interp, sub->ctx);
         if (sub->outer_ctx)

Modified: trunk/src/pmc/task.pmc
==============================================================================
--- trunk/src/pmc/task.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/task.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -395,9 +395,9 @@
             Parrot_Task_attributes * const core_struct = PARROT_TASK(SELF);
 
             if (core_struct->codeblock)
-                pobject_lives(interp, (PObj*)core_struct->codeblock);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)core_struct->codeblock);
             if (core_struct->data)
-                pobject_lives(interp, (PObj*)core_struct->data);
+                Parrot_gc_mark_PObj_alive(interp, (PObj*)core_struct->data);
         }
     }
 

Modified: trunk/src/pmc/unmanagedstruct.pmc
==============================================================================
--- trunk/src/pmc/unmanagedstruct.pmc	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc/unmanagedstruct.pmc	Sat May  9 20:02:23 2009	(r38654)
@@ -759,7 +759,7 @@
 
     VTABLE void mark() {
         if (PARROT_UNMANAGEDSTRUCT(SELF)->init)
-            pobject_lives(INTERP, (PObj *)PARROT_UNMANAGEDSTRUCT(SELF)->init);
+            Parrot_gc_mark_PObj_alive(INTERP, (PObj *)PARROT_UNMANAGEDSTRUCT(SELF)->init);
     }
 
 /*

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/pmc_freeze.c	Sat May  9 20:02:23 2009	(r38654)
@@ -51,12 +51,6 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(3);
 
-static void cleanup_next_for_GC(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-static void cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
-        __attribute__nonnull__(1);
-
 static void create_image(PARROT_INTERP,
     ARGIN_NULLOK(PMC *pmc),
     ARGMOD(visit_info *info))
@@ -301,10 +295,6 @@
 #define ASSERT_ARGS_add_pmc_todo_list __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(info)
-#define ASSERT_ARGS_cleanup_next_for_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_cleanup_next_for_GC_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(pool)
 #define ASSERT_ARGS_create_image __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(info)
@@ -482,7 +472,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);
@@ -730,11 +720,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
 }
 
@@ -969,55 +959,7 @@
 {
     ASSERT_ARGS(pmc_add_ext)
     if (pmc->vtable->flags & VTABLE_PMC_NEEDS_EXT)
-        add_pmc_ext(interp, pmc);
-}
-
-/*
-
-=item C<static void cleanup_next_for_GC_pool(Small_Object_Pool *pool)>
-
-Sets all the C<next_for_GC> pointers to C<NULL>.
-
-=cut
-
-*/
-
-static void
-cleanup_next_for_GC_pool(ARGIN(Small_Object_Pool *pool))
-{
-    ASSERT_ARGS(cleanup_next_for_GC_pool)
-    Small_Object_Arena *arena;
-
-    for (arena = pool->last_Arena; arena; arena = arena->prev) {
-        PMC *p = (PMC *)arena->start_objects;
-        UINTVAL i;
-
-        for (i = 0; i < arena->used; i++) {
-            if (!PObj_on_free_list_TEST(p)) {
-                if (p->pmc_ext)
-                    PMC_next_for_GC(p) = PMCNULL;
-            }
-            p++;
-        }
-    }
-}
-
-/*
-
-=item C<static void cleanup_next_for_GC(PARROT_INTERP)>
-
-Cleans up the C<next_for_GC> pointers.
-
-=cut
-
-*/
-
-static void
-cleanup_next_for_GC(PARROT_INTERP)
-{
-    ASSERT_ARGS(cleanup_next_for_GC)
-    cleanup_next_for_GC_pool(interp->arena_base->pmc_pool);
-    cleanup_next_for_GC_pool(interp->arena_base->constant_pmc_pool);
+        Parrot_gc_add_pmc_ext(interp, pmc);
 }
 
 /*
@@ -1423,37 +1365,7 @@
 static UINTVAL
 id_from_pmc(PARROT_INTERP, ARGIN(PMC* pmc))
 {
-    ASSERT_ARGS(id_from_pmc)
-    UINTVAL id = 1;     /* first PMC in first arena */
-    Small_Object_Arena *arena;
-    Small_Object_Pool *pool;
-
-    pmc = (PMC*)PObj_to_ARENA(pmc);
-    pool = interp->arena_base->pmc_pool;
-    for (arena = pool->last_Arena; arena; arena = arena->prev) {
-        const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
-        if (ptr_diff >= 0 && ptr_diff <
-                (ptrdiff_t)(arena->used * pool->object_size)) {
-            PARROT_ASSERT(ptr_diff % pool->object_size == 0);
-            id += ptr_diff / pool->object_size;
-            return id << 2;
-        }
-        id += arena->total_objects;
-    }
-
-    pool = interp->arena_base->constant_pmc_pool;
-    for (arena = pool->last_Arena; arena; arena = arena->prev) {
-        const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects;
-        if (ptr_diff >= 0 && ptr_diff <
-                (ptrdiff_t)(arena->used * pool->object_size)) {
-            PARROT_ASSERT(ptr_diff % pool->object_size == 0);
-            id += ptr_diff / pool->object_size;
-            return id << 2;
-        }
-        id += arena->total_objects;
-    }
-
-    Parrot_ex_throw_from_c_args(interp, NULL, 1, "Couldn't find PMC in arenas");
+    return Parrot_gc_get_pmc_index(interp, pmc) << 2;
 }
 
 /*
@@ -1846,7 +1758,7 @@
      * collected under us.
      */
     if (1 || (Parrot_str_byte_length(interp, image) > THAW_BLOCK_GC_SIZE)) {
-        Parrot_do_gc_run(interp, 1);
+        Parrot_gc_mark_and_sweep(interp, 1);
         Parrot_block_GC_mark(interp);
         Parrot_block_GC_sweep(interp);
         gc_block = 1;
@@ -1908,7 +1820,7 @@
     visit_info info;
 
     Parrot_block_GC_mark(interp);
-    cleanup_next_for_GC(interp);
+    Parrot_gc_cleanup_next_for_GC(interp);
     info.what = VISIT_FREEZE_AT_DESTRUCT;
     info.mark_ptr = pmc;
     info.thaw_ptr = NULL;

Modified: trunk/src/runcore/cores.c
==============================================================================
--- trunk/src/runcore/cores.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/runcore/cores.c	Sat May  9 20:02:23 2009	(r38654)
@@ -357,11 +357,10 @@
     ASSERT_ARGS(runops_trace_core)
 
     static size_t  gc_mark_runs, gc_collect_runs;
-    Arenas * const arena_base = interp->arena_base;
     Interp        *debugger;
 
-    gc_mark_runs    = arena_base->gc_mark_runs;
-    gc_collect_runs = arena_base->gc_collect_runs;
+    gc_mark_runs    = Parrot_gc_count_mark_runs(interp);
+    gc_collect_runs = Parrot_gc_count_collect_runs(interp);
     if (interp->pdb) {
         debugger = interp->pdb->debugger;
         PARROT_ASSERT(debugger);
@@ -399,6 +398,7 @@
 
     trace_op(interp, code_start, code_end, pc);
     while (pc) {
+        int runs;
         if (pc < code_start || pc >= code_end)
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                 "attempt to access code outside of current code segment");
@@ -408,13 +408,15 @@
         DO_OP(pc, interp);
         trace_op(interp, code_start, code_end, pc);
 
-        if (gc_mark_runs != arena_base->gc_mark_runs) {
-            gc_mark_runs  = arena_base->gc_mark_runs;
+        runs = Parrot_gc_count_mark_runs(interp);
+        if (gc_mark_runs != runs) {
+            gc_mark_runs  = runs;
             Parrot_io_eprintf(debugger, "       GC mark\n");
         }
 
-        if (gc_collect_runs != arena_base->gc_collect_runs) {
-            gc_collect_runs  = arena_base->gc_collect_runs;
+        runs = Parrot_gc_count_collect_runs(interp);
+        if (gc_collect_runs != runs) {
+            gc_collect_runs  = runs;
             Parrot_io_eprintf(debugger, "       GC collect\n");
         }
     }
@@ -487,7 +489,7 @@
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                 "attempt to access code outside of current code segment");
 
-        Parrot_do_gc_run(interp, 0);
+        Parrot_gc_mark_and_sweep(interp, 0);
         CONTEXT(interp)->current_pc = pc;
 
         DO_OP(pc, interp);
@@ -579,7 +581,7 @@
                     "attempt to access code outside of current code segment");
 
         if (interp->pdb->state & PDB_GCDEBUG)
-            Parrot_do_gc_run(interp, 0);
+            Parrot_gc_mark_and_sweep(interp, 0);
 
         if (interp->pdb->state & PDB_TRACING) {
             trace_op(interp,

Modified: trunk/src/stacks.c
==============================================================================
--- trunk/src/stacks.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/stacks.c	Sat May  9 20:02:23 2009	(r38654)
@@ -74,13 +74,12 @@
 cst_new_stack_chunk(PARROT_INTERP, ARGIN(const Stack_Chunk_t *chunk))
 {
     ASSERT_ARGS(cst_new_stack_chunk)
-    Small_Object_Pool * const pool = chunk->pool;
-    Stack_Chunk_t * const new_chunk = (Stack_Chunk_t *)pool->get_free_object(interp, pool);
+    Stack_Chunk_t * const new_chunk =
+        (Stack_Chunk_t *)Parrot_gc_new_bufferlike_header(interp, sizeof(Stack_Chunk_t));
 
     PObj_bufstart(new_chunk) = NULL;
     PObj_buflen(new_chunk)   = 0;
 
-    new_chunk->pool          = chunk->pool;
     new_chunk->name          = chunk->name;
 
     return new_chunk;
@@ -104,12 +103,11 @@
 new_stack(PARROT_INTERP, ARGIN(const char *name))
 {
     ASSERT_ARGS(new_stack)
-    Small_Object_Pool * const pool = get_bufferlike_pool(interp, sizeof (Stack_Chunk_t));
-    Stack_Chunk_t     * const chunk = (Stack_Chunk_t *)(pool->get_free_object)(interp, pool);
+    Stack_Chunk_t * const chunk =
+        (Stack_Chunk_t *)Parrot_gc_new_bufferlike_header(interp, sizeof(Stack_Chunk_t));
 
     chunk->prev = chunk;        /* mark the top of the stack */
     chunk->name = name;
-    chunk->pool = pool;         /* cache the pool pointer, for ease */
 
     return chunk;
 }
@@ -133,7 +131,7 @@
     for (; ; chunk = chunk->prev) {
         Stack_Entry_t  *entry;
 
-        pobject_lives(interp, (PObj *)chunk);
+        Parrot_gc_mark_PObj_alive(interp, (PObj *)chunk);
 
         if (chunk == chunk->prev)
             break;
@@ -141,7 +139,7 @@
         entry = STACK_DATAP(chunk);
 
         if (entry->entry_type == STACK_ENTRY_PMC && UVal_pmc(entry->entry))
-            pobject_lives(interp, (PObj *)UVal_pmc(entry->entry));
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)UVal_pmc(entry->entry));
     }
 }
 
@@ -371,12 +369,8 @@
     }
 
     /* recycle this chunk to the free list if it's otherwise unreferenced */
-    if (cur_chunk->refcount <= 0) {
-        Small_Object_Pool * const pool = cur_chunk->pool;
-
-        pool->gc_object(interp, pool, (PObj *)cur_chunk);
-        pool->add_free_object(interp, pool, (PObj *)cur_chunk);
-    }
+    if (cur_chunk->refcount <= 0)
+        Parrot_gc_free_bufferlike_header(interp, (PObj *)cur_chunk, sizeof (Stack_Chunk_t));
 
     return where;
 }

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/api.c	Sat May  9 20:02:23 2009	(r38654)
@@ -27,7 +27,6 @@
 #include "parrot/compiler.h"
 #include "parrot/string_funcs.h"
 #include "private_cstring.h"
-#include "parrot/resources.h"
 
 #define nonnull_encoding_name(s) (s) ? (s)->encoding->name : "null string"
 #define saneify_string(s) \
@@ -89,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);
@@ -128,7 +127,8 @@
     STRING *d;
 
     if (PObj_constant_TEST(s)) {
-        d = new_string_header(interp, PObj_get_FLAGS(s) & ~PObj_constant_FLAG);
+        d = Parrot_gc_new_string_header(interp,
+            PObj_get_FLAGS(s) & ~PObj_constant_FLAG);
         PObj_COW_SET(s);
         STRUCT_COPY(d, s);
         /* we can't move the memory, because constants aren't
@@ -139,7 +139,7 @@
         PObj_external_SET(d);
     }
     else {
-        d = new_string_header(interp, PObj_get_FLAGS(s));
+        d = Parrot_gc_new_string_header(interp, PObj_get_FLAGS(s));
         PObj_COW_SET(s);
         STRUCT_COPY(d, s);
         PObj_sysmem_CLEAR(d);
@@ -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",
@@ -242,10 +242,7 @@
 Parrot_str_free(PARROT_INTERP, ARGIN(STRING *s))
 {
     ASSERT_ARGS(Parrot_str_free)
-    if (!PObj_constant_TEST(s)) {
-        Small_Object_Pool * const pool = interp->arena_base->string_header_pool;
-        pool->add_free_object(interp, pool, s);
-    }
+    Parrot_gc_free_string_header(interp, s);
 }
 
 /*
@@ -381,7 +378,7 @@
     parrot_string_representation_t representation, UINTVAL capacity)
 {
     ASSERT_ARGS(Parrot_str_new_noinit)
-    STRING * const s = new_string_header(interp, 0);
+    STRING * const s = Parrot_gc_new_string_header(interp, 0);
 
     /* TODO adapt string creation functions */
     if (representation != enum_stringrep_one)
@@ -391,7 +388,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;
@@ -567,7 +564,7 @@
         /* upgrade to utf16 */
         Parrot_utf16_encoding_ptr->to_encoding(interp, a, NULL);
         b = Parrot_utf16_encoding_ptr->to_encoding(interp, b,
-                new_string_header(interp, 0));
+                Parrot_gc_new_string_header(interp, 0));
 
         /* result could be mixed ucs2 / utf16 */
         if (b->encoding == Parrot_utf16_encoding_ptr)
@@ -580,7 +577,7 @@
 
     /* make sure A's big enough for both  */
     if (total_length > a_capacity)
-        Parrot_reallocate_string(interp, a, total_length << 1);
+        Parrot_gc_reallocate_string_storage(interp, a, total_length << 1);
 
     /* A is now ready to receive the contents of B */
 
@@ -760,7 +757,7 @@
 {
     ASSERT_ARGS(Parrot_str_new_init)
     DECL_CONST_CAST;
-    STRING * const s = new_string_header(interp, flags);
+    STRING * const s = Parrot_gc_new_string_header(interp, flags);
     s->encoding      = encoding;
     s->charset       = charset;
 
@@ -785,7 +782,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);
@@ -822,7 +819,7 @@
     Parrot_str_write_COW(interp, s);
 
     /* Don't check buflen, if we are here, we already checked. */
-    Parrot_reallocate_string(interp,
+    Parrot_gc_reallocate_string_storage(interp,
         s, PObj_buflen(s) + string_max_bytes(interp, s, addlen));
     return s;
 }
@@ -1266,7 +1263,7 @@
     if (!cs) {
         Parrot_utf16_encoding_ptr->to_encoding(interp, src, NULL);
         rep = Parrot_utf16_encoding_ptr->to_encoding(interp, rep,
-                new_string_header(interp, 0));
+                Parrot_gc_new_string_header(interp, 0));
     }
     else {
         src->charset  = cs;
@@ -1611,7 +1608,7 @@
 #if ! DISABLE_GC_DEBUG
     /* trigger GC for debug */
     if (interp && GC_DEBUG(interp))
-        Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+        Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #endif
 
     make_writable(interp, &res, minlen, enum_stringrep_one);
@@ -1764,7 +1761,7 @@
 #if ! DISABLE_GC_DEBUG
     /* trigger GC for debug */
     if (interp && GC_DEBUG(interp))
-        Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+        Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #endif
 
     make_writable(interp, &res, maxlen, enum_stringrep_one);
@@ -1840,7 +1837,7 @@
 #if ! DISABLE_GC_DEBUG
     /* trigger GC for debug */
     if (interp && GC_DEBUG(interp))
-        Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+        Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #endif
 
     make_writable(interp, &res, maxlen, enum_stringrep_one);
@@ -1919,7 +1916,7 @@
 #if ! DISABLE_GC_DEBUG
     /* trigger GC for debug */
     if (interp && GC_DEBUG(interp))
-        Parrot_do_gc_run(interp, GC_trace_stack_FLAG);
+        Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 #endif
 
     make_writable(interp, &res, len, enum_stringrep_one);
@@ -2325,13 +2322,13 @@
     memory = PObj_bufstart(s);
 
     /* Reallocate it the same size
-     * NOTE can't use Parrot_reallocate_string because of the LEA
+     * NOTE can't use Parrot_gc_reallocate_string_storage because of the LEA
      * allocator, where this is a noop for the same size
      *
      * 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);
 
@@ -2453,7 +2450,7 @@
             if (i >= charlen - 2) {
                 /* resize - still len codepoints to go */
                 charlen += len * 2 + 16;
-                Parrot_reallocate_string(interp, result, charlen);
+                Parrot_gc_reallocate_string_storage(interp, result, charlen);
                 /* start can change */
                 dp = (unsigned char *)result->strstart;
             }

Modified: trunk/src/string/charset/ascii.c
==============================================================================
--- trunk/src/string/charset/ascii.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/charset/ascii.c	Sat May  9 20:02:23 2009	(r38654)
@@ -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: trunk/src/string/charset/iso-8859-1.c
==============================================================================
--- trunk/src/string/charset/iso-8859-1.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/charset/iso-8859-1.c	Sat May  9 20:02:23 2009	(r38654)
@@ -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: trunk/src/string/charset/unicode.c
==============================================================================
--- trunk/src/string/charset/unicode.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/charset/unicode.c	Sat May  9 20:02:23 2009	(r38654)
@@ -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,

Modified: trunk/src/string/encoding/utf16.c
==============================================================================
--- trunk/src/string/encoding/utf16.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/encoding/utf16.c	Sat May  9 20:02:23 2009	(r38654)
@@ -286,7 +286,7 @@
         p = (UChar *)mem_sys_allocate(src_len * sizeof (UChar));
     }
     else {
-        Parrot_reallocate_string(interp, dest, sizeof (UChar) * src_len);
+        Parrot_gc_reallocate_string_storage(interp, dest, sizeof (UChar) * src_len);
         p = (UChar *)dest->strstart;
     }
     if (src->charset == Parrot_iso_8859_1_charset_ptr ||
@@ -307,7 +307,7 @@
                 p = (UChar *)mem_sys_realloc(p, dest_len * sizeof (UChar));
             else {
                 result->bufused = dest_len * sizeof (UChar);
-                Parrot_reallocate_string(interp, dest,
+                Parrot_gc_reallocate_string_storage(interp, dest,
                                          sizeof (UChar) * dest_len);
                 p = (UChar *)dest->strstart;
             }
@@ -318,7 +318,7 @@
     }
     result->bufused = dest_len * sizeof (UChar);
     if (in_place) {
-        Parrot_reallocate_string(interp, src, src->bufused);
+        Parrot_gc_reallocate_string_storage(interp, src, src->bufused);
         memcpy(src->strstart, p, src->bufused);
         mem_sys_free(p);
     }

Modified: trunk/src/string/encoding/utf8.c
==============================================================================
--- trunk/src/string/encoding/utf8.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/string/encoding/utf8.c	Sat May  9 20:02:23 2009	(r38654)
@@ -596,7 +596,7 @@
         p = (unsigned char *)mem_sys_allocate(src_len);
     }
     else {
-        Parrot_reallocate_string(interp, dest, src_len);
+        Parrot_gc_reallocate_string_storage(interp, dest, src_len);
         p = (unsigned char *)dest->strstart;
     }
     if (src->charset == Parrot_ascii_charset_ptr) {
@@ -619,7 +619,7 @@
                     p = (unsigned char *)mem_sys_realloc(p, dest_len);
                 else {
                     result->bufused = dest_pos;
-                    Parrot_reallocate_string(interp, dest, dest_len);
+                    Parrot_gc_reallocate_string_storage(interp, dest, dest_len);
                     p = (unsigned char *)dest->strstart;
                 }
             }
@@ -631,7 +631,7 @@
         result->bufused = dest_pos;
     }
     if (in_place) {
-        Parrot_reallocate_string(interp, src, src->bufused);
+        Parrot_gc_reallocate_string_storage(interp, src, src->bufused);
         memcpy(src->strstart, p, src->bufused);
         mem_sys_free(p);
     }

Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/sub.c	Sat May  9 20:02:23 2009	(r38654)
@@ -80,15 +80,15 @@
 
     obj = (PObj *)ctx->current_sub;
     if (obj)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     obj = (PObj *)ctx->current_object;
     if (obj)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     obj = (PObj *)ctx->current_cont;
     if (obj && !PObj_live_TEST(obj))
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     if (ctx->caller_ctx)
         mark_context(interp, ctx->caller_ctx);
@@ -98,15 +98,15 @@
 
     obj = (PObj *)ctx->current_namespace;
     if (obj)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     obj = (PObj *)ctx->lex_pad;
     if (obj)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
     obj = (PObj *)ctx->handlers;
     if (obj)
-        pobject_lives(interp, obj);
+        Parrot_gc_mark_PObj_alive(interp, obj);
 
 
     if (!ctx->n_regs_used)
@@ -115,7 +115,7 @@
     for (i = 0; i < ctx->n_regs_used[REGNO_PMC]; ++i) {
         obj = (PObj *)CTX_REG_PMC(ctx, i);
         if (obj)
-            pobject_lives(interp, obj);
+            Parrot_gc_mark_PObj_alive(interp, obj);
     }
 
     for (i = 0; i < ctx->n_regs_used[REGNO_STR]; ++i) {
@@ -125,7 +125,7 @@
              * yet tracked down */
             PObj_flag_CLEAR(is_PMC, obj);
             PObj_is_string_SET(obj);
-            pobject_lives(interp, obj);
+            Parrot_gc_mark_PObj_alive(interp, obj);
         }
     }
 }

Modified: trunk/src/thread.c
==============================================================================
--- trunk/src/thread.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/thread.c	Sat May  9 20:02:23 2009	(r38654)
@@ -352,7 +352,7 @@
     if (is_ro)
         pmc->vtable = pmc->vtable->ro_variant_vtable;
 
-    add_pmc_sync(interp, pmc);
+    Parrot_gc_add_pmc_sync(interp, pmc);
 
     PObj_is_PMC_shared_SET(pmc);
 
@@ -1260,7 +1260,7 @@
 {
     ASSERT_ARGS(pt_suspend_self_for_gc)
     PARROT_ASSERT(interp);
-    PARROT_ASSERT(!interp->arena_base->gc_mark_block_level);
+    PARROT_ASSERT(!Parrot_is_blocked_GC_mark(interp));
     DEBUG_ONLY(fprintf(stderr, "%p: suspend_self_for_gc\n", interp));
     /* since we are modifying our own state, we need to lock
      * the interpreter_array_mutex.
@@ -1288,7 +1288,7 @@
     /* mark and sweep our world -- later callbacks will keep
      * it sync'd
      */
-    Parrot_gc_ms_run(interp, GC_trace_stack_FLAG);
+    Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 
     PARROT_ASSERT(!(interp->thread_data->state & THREAD_STATE_SUSPENDED_GC));
 }

Modified: trunk/src/vtables.c
==============================================================================
--- trunk/src/vtables.c	Sat May  9 19:32:38 2009	(r38653)
+++ trunk/src/vtables.c	Sat May  9 20:02:23 2009	(r38654)
@@ -209,15 +209,15 @@
             continue;
 
         if (vtable->mro)
-            pobject_lives(interp, (PObj *)vtable->mro);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)vtable->mro);
         if (vtable->_namespace)
-            pobject_lives(interp, (PObj *)vtable->_namespace);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)vtable->_namespace);
         if (vtable->whoami)
-            pobject_lives(interp, (PObj *)vtable->whoami);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)vtable->whoami);
         if (vtable->provides_str)
-            pobject_lives(interp, (PObj *)vtable->provides_str);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)vtable->provides_str);
         if (vtable->pmc_class)
-            pobject_lives(interp, (PObj *)vtable->pmc_class);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)vtable->pmc_class);
     }
 }
 


More information about the parrot-commits mailing list