[svn:parrot] r38839 - in trunk: compilers/imcc src/gc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat May 16 20:41:54 UTC 2009


Author: whiteknight
Date: Sat May 16 20:41:54 2009
New Revision: 38839
URL: https://trac.parrot.org/parrot/changeset/38839

Log:
[gc] rearrange some functions that a pool-related and not ms-related

Modified:
   trunk/compilers/imcc/imcparser.c
   trunk/src/gc/gc_private.h
   trunk/src/gc/mark_sweep.c
   trunk/src/gc/pools.c

Modified: trunk/compilers/imcc/imcparser.c
==============================================================================
--- trunk/compilers/imcc/imcparser.c	Sat May 16 20:35:04 2009	(r38838)
+++ trunk/compilers/imcc/imcparser.c	Sat May 16 20:41:54 2009	(r38839)
@@ -368,8 +368,8 @@
 
 static void add_pcc_named_arg(PARROT_INTERP,
     ARGMOD(SymReg *cur_call),
-    ARGIN(SymReg  *name),
-    ARGIN(SymReg  *value))
+    ARGIN(SymReg *name),
+    ARGIN(SymReg *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
@@ -378,8 +378,8 @@
 
 static void add_pcc_named_arg_var(PARROT_INTERP,
     ARGMOD(SymReg *cur_call),
-    ARGIN(SymReg  *name),
-    ARGIN(SymReg  *value))
+    ARGIN(SymReg *name),
+    ARGIN(SymReg *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
@@ -388,8 +388,8 @@
 
 static void add_pcc_named_param(PARROT_INTERP,
     ARGMOD(SymReg *cur_call),
-    ARGIN(SymReg  *name),
-    ARGIN(SymReg  *value))
+    ARGIN(SymReg *name),
+    ARGIN(SymReg *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
@@ -398,8 +398,8 @@
 
 static void add_pcc_named_result(PARROT_INTERP,
     ARGMOD(SymReg *cur_call),
-    ARGIN(SymReg  *name),
-    ARGIN(SymReg  *value))
+    ARGIN(SymReg *name),
+    ARGIN(SymReg *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
@@ -408,8 +408,8 @@
 
 static void add_pcc_named_return(PARROT_INTERP,
     ARGMOD(SymReg *cur_call),
-    ARGIN(SymReg  *name),
-    ARGIN(SymReg  *value))
+    ARGIN(SymReg *name),
+    ARGIN(SymReg *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)
@@ -1194,8 +1194,8 @@
 
 /*
 
-=item C<static void add_pcc_named_arg(PARROT_INTERP, SymReg *cur_call, const
-char *name, SymReg *value)>
+=item C<static void add_pcc_named_arg(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
 
 =cut
 
@@ -1234,8 +1234,8 @@
 
 /*
 
-=item C<static void add_pcc_named_result(PARROT_INTERP, SymReg *cur_call, const
-char *name, SymReg *value)>
+=item C<static void add_pcc_named_result(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
 
 =cut
 
@@ -1255,7 +1255,7 @@
 
 /*
 
-=item C<static void add_pcc_named_param(PARROT_INTERP, SymReg *cur_call, SymReg 
+=item C<static void add_pcc_named_param(PARROT_INTERP, SymReg *cur_call, SymReg
 *name, SymReg *value)>
 
 =cut
@@ -1276,8 +1276,8 @@
 
 /*
 
-=item C<static void add_pcc_named_return(PARROT_INTERP, SymReg *cur_call, const
-char *name, SymReg *value)>
+=item C<static void add_pcc_named_return(PARROT_INTERP, SymReg *cur_call, SymReg
+*name, SymReg *value)>
 
 =cut
 
@@ -1297,7 +1297,7 @@
 
 /*
 
-=item C<static void adv_named_set(PARROT_INTERP, char *name)>
+=item C<static void adv_named_set(PARROT_INTERP, const char *name)>
 
 Sets the name of the current named argument.
 

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Sat May 16 20:35:04 2009	(r38838)
+++ trunk/src/gc/gc_private.h	Sat May 16 20:41:54 2009	(r38839)
@@ -322,12 +322,6 @@
         __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))
@@ -377,15 +371,6 @@
         __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);
-
 int trace_active_PMCs(PARROT_INTERP, Parrot_gc_trace_type trace)
         __attribute__nonnull__(1);
 
@@ -395,7 +380,6 @@
 #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) \
@@ -422,11 +406,6 @@
 #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)
 #define ASSERT_ARGS_trace_active_PMCs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -515,6 +494,15 @@
         __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_free_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(pool)
 #define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -553,6 +541,11 @@
 #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_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/pools.c */
 

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Sat May 16 20:35:04 2009	(r38838)
+++ trunk/src/gc/mark_sweep.c	Sat May 16 20:41:54 2009	(r38839)
@@ -687,114 +687,6 @@
 
 /*
 
-=item C<Small_Object_Pool * new_small_object_pool(size_t object_size, size_t
-objects_per_alloc)>
-
-Creates a new C<Small_Object_Pool> and returns a pointer to it.
-Initializes the pool structure based on the size of objects in the
-pool and the number of items to allocate in each arena.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-Small_Object_Pool *
-new_small_object_pool(size_t object_size, size_t objects_per_alloc)
-{
-    ASSERT_ARGS(new_small_object_pool)
-    Small_Object_Pool * const pool =
-        mem_internal_allocate_zeroed_typed(Small_Object_Pool);
-
-    pool->last_Arena        = NULL;
-    pool->free_list         = NULL;
-    pool->mem_pool          = NULL;
-    pool->object_size       = object_size;
-    pool->objects_per_alloc = objects_per_alloc;
-
-    return pool;
-}
-
-
-/*
-
-=item C<void Parrot_small_object_pool_merge(PARROT_INTERP, Small_Object_Pool
-*dest, Small_Object_Pool *source)>
-
-Merge pool C<source> into pool C<dest>. Combines the free lists directly,
-moves all arenas to the new pool, and remove the old pool. To merge, the
-two pools must have the same object size, and the same name (if they have
-names).
-
-=cut
-
-*/
-
-void
-Parrot_small_object_pool_merge(PARROT_INTERP,
-        ARGMOD(Small_Object_Pool *dest), ARGMOD(Small_Object_Pool *source))
-{
-    ASSERT_ARGS(Parrot_small_object_pool_merge)
-    Small_Object_Arena  *cur_arena;
-    void               **free_list_end;
-
-    /* XXX num_free_objects doesn't seem to be accounted correctly in, e.g.,
-     * the PMC_EXT pool.
-     */
-#if 0
-    if (source->num_free_objects == source->total_objects) {
-        return;
-    }
-#endif
-
-    /* PARROT_ASSERT(source->total_objects); */
-    PARROT_ASSERT(dest->object_size == source->object_size);
-    PARROT_ASSERT((dest->name == NULL && source->name == NULL)
-                || STREQ(dest->name, source->name));
-
-    dest->total_objects += source->total_objects;
-
-    /* append new free_list to old */
-    /* XXX this won't work with, e.g., gc_gms */
-    free_list_end  = &dest->free_list;
-
-    while (*free_list_end)
-        free_list_end = (void **)*free_list_end;
-
-    *free_list_end = source->free_list;
-
-    /* now append source arenas */
-    cur_arena = source->last_Arena;
-
-    while (cur_arena) {
-        size_t                     total_objects;
-        Small_Object_Arena * const next_arena = cur_arena->prev;
-
-        cur_arena->next = cur_arena->prev = NULL;
-
-        total_objects   = cur_arena->total_objects;
-
-        Parrot_append_arena_in_pool(interp, dest, cur_arena,
-            cur_arena->total_objects);
-
-        /* XXX needed? */
-        cur_arena->total_objects = total_objects;
-
-        cur_arena = next_arena;
-    }
-
-    /* remove things from source */
-    /* XXX is this enough? */
-    source->last_Arena       = NULL;
-    source->free_list        = NULL;
-    source->total_objects    = 0;
-    source->num_free_objects = 0;
-}
-
-
-/*
-
 =back
 
 =head1 SEE ALSO

Modified: trunk/src/gc/pools.c
==============================================================================
--- trunk/src/gc/pools.c	Sat May 16 20:35:04 2009	(r38838)
+++ trunk/src/gc/pools.c	Sat May 16 20:41:54 2009	(r38839)
@@ -22,6 +22,12 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
+PARROT_MALLOC
+PARROT_CANNOT_RETURN_NULL
+static Small_Object_Pool * new_small_object_pool(
+    size_t object_size,
+    size_t objects_per_alloc);
+
 static void Parrot_gc_free_buffer(SHIM_INTERP,
     ARGMOD(Small_Object_Pool *pool),
     ARGMOD(PObj *b))
@@ -36,6 +42,7 @@
         __attribute__nonnull__(3)
         FUNC_MODIFIES(*b);
 
+#define ASSERT_ARGS_new_small_object_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_Parrot_gc_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(pool) \
     || PARROT_ASSERT_ARG(b)
@@ -88,6 +95,82 @@
 
 /*
 
+=item C<void Parrot_small_object_pool_merge(PARROT_INTERP, Small_Object_Pool
+*dest, Small_Object_Pool *source)>
+
+Merge pool C<source> into pool C<dest>. Combines the free lists directly,
+moves all arenas to the new pool, and remove the old pool. To merge, the
+two pools must have the same object size, and the same name (if they have
+names).
+
+=cut
+
+*/
+
+void
+Parrot_small_object_pool_merge(PARROT_INTERP,
+        ARGMOD(Small_Object_Pool *dest), ARGMOD(Small_Object_Pool *source))
+{
+    ASSERT_ARGS(Parrot_small_object_pool_merge)
+    Small_Object_Arena  *cur_arena;
+    void               **free_list_end;
+
+    /* XXX num_free_objects doesn't seem to be accounted correctly in, e.g.,
+     * the PMC_EXT pool.
+     */
+#if 0
+    if (source->num_free_objects == source->total_objects) {
+        return;
+    }
+#endif
+
+    /* PARROT_ASSERT(source->total_objects); */
+    PARROT_ASSERT(dest->object_size == source->object_size);
+    PARROT_ASSERT((dest->name == NULL && source->name == NULL)
+                || STREQ(dest->name, source->name));
+
+    dest->total_objects += source->total_objects;
+
+    /* append new free_list to old */
+    /* XXX this won't work with, e.g., gc_gms */
+    free_list_end  = &dest->free_list;
+
+    while (*free_list_end)
+        free_list_end = (void **)*free_list_end;
+
+    *free_list_end = source->free_list;
+
+    /* now append source arenas */
+    cur_arena = source->last_Arena;
+
+    while (cur_arena) {
+        size_t                     total_objects;
+        Small_Object_Arena * const next_arena = cur_arena->prev;
+
+        cur_arena->next = cur_arena->prev = NULL;
+
+        total_objects   = cur_arena->total_objects;
+
+        Parrot_append_arena_in_pool(interp, dest, cur_arena,
+            cur_arena->total_objects);
+
+        /* XXX needed? */
+        cur_arena->total_objects = total_objects;
+
+        cur_arena = next_arena;
+    }
+
+    /* remove things from source */
+    /* XXX is this enough? */
+    source->last_Arena       = NULL;
+    source->free_list        = NULL;
+    source->total_objects    = 0;
+    source->num_free_objects = 0;
+}
+
+
+/*
+
 =item C<void * get_free_buffer(PARROT_INTERP, Small_Object_Pool *pool)>
 
 Gets a free object or buffer from the given C<pool> and returns it.  If the
@@ -182,6 +265,38 @@
     return pool;
 }
 
+/*
+
+=item C<static Small_Object_Pool * new_small_object_pool(size_t object_size,
+size_t objects_per_alloc)>
+
+Creates a new C<Small_Object_Pool> and returns a pointer to it.
+Initializes the pool structure based on the size of objects in the
+pool and the number of items to allocate in each arena.
+
+=cut
+
+*/
+
+PARROT_MALLOC
+PARROT_CANNOT_RETURN_NULL
+static Small_Object_Pool *
+new_small_object_pool(size_t object_size, size_t objects_per_alloc)
+{
+    ASSERT_ARGS(new_small_object_pool)
+    Small_Object_Pool * const pool =
+        mem_internal_allocate_zeroed_typed(Small_Object_Pool);
+
+    pool->last_Arena        = NULL;
+    pool->free_list         = NULL;
+    pool->mem_pool          = NULL;
+    pool->object_size       = object_size;
+    pool->objects_per_alloc = objects_per_alloc;
+
+    return pool;
+}
+
+
 
 /*
 


More information about the parrot-commits mailing list