[svn:parrot] r38578 - in branches/gc_api: include/parrot src/gc src/interp

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Fri May 8 01:47:16 UTC 2009


Author: whiteknight
Date: Fri May  8 01:47:15 2009
New Revision: 38578
URL: https://trac.parrot.org/parrot/changeset/38578

Log:
[gc_api] move the subsystem initialization routine (now named Parrot_gc_initialize) to the API, and move a lot of function prototypes to the gc_private.h header file where they are hidden from the rest of Parrot

Modified:
   branches/gc_api/include/parrot/gc_api.h
   branches/gc_api/include/parrot/memory.h
   branches/gc_api/src/gc/api.c
   branches/gc_api/src/gc/gc_private.h
   branches/gc_api/src/gc/generational_ms.c
   branches/gc_api/src/gc/incremental_ms.c
   branches/gc_api/src/gc/mark_sweep.c
   branches/gc_api/src/gc/memory.c
   branches/gc_api/src/interp/inter_create.c

Modified: branches/gc_api/include/parrot/gc_api.h
==============================================================================
--- branches/gc_api/include/parrot/gc_api.h	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/include/parrot/gc_api.h	Fri May  8 01:47:15 2009	(r38578)
@@ -55,9 +55,6 @@
 /* HEADERIZER BEGIN: src/gc/api.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
-        __attribute__nonnull__(1);
-
 void Parrot_gc_add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -80,6 +77,9 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*p);
 
+void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
+        __attribute__nonnull__(1);
+
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 void * Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size)
@@ -95,8 +95,6 @@
 STRING * Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 
-#define ASSERT_ARGS_Parrot_gc_mark_and_sweep __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)
@@ -110,6 +108,8 @@
 #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_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_gc_new_bufferlike_header \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)

Modified: branches/gc_api/include/parrot/memory.h
==============================================================================
--- branches/gc_api/include/parrot/memory.h	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/include/parrot/memory.h	Fri May  8 01:47:15 2009	(r38578)
@@ -111,7 +111,7 @@
     int line)
         __attribute__nonnull__(4);
 
-void mem_setup_allocator(PARROT_INTERP, ARGIN(void *stacktop))
+void Parrot_gc_initialize(PARROT_INTERP, ARGIN(void *stacktop))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -130,7 +130,7 @@
        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 = \
+#define ASSERT_ARGS_Parrot_gc_initialize __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. */

Modified: branches/gc_api/src/gc/api.c
==============================================================================
--- branches/gc_api/src/gc/api.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/api.c	Fri May  8 01:47:15 2009	(r38578)
@@ -49,6 +49,45 @@
 
 /*
 
+=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<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

Modified: branches/gc_api/src/gc/gc_private.h
==============================================================================
--- branches/gc_api/src/gc/gc_private.h	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/gc_private.h	Fri May  8 01:47:15 2009	(r38578)
@@ -59,6 +59,217 @@
 /* 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_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 = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_parrot_gc_gms_pobject_lives __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_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_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_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_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 */
+
 #endif /* PARROT_GC_PRIVATE_H_GUARD */
 
 /*

Modified: branches/gc_api/src/gc/generational_ms.c
==============================================================================
--- branches/gc_api/src/gc/generational_ms.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/generational_ms.c	Fri May  8 01:47:15 2009	(r38578)
@@ -120,7 +120,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. */

Modified: branches/gc_api/src/gc/incremental_ms.c
==============================================================================
--- branches/gc_api/src/gc/incremental_ms.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/incremental_ms.c	Fri May  8 01:47:15 2009	(r38578)
@@ -332,7 +332,7 @@
 #include "parrot/gc_api.h"
 #include "parrot/gc_mark_sweep.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. */

Modified: branches/gc_api/src/gc/mark_sweep.c
==============================================================================
--- branches/gc_api/src/gc/mark_sweep.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/mark_sweep.c	Fri May  8 01:47:15 2009	(r38578)
@@ -23,7 +23,7 @@
 #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. */

Modified: branches/gc_api/src/gc/memory.c
==============================================================================
--- branches/gc_api/src/gc/memory.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/gc/memory.c	Fri May  8 01:47:15 2009	(r38578)
@@ -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: branches/gc_api/src/interp/inter_create.c
==============================================================================
--- branches/gc_api/src/interp/inter_create.c	Fri May  8 01:37:36 2009	(r38577)
+++ branches/gc_api/src/interp/inter_create.c	Fri May  8 01:47:15 2009	(r38578)
@@ -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);
 


More information about the parrot-commits mailing list