[svn:parrot] r43779 - branches/gc_encapsulate_part1/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Feb 8 13:27:02 UTC 2010


Author: bacek
Date: Mon Feb  8 13:27:02 2010
New Revision: 43779
URL: https://trac.parrot.org/parrot/changeset/43779

Log:
Switch mark_sweep functions to use explicit Memory_Pools*.

Modified:
   branches/gc_encapsulate_part1/src/gc/api.c
   branches/gc_encapsulate_part1/src/gc/gc_ms.c
   branches/gc_encapsulate_part1/src/gc/gc_private.h
   branches/gc_encapsulate_part1/src/gc/mark_sweep.c

Modified: branches/gc_encapsulate_part1/src/gc/api.c
==============================================================================
--- branches/gc_encapsulate_part1/src/gc/api.c	Mon Feb  8 13:05:53 2010	(r43778)
+++ branches/gc_encapsulate_part1/src/gc/api.c	Mon Feb  8 13:27:02 2010	(r43779)
@@ -225,7 +225,7 @@
         PMC * const p = (PMC *)obj;
 
         if (PObj_is_special_PMC_TEST(obj))
-            mark_special(interp, p);
+            mark_special(interp, interp->mem_pools, p);
 
         else if (PMC_metadata(p))
             Parrot_gc_mark_PMC_alive(interp, PMC_metadata(p));
@@ -349,8 +349,8 @@
     }
 
     initialize_var_size_pools(interp, interp->mem_pools);
-    initialize_fixed_size_pools(interp);
-    Parrot_gc_initialize_fixed_size_pools(interp, GC_NUM_INITIAL_FIXED_SIZE_POOLS);
+    initialize_fixed_size_pools(interp, interp->mem_pools);
+    Parrot_gc_initialize_fixed_size_pools(interp, interp->mem_pools, GC_NUM_INITIAL_FIXED_SIZE_POOLS);
 }
 
 /*
@@ -563,7 +563,7 @@
 {
     ASSERT_ARGS(Parrot_gc_new_bufferlike_header)
 
-    Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, size);
+    Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, interp->mem_pools, size);
 
     return get_free_buffer(interp, pool);
 }
@@ -606,7 +606,7 @@
     size_t size)
 {
     ASSERT_ARGS(Parrot_gc_free_bufferlike_header)
-    Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, size);
+    Fixed_Size_Pool * const pool = get_bufferlike_pool(interp, interp->mem_pools, size);
     pool->add_free_object(interp, interp->mem_pools, pool, obj);
 }
 
@@ -910,7 +910,7 @@
         if (i >= dest_arena->num_sized
         || !dest_arena->sized_header_pools[i]) {
             Fixed_Size_Pool *ignored = get_bufferlike_pool(dest_interp,
-                    i * sizeof (void *));
+                    dest_interp->mem_pools, i * sizeof (void *));
             UNUSED(ignored);
             PARROT_ASSERT(dest_arena->sized_header_pools[i]);
         }
@@ -973,7 +973,7 @@
 
         total_objects   = cur_arena->total_objects;
 
-        Parrot_append_arena_in_pool(interp, dest, cur_arena,
+        Parrot_append_arena_in_pool(interp, interp->mem_pools, dest, cur_arena,
             cur_arena->total_objects);
 
         /* XXX needed? */
@@ -1054,12 +1054,12 @@
      */
     const INTVAL start = 2;
 
-    header_pools_iterate_callback(interp, POOL_PMC, NULL, sweep_cb_pmc);
-    header_pools_iterate_callback(interp, POOL_PMC | POOL_CONST, NULL,
+    header_pools_iterate_callback(interp, interp->mem_pools, POOL_PMC, NULL, sweep_cb_pmc);
+    header_pools_iterate_callback(interp, interp->mem_pools, POOL_PMC | POOL_CONST, NULL,
             sweep_cb_pmc);
 
     for (pass = start; pass <= 2; pass++) {
-        header_pools_iterate_callback(interp, POOL_BUFFER | POOL_CONST,
+        header_pools_iterate_callback(interp, interp->mem_pools, POOL_BUFFER | POOL_CONST,
                 (void *)pass, sweep_cb_buf);
     }
 
@@ -1111,7 +1111,7 @@
         SHIM(int flag), SHIM(void *arg))
 {
     ASSERT_ARGS(sweep_cb_pmc)
-    Parrot_gc_sweep_pool(interp, pool);
+    Parrot_gc_sweep_pool(interp, interp->mem_pools, pool);
     free_pool(pool);
     return 0;
 }
@@ -1137,7 +1137,7 @@
 {
     ASSERT_ARGS(sweep_cb_buf)
     UNUSED(arg);
-    Parrot_gc_sweep_pool(interp, pool);
+    Parrot_gc_sweep_pool(interp, interp->mem_pools, pool);
     free_pool(pool);
 
     return 0;
@@ -1620,7 +1620,7 @@
     const size_t attr_size = pmc->vtable->attr_size;
 #if GC_USE_FIXED_SIZE_ALLOCATOR
     PMC_Attribute_Pool * const pool = Parrot_gc_get_attribute_pool(interp,
-        attr_size);
+            interp->mem_pools, attr_size);
     void * const attrs = Parrot_gc_get_attributes_from_pool(interp, pool);
     memset(attrs, 0, attr_size);
     PMC_data(pmc) = attrs;
@@ -1686,7 +1686,7 @@
 
     /* otherwise create it */
     if (!pool)
-        pool = Parrot_gc_get_attribute_pool(interp, size);
+        pool = Parrot_gc_get_attribute_pool(interp, interp->mem_pools, size);
 
     return Parrot_gc_get_attributes_from_pool(interp, pool);
 }

Modified: branches/gc_encapsulate_part1/src/gc/gc_ms.c
==============================================================================
--- branches/gc_encapsulate_part1/src/gc/gc_ms.c	Mon Feb  8 13:05:53 2010	(r43778)
+++ branches/gc_encapsulate_part1/src/gc/gc_ms.c	Mon Feb  8 13:27:02 2010	(r43779)
@@ -182,7 +182,7 @@
 
     /* tell the threading system that we're doing GC mark */
     pt_gc_start_mark(interp);
-    Parrot_gc_run_init(interp);
+    Parrot_gc_run_init(interp, interp->mem_pools);
 
     /* compact STRING pools to collect free headers and allocated buffers */
     Parrot_gc_compact_memory_pool(interp);
@@ -197,7 +197,7 @@
 
         /* We've done the mark, now do the sweep. Pass the sweep callback
            function to the PMC pool and all the sized pools. */
-        header_pools_iterate_callback(interp, POOL_BUFFER | POOL_PMC,
+        header_pools_iterate_callback(interp, interp->mem_pools, POOL_BUFFER | POOL_PMC,
             (void*)&total_free, gc_ms_sweep_cb);
 
     }
@@ -239,12 +239,12 @@
     if (interp->scheduler) {
         Parrot_gc_mark_PMC_alive(interp, interp->scheduler);
         VTABLE_mark(interp, interp->scheduler);
-        Parrot_gc_sweep_pool(interp, interp->mem_pools->pmc_pool);
+        Parrot_gc_sweep_pool(interp, mem_pools, mem_pools->pmc_pool);
     }
 
     /* now sweep everything that's left */
-    Parrot_gc_sweep_pool(interp, interp->mem_pools->pmc_pool);
-    Parrot_gc_sweep_pool(interp, interp->mem_pools->constant_pmc_pool);
+    Parrot_gc_sweep_pool(interp, mem_pools, mem_pools->pmc_pool);
+    Parrot_gc_sweep_pool(interp, mem_pools, mem_pools->constant_pmc_pool);
 }
 
 
@@ -266,7 +266,7 @@
 {
     ASSERT_ARGS(gc_ms_trace_active_PMCs)
 
-    if (!Parrot_gc_trace_root(interp, trace))
+    if (!Parrot_gc_trace_root(interp, interp->mem_pools, trace))
         return 0;
 
     pt_gc_mark_root_finished(interp);
@@ -297,7 +297,7 @@
     ASSERT_ARGS(gc_ms_sweep_cb)
     int * const total_free = (int *) arg;
 
-    Parrot_gc_sweep_pool(interp, pool);
+    Parrot_gc_sweep_pool(interp, mem_pools, pool);
 
     *total_free += pool->num_free_objects;
 
@@ -495,7 +495,7 @@
     /* could be mem_internal_allocate too, but calloc is fast */
     new_arena->start_objects = mem_internal_allocate_zeroed(size);
 
-    Parrot_append_arena_in_pool(interp, pool, new_arena, size);
+    Parrot_append_arena_in_pool(interp, mem_pools, pool, new_arena, size);
 
     PARROT_ASSERT(pool->last_Arena);
 

Modified: branches/gc_encapsulate_part1/src/gc/gc_private.h
==============================================================================
--- branches/gc_encapsulate_part1/src/gc/gc_private.h	Mon Feb  8 13:05:53 2010	(r43778)
+++ branches/gc_encapsulate_part1/src/gc/gc_private.h	Mon Feb  8 13:27:02 2010	(r43779)
@@ -290,25 +290,35 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
-        __attribute__nonnull__(1);
+Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
+    size_t buffer_size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 PARROT_IGNORABLE_RESULT
 int /*@alt void@*/
 header_pools_iterate_callback(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
     int flag,
     ARGIN_NULLOK(void *arg),
     NOTNULL(pool_iter_fn func))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(4);
-
-void initialize_fixed_size_pools(PARROT_INTERP)
-        __attribute__nonnull__(1);
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(5);
 
-void mark_special(PARROT_INTERP, ARGIN(PMC *obj))
+void initialize_fixed_size_pools(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+void mark_special(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
+    ARGIN(PMC *obj))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
 void Parrot_add_to_free_list(PARROT_INTERP,
     ARGMOD(Fixed_Size_Pool *pool),
     ARGMOD(Fixed_Size_Arena *arena))
@@ -319,12 +329,14 @@
         FUNC_MODIFIES(*arena);
 
 void Parrot_append_arena_in_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
     ARGMOD(Fixed_Size_Pool *pool),
     ARGMOD(Fixed_Size_Arena *new_arena),
     size_t size)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
+        __attribute__nonnull__(4)
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*new_arena);
 
@@ -335,8 +347,10 @@
 
 PARROT_CANNOT_RETURN_NULL
 PMC_Attribute_Pool * Parrot_gc_get_attribute_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
     size_t attrib_size)
-        __attribute__nonnull__(1);
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
 void * Parrot_gc_get_attributes_from_pool(PARROT_INTERP,
@@ -346,33 +360,47 @@
         FUNC_MODIFIES(* pool);
 
 void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
     size_t init_num_pools)
-        __attribute__nonnull__(1);
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
-void Parrot_gc_run_init(PARROT_INTERP)
-        __attribute__nonnull__(1);
+void Parrot_gc_run_init(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
-void Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
+void Parrot_gc_sweep_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
+    ARGMOD(Fixed_Size_Pool *pool))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
         FUNC_MODIFIES(*pool);
 
-int Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)
-        __attribute__nonnull__(1);
+int Parrot_gc_trace_root(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
+    Parrot_gc_trace_type trace)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 #define ASSERT_ARGS_contained_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(ptr))
 #define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_header_pools_iterate_callback __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools) \
     , PARROT_ASSERT_ARG(func))
 #define ASSERT_ARGS_initialize_fixed_size_pools __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_mark_special __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools) \
     , PARROT_ASSERT_ARG(obj))
 #define ASSERT_ARGS_Parrot_add_to_free_list __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -380,27 +408,33 @@
     , 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(mem_pools) \
     , 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) \
     , PARROT_ASSERT_ARG(pool))
 #define ASSERT_ARGS_Parrot_gc_get_attribute_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_Parrot_gc_get_attributes_from_pool \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pool))
 #define ASSERT_ARGS_Parrot_gc_initialize_fixed_size_pools \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_Parrot_gc_run_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_Parrot_gc_sweep_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools) \
     , PARROT_ASSERT_ARG(pool))
 #define ASSERT_ARGS_Parrot_gc_trace_root __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/mark_sweep.c */
 
@@ -454,7 +488,7 @@
         FUNC_MODIFIES(* pool);
 
 void compact_pool(PARROT_INTERP,
-    ARGIN(Memory_Pools *mem_pools),
+    ARGIN(Memory_Pools * const mem_pools),
     ARGMOD(Variable_Size_Pool *pool))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)

Modified: branches/gc_encapsulate_part1/src/gc/mark_sweep.c
==============================================================================
--- branches/gc_encapsulate_part1/src/gc/mark_sweep.c	Mon Feb  8 13:05:53 2010	(r43778)
+++ branches/gc_encapsulate_part1/src/gc/mark_sweep.c	Mon Feb  8 13:27:02 2010	(r43779)
@@ -59,8 +59,10 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static Fixed_Size_Pool * new_bufferlike_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
     size_t actual_buffer_size)
-        __attribute__nonnull__(1);
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
@@ -75,8 +77,11 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static Fixed_Size_Pool * new_string_pool(PARROT_INTERP, INTVAL constant)
-        __attribute__nonnull__(1);
+static Fixed_Size_Pool * new_string_pool(PARROT_INTERP,
+    ARGIN(Memory_Pools * const mem_pools),
+    INTVAL constant)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 static void Parrot_gc_allocate_new_attributes_arena(PARROT_INTERP,
     ARGMOD(PMC_Attribute_Pool *pool))
@@ -100,12 +105,14 @@
     , PARROT_ASSERT_ARG(mem_pools) \
     , PARROT_ASSERT_ARG(p))
 #define ASSERT_ARGS_new_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_new_fixed_size_obj_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #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))
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_Parrot_gc_allocate_new_attributes_arena \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -120,7 +127,7 @@
 
 /*
 
-=item C<void Parrot_gc_run_init(PARROT_INTERP)>
+=item C<void Parrot_gc_run_init(PARROT_INTERP, Memory_Pools * const mem_pools)>
 
 Prepares the collector for a mark & sweep GC run. Initializes the various
 fields in the Memory_Pools structure that need to be zeroed out prior to the
@@ -131,10 +138,10 @@
 */
 
 void
-Parrot_gc_run_init(PARROT_INTERP)
+Parrot_gc_run_init(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools))
 {
     ASSERT_ARGS(Parrot_gc_run_init)
-    Memory_Pools * const mem_pools       = interp->mem_pools;
 
     mem_pools->gc_trace_ptr        = NULL;
     mem_pools->gc_mark_start       = NULL;
@@ -143,7 +150,8 @@
 
 /*
 
-=item C<int Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)>
+=item C<int Parrot_gc_trace_root(PARROT_INTERP, Memory_Pools * const mem_pools,
+Parrot_gc_trace_type trace)>
 
 Traces the root set with behavior that's dependent on the flags passed.
 Returns 0 if it's a lazy GC run and all objects that need timely destruction
@@ -172,10 +180,11 @@
 */
 
 int
-Parrot_gc_trace_root(PARROT_INTERP, Parrot_gc_trace_type trace)
+Parrot_gc_trace_root(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        Parrot_gc_trace_type trace)
 {
     ASSERT_ARGS(Parrot_gc_trace_root)
-    Memory_Pools  * const mem_pools = interp->mem_pools;
     PObj    *obj;
 
     /* note: adding locals here did cause increased GC runs */
@@ -256,7 +265,8 @@
 
 /*
 
-=item C<void Parrot_gc_sweep_pool(PARROT_INTERP, Fixed_Size_Pool *pool)>
+=item C<void Parrot_gc_sweep_pool(PARROT_INTERP, Memory_Pools * const mem_pools,
+Fixed_Size_Pool *pool)>
 
 Puts any buffers/PMCs that are marked as "dead" or "black" onto the pool
 free list.
@@ -266,7 +276,9 @@
 */
 
 void
-Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Fixed_Size_Pool *pool))
+Parrot_gc_sweep_pool(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        ARGMOD(Fixed_Size_Pool *pool))
 {
     ASSERT_ARGS(Parrot_gc_sweep_pool)
 
@@ -312,9 +324,9 @@
                 }
 
                 if (gc_object)
-                    gc_object(interp, interp->mem_pools, pool, b);
+                    gc_object(interp, mem_pools, pool, b);
 
-                pool->add_free_object(interp, interp->mem_pools, pool, b);
+                pool->add_free_object(interp, mem_pools, pool, b);
             }
 next:
             b = (PObj *)((char *)b + object_size);
@@ -359,7 +371,8 @@
 
 /*
 
-=item C<void mark_special(PARROT_INTERP, PMC *obj)>
+=item C<void mark_special(PARROT_INTERP, Memory_Pools * const mem_pools, PMC
+*obj)>
 
 Handles marking a PMC. Specifically, calls the VTABLE_mark for that PMC
 if one is present. Also handles marking shared PMCs.
@@ -369,7 +382,9 @@
 */
 
 void
-mark_special(PARROT_INTERP, ARGIN(PMC *obj))
+mark_special(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        ARGIN(PMC *obj))
 {
     ASSERT_ARGS(mark_special)
 
@@ -388,8 +403,8 @@
         interp = PMC_sync(obj)->owner;
         PARROT_ASSERT(interp);
 
-        if (!interp->mem_pools->gc_mark_ptr)
-            interp->mem_pools->gc_mark_ptr = obj;
+        if (!mem_pools->gc_mark_ptr)
+            mem_pools->gc_mark_ptr = obj;
     }
 
     PObj_get_FLAGS(obj) |= PObj_custom_GC_FLAG;
@@ -486,8 +501,8 @@
 
 /*
 
-=item C<void Parrot_append_arena_in_pool(PARROT_INTERP, Fixed_Size_Pool *pool,
-Fixed_Size_Arena *new_arena, size_t size)>
+=item C<void Parrot_append_arena_in_pool(PARROT_INTERP, Memory_Pools * const
+mem_pools, Fixed_Size_Pool *pool, Fixed_Size_Arena *new_arena, size_t size)>
 
 Insert the new arena into the pool's structure. Arenas are stored in a
 linked list, so add the new arena to the list. Set information in the
@@ -499,8 +514,9 @@
 
 void
 Parrot_append_arena_in_pool(PARROT_INTERP,
-    ARGMOD(Fixed_Size_Pool *pool),
-    ARGMOD(Fixed_Size_Arena *new_arena), size_t size)
+        ARGIN(Memory_Pools * const mem_pools),
+        ARGMOD(Fixed_Size_Pool *pool),
+        ARGMOD(Fixed_Size_Arena *new_arena), size_t size)
 {
     ASSERT_ARGS(Parrot_append_arena_in_pool)
 
@@ -522,7 +538,7 @@
         new_arena->prev->next = new_arena;
 
     pool->last_Arena = new_arena;
-    interp->mem_pools->header_allocs_since_last_collect++;
+    mem_pools->header_allocs_since_last_collect++;
 }
 
 /*
@@ -581,7 +597,6 @@
 
     /* TODO collect objects with finalizers */
     if (PObj_needs_early_gc_TEST(p)) {
-        Memory_Pools * const mem_pools = interp->mem_pools;
         --mem_pools->num_early_gc_PMCs;
     }
 
@@ -591,8 +606,8 @@
 
 /*
 
-=item C<static Fixed_Size_Pool * new_bufferlike_pool(PARROT_INTERP, size_t
-actual_buffer_size)>
+=item C<static Fixed_Size_Pool * new_bufferlike_pool(PARROT_INTERP, Memory_Pools
+* const mem_pools, size_t actual_buffer_size)>
 
 Creates a new pool for buffer-like structures. This is called from
 C<get_bufferlike_pool()>, and should probably not be called directly.
@@ -604,7 +619,9 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static Fixed_Size_Pool *
-new_bufferlike_pool(PARROT_INTERP, size_t actual_buffer_size)
+new_bufferlike_pool(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        size_t actual_buffer_size)
 {
     ASSERT_ARGS(new_bufferlike_pool)
     const int num_headers          = BUFFER_HEADERS_PER_ALLOC;
@@ -615,7 +632,7 @@
 
     pool->gc_object = (gc_object_fn_type)free_buffer;
 
-    pool->mem_pool  = interp->mem_pools->memory_pool;
+    pool->mem_pool  = mem_pools->memory_pool;
     (interp->gc_sys->init_pool)(interp, pool);
     return pool;
 }
@@ -657,8 +674,8 @@
 
 /*
 
-=item C<static Fixed_Size_Pool * new_string_pool(PARROT_INTERP, INTVAL
-constant)>
+=item C<static Fixed_Size_Pool * new_string_pool(PARROT_INTERP, Memory_Pools *
+const mem_pools, INTVAL constant)>
 
 Creates a new pool for C<STRING>s and returns it. This calls
 C<get_bufferlike_pool> internally, which in turn calls C<new_bufferlike_pool>.
@@ -670,17 +687,19 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static Fixed_Size_Pool *
-new_string_pool(PARROT_INTERP, INTVAL constant)
+new_string_pool(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        INTVAL constant)
 {
     ASSERT_ARGS(new_string_pool)
     Fixed_Size_Pool *pool;
     if (constant) {
-        pool           = new_bufferlike_pool(interp, sizeof (STRING));
+        pool           = new_bufferlike_pool(interp, mem_pools, sizeof (STRING));
         pool->gc_object = NULL;
-        pool->mem_pool = interp->mem_pools->constant_string_pool;
+        pool->mem_pool = mem_pools->constant_string_pool;
     }
     else
-        pool = get_bufferlike_pool(interp, sizeof (STRING));
+        pool = get_bufferlike_pool(interp, mem_pools, sizeof (STRING));
 
     pool->objects_per_alloc = STRING_HEADERS_PER_ALLOC;
 
@@ -759,8 +778,8 @@
 
 /*
 
-=item C<Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, size_t
-buffer_size)>
+=item C<Fixed_Size_Pool * get_bufferlike_pool(PARROT_INTERP, Memory_Pools *
+const mem_pools, size_t buffer_size)>
 
 Makes and return a bufferlike header pool for objects of a given size. If a
 pool for objects of that size already exists, no new pool will be created and
@@ -773,11 +792,13 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 Fixed_Size_Pool *
-get_bufferlike_pool(PARROT_INTERP, size_t buffer_size)
+get_bufferlike_pool(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        size_t buffer_size)
 {
     ASSERT_ARGS(get_bufferlike_pool)
-    Fixed_Size_Pool **sized_pools = interp->mem_pools->sized_header_pools;
-    const UINTVAL       num_old     = interp->mem_pools->num_sized;
+    Fixed_Size_Pool **sized_pools   = mem_pools->sized_header_pools;
+    const UINTVAL       num_old     = mem_pools->num_sized;
     const UINTVAL       idx         = GET_SIZED_POOL_IDX(buffer_size);
 
     /* Expands the array of sized resource pools, if necessary */
@@ -791,19 +812,20 @@
                                            num_new * sizeof (void *));
         memset(sized_pools + num_old, 0, sizeof (void *) * (num_new - num_old));
 
-        interp->mem_pools->sized_header_pools = sized_pools;
-        interp->mem_pools->num_sized = num_new;
+        mem_pools->sized_header_pools = sized_pools;
+        mem_pools->num_sized = num_new;
     }
 
     if (sized_pools[idx] == NULL)
-        sized_pools[idx] = new_bufferlike_pool(interp, buffer_size);
+        sized_pools[idx] = new_bufferlike_pool(interp, mem_pools, buffer_size);
 
     return sized_pools[idx];
 }
 
 /*
 
-=item C<void initialize_fixed_size_pools(PARROT_INTERP)>
+=item C<void initialize_fixed_size_pools(PARROT_INTERP, Memory_Pools * const
+mem_pools)>
 
 The initialization routine for the interpreter's header pools. Initializes
 pools for string headers, constant string headers, buffers, PMCs and
@@ -817,13 +839,13 @@
 */
 
 void
-initialize_fixed_size_pools(PARROT_INTERP)
+initialize_fixed_size_pools(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools))
 {
     ASSERT_ARGS(initialize_fixed_size_pools)
-    Memory_Pools * const mem_pools                     = interp->mem_pools;
 
     /* Init the constant string header pool */
-    mem_pools->constant_string_header_pool       = new_string_pool(interp, 1);
+    mem_pools->constant_string_header_pool       = new_string_pool(interp, mem_pools, 1);
     mem_pools->constant_string_header_pool->name = "constant_string_header";
     mem_pools->constant_string_header_pool->skip = GC_ALWAYS_SKIP;
 
@@ -834,7 +856,7 @@
      * new_*_header */
 
     /* Init the string header pool */
-    mem_pools->string_header_pool       = new_string_pool(interp, 0);
+    mem_pools->string_header_pool       = new_string_pool(interp, mem_pools, 0);
     mem_pools->string_header_pool->name = "string_header";
 
     /* Init the PMC header pool */
@@ -852,8 +874,8 @@
 
 /*
 
-=item C<int header_pools_iterate_callback(PARROT_INTERP, int flag, void *arg,
-pool_iter_fn func)>
+=item C<int header_pools_iterate_callback(PARROT_INTERP, Memory_Pools * const
+mem_pools, int flag, void *arg, pool_iter_fn func)>
 
 Iterates through header pools, invoking the given callback function on each
 pool in the list matching the given criteria. Determines which pools to iterate
@@ -892,18 +914,19 @@
 
 PARROT_IGNORABLE_RESULT
 int
-header_pools_iterate_callback(PARROT_INTERP, int flag, ARGIN_NULLOK(void *arg),
+header_pools_iterate_callback(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        int flag, ARGIN_NULLOK(void *arg),
         NOTNULL(pool_iter_fn func))
 {
     ASSERT_ARGS(header_pools_iterate_callback)
-    Memory_Pools * const mem_pools = interp->mem_pools;
 
     if (flag & POOL_PMC) {
         Fixed_Size_Pool *pool = flag & POOL_CONST
             ? mem_pools->constant_pmc_pool
             : mem_pools->pmc_pool;
 
-        const int ret_val = (func)(interp, interp->mem_pools, pool,
+        const int ret_val = (func)(interp, mem_pools, pool,
             flag & (POOL_PMC | POOL_CONST) , arg);
 
         if (ret_val)
@@ -914,7 +937,7 @@
         INTVAL i;
 
         if (flag & POOL_CONST) {
-            const int ret_val = (func)(interp, interp->mem_pools,
+            const int ret_val = (func)(interp, mem_pools,
                 mem_pools->constant_string_header_pool,
                 POOL_BUFFER | POOL_CONST, arg);
 
@@ -922,11 +945,11 @@
                 return ret_val;
         }
 
-        for (i = interp->mem_pools->num_sized - 1; i >= 0; --i) {
+        for (i = mem_pools->num_sized - 1; i >= 0; --i) {
             Fixed_Size_Pool * const pool = mem_pools->sized_header_pools[i];
 
             if (pool) {
-                const int ret_val = (func)(interp, interp->mem_pools, pool, POOL_BUFFER, arg);
+                const int ret_val = (func)(interp, mem_pools, pool, POOL_BUFFER, arg);
                 if (ret_val)
                     return ret_val;
             }
@@ -951,13 +974,13 @@
 
 Allocate a new arena of fixed-sized data structures for the given pool.
 
-=item C<void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP, size_t
-init_num_pools)>
+=item C<void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP, Memory_Pools *
+const mem_pools, size_t init_num_pools)>
 
 Initialize the pools (zeroize)
 
-=item C<PMC_Attribute_Pool * Parrot_gc_get_attribute_pool(PARROT_INTERP, size_t
-attrib_size)>
+=item C<PMC_Attribute_Pool * Parrot_gc_get_attribute_pool(PARROT_INTERP,
+Memory_Pools * const mem_pools, size_t attrib_size)>
 
 Find a fixed-sized data structure pool given the size of the object to
 allocate. If the pool does not exist, create it.
@@ -1046,10 +1069,11 @@
 }
 
 void
-Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP, size_t init_num_pools)
+Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        size_t init_num_pools)
 {
     ASSERT_ARGS(Parrot_gc_initialize_fixed_size_pools)
-    Memory_Pools       * const mem_pools = interp->mem_pools;
     PMC_Attribute_Pool **pools;
     const size_t total_size = (init_num_pools + 1) * sizeof (void *);
 
@@ -1063,11 +1087,12 @@
 
 PARROT_CANNOT_RETURN_NULL
 PMC_Attribute_Pool *
-Parrot_gc_get_attribute_pool(PARROT_INTERP, size_t attrib_size)
+Parrot_gc_get_attribute_pool(PARROT_INTERP,
+        ARGIN(Memory_Pools * const mem_pools),
+        size_t attrib_size)
 {
     ASSERT_ARGS(Parrot_gc_get_attribute_pool)
 
-    Memory_Pools       * const mem_pools = interp->mem_pools;
     PMC_Attribute_Pool **pools = mem_pools->attrib_pools;
     const size_t         idx   = (attrib_size < sizeof (void *))
                                ? 0


More information about the parrot-commits mailing list