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

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat May 9 15:05:33 UTC 2009


Author: whiteknight
Date: Sat May  9 15:05:32 2009
New Revision: 38645
URL: https://trac.parrot.org/parrot/changeset/38645

Log:
[gc_api] some basic cleanups. Rename some stuff to be better, documentation, fix some mis-matched data types

Modified:
   branches/gc_api/include/parrot/gc_api.h
   branches/gc_api/src/gc/api.c
   branches/gc_api/src/gc/res_lea.c
   branches/gc_api/src/list.c

Modified: branches/gc_api/include/parrot/gc_api.h
==============================================================================
--- branches/gc_api/include/parrot/gc_api.h	Sat May  9 14:53:36 2009	(r38644)
+++ branches/gc_api/include/parrot/gc_api.h	Sat May  9 15:05:32 2009	(r38645)
@@ -151,11 +151,11 @@
         FUNC_MODIFIES(*obj);
 
 PARROT_EXPORT
-int Parrot_is_blocked_GC_mark(PARROT_INTERP)
+unsigned int Parrot_is_blocked_GC_mark(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 PARROT_EXPORT
-int Parrot_is_blocked_GC_sweep(PARROT_INTERP)
+unsigned int Parrot_is_blocked_GC_sweep(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 PARROT_EXPORT
@@ -182,7 +182,7 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
-void Parrot_gc_allocate_aligned(PARROT_INTERP,
+void Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP,
     ARGOUT(Buffer *buffer),
     size_t size)
         __attribute__nonnull__(1)
@@ -205,13 +205,13 @@
 void Parrot_gc_completely_unblock(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_count_collect_runs(PARROT_INTERP)
+size_t Parrot_gc_count_collect_runs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)
+size_t Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_count_mark_runs(PARROT_INTERP)
+size_t Parrot_gc_count_mark_runs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 void Parrot_gc_destroy_header_pools(PARROT_INTERP)
@@ -220,7 +220,7 @@
 void Parrot_gc_destroy_memory_pools(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_extended_pmcs(PARROT_INTERP)
+UINTVAL Parrot_gc_extended_pmcs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 void Parrot_gc_finalize(PARROT_INTERP)
@@ -252,10 +252,10 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-int Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
+size_t Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_impatient_pmcs(PARROT_INTERP)
+UINTVAL Parrot_gc_impatient_pmcs(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 void Parrot_gc_initialize(PARROT_INTERP, ARGIN(void *stacktop))
@@ -265,7 +265,7 @@
 void Parrot_gc_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
         __attribute__nonnull__(1);
 
-int Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)
+size_t Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 void Parrot_gc_merge_header_pools(
@@ -304,6 +304,13 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+void Parrot_gc_reallocate_buffer_storage(PARROT_INTERP,
+    ARGMOD(Buffer *buffer),
+    size_t newsize)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
+
 void Parrot_gc_reallocate_string_storage(PARROT_INTERP,
     ARGMOD(STRING *str),
     size_t newsize)
@@ -311,10 +318,10 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*str);
 
-int Parrot_gc_total_copied(PARROT_INTERP)
+UINTVAL Parrot_gc_total_copied(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-int Parrot_gc_total_memory_allocated(PARROT_INTERP)
+size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 int Parrot_gc_total_pmcs(PARROT_INTERP)
@@ -323,13 +330,6 @@
 int Parrot_gc_total_sized_buffers(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void Parrot_reallocate(PARROT_INTERP,
-    ARGMOD(Buffer *buffer),
-    size_t newsize)
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*buffer);
-
 #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 = \
@@ -356,7 +356,8 @@
 #define ASSERT_ARGS_Parrot_gc_add_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pmc)
-#define ASSERT_ARGS_Parrot_gc_allocate_aligned __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+#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 \
@@ -435,6 +436,10 @@
 #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) \
@@ -448,9 +453,6 @@
        PARROT_ASSERT_ARG(interp)
 #define ASSERT_ARGS_Parrot_gc_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_reallocate __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(buffer)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/api.c */
 

Modified: branches/gc_api/src/gc/api.c
==============================================================================
--- branches/gc_api/src/gc/api.c	Sat May  9 14:53:36 2009	(r38644)
+++ branches/gc_api/src/gc/api.c	Sat May  9 15:05:32 2009	(r38645)
@@ -239,6 +239,8 @@
 
 =item C<void Parrot_gc_free_pmc_header(PARROT_INTERP, PMC *pmc)>
 
+Adds the given PMC to the free list for later reuse.
+
 =cut
 
 */
@@ -265,6 +267,8 @@
 
 =item C<void Parrot_gc_free_string_header(PARROT_INTERP, STRING *s)>
 
+Adds the given STRING to the free list for later reuse.
+
 =cut
 
 */
@@ -703,8 +707,8 @@
 
 /*
 
-=item C<void Parrot_gc_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)>
 
 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>,
@@ -715,9 +719,10 @@
 */
 
 void
-Parrot_gc_allocate_aligned(PARROT_INTERP, ARGOUT(Buffer *buffer), size_t size)
+Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP,
+    ARGOUT(Buffer *buffer), size_t size)
 {
-    ASSERT_ARGS(Parrot_gc_allocate_aligned)
+    ASSERT_ARGS(Parrot_gc_allocate_buffer_storage_aligned)
     size_t new_size;
     char *mem;
 
@@ -748,7 +753,8 @@
 */
 
 void
-Parrot_gc_allocate_string_storage(PARROT_INTERP, ARGOUT(STRING *str), size_t size)
+Parrot_gc_allocate_string_storage(PARROT_INTERP, ARGOUT(STRING *str),
+    size_t size)
 {
     ASSERT_ARGS(Parrot_gc_allocate_string_storage)
     size_t       new_size;
@@ -779,7 +785,8 @@
 
 /*
 
-=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)>
 
 Reallocate the Buffer's buffer memory to the given size. The
 allocated buffer will not shrink. If the buffer was allocated with
@@ -792,9 +799,10 @@
 */
 
 void
-Parrot_reallocate(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t newsize)
+Parrot_gc_reallocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer),
+    size_t newsize)
 {
-    ASSERT_ARGS(Parrot_reallocate)
+    ASSERT_ARGS(Parrot_gc_reallocate_buffer_storage)
     size_t copysize;
     char  *mem;
     Memory_Pool * const pool = interp->arena_base->memory_pool;
@@ -848,7 +856,6 @@
     PObj_buflen(buffer) = new_size;
 }
 
-
 /*
 
 =item C<void Parrot_gc_compact_memory_pool(PARROT_INTERP)>
@@ -911,7 +918,8 @@
 */
 
 void
-Parrot_gc_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str), size_t newsize)
+Parrot_gc_reallocate_string_storage(PARROT_INTERP, ARGMOD(STRING *str),
+    size_t newsize)
 {
     ASSERT_ARGS(Parrot_gc_reallocate_string_storage)
     size_t copysize;
@@ -1009,7 +1017,8 @@
 
 =item C<void Parrot_gc_cleanup_next_for_GC(PARROT_INTERP)>
 
-Cleans up the C<next_for_GC> pointers.
+Cleans up the C<next_for_GC> pointers. Sets all of them in the PMC and Constant
+PMC pools to NULL.
 
 =cut
 
@@ -1057,6 +1066,9 @@
 
 =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
 
 */
@@ -1119,6 +1131,8 @@
 
 =item C<int Parrot_gc_active_sized_buffers(PARROT_INTERP)>
 
+Returns the number of actively used sized buffers.
+
 =cut
 
 */
@@ -1142,6 +1156,8 @@
 
 =item C<int Parrot_gc_total_sized_buffers(PARROT_INTERP)>
 
+Returns the total number of sized buffers that we are managing.
+
 =cut
 
 */
@@ -1164,6 +1180,8 @@
 
 =item C<int Parrot_gc_active_pmcs(PARROT_INTERP)>
 
+Return the number of actively used PMCs.
+
 =cut
 
 */
@@ -1180,6 +1198,8 @@
 
 =item C<int Parrot_gc_total_pmcs(PARROT_INTERP)>
 
+Return the total number of PMCs that we are managing.
+
 =cut
 
 */
@@ -1193,85 +1213,101 @@
 
 /*
 
-=item C<int Parrot_gc_count_mark_runs(PARROT_INTERP)>
+=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)>
 
-=item C<int Parrot_gc_count_collect_runs(PARROT_INTERP)>
+Return the number of lazy mark runs the GC has performed.
 
-=item C<int Parrot_gc_count_lazy_mark_runs(PARROT_INTERP)>
+=item C<size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)>
 
-=item C<int Parrot_gc_total_memory_allocated(PARROT_INTERP)>
+Return the total number of memory allocations made by the GC.
 
-=item C<int Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)>
+=item C<size_t Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)>
 
-=item C<int Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)>
+Return the number of new headers allocated since the last collection run.
 
-=item C<int Parrot_gc_total_copied(PARROT_INTERP)>
+=item C<size_t Parrot_gc_mem_alloc_since_last_collect(PARROT_INTERP)>
 
-=item C<int Parrot_gc_impatient_pmcs(PARROT_INTERP)>
+Return the number of memory allocations made since the last collection run.
 
-=item C<int Parrot_gc_extended_pmcs(PARROT_INTERP)>
+=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
 
 */
 
-int
+size_t
 Parrot_gc_count_mark_runs(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
     return arena_base->gc_mark_runs;
 }
 
-int
+size_t
 Parrot_gc_count_collect_runs(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
     return arena_base->gc_collect_runs;
 }
 
-int
+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;;
 }
 
-int
+size_t
 Parrot_gc_total_memory_allocated(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
     return arena_base->memory_allocated;
 }
 
-int
+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;
 }
 
-int
+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;
 }
 
-int
+UINTVAL
 Parrot_gc_total_copied(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
     return arena_base->memory_collected;
 }
 
-int
+UINTVAL
 Parrot_gc_impatient_pmcs(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
     return arena_base->num_early_gc_PMCs;
 }
 
-int
+UINTVAL
 Parrot_gc_extended_pmcs(PARROT_INTERP)
 {
     const Arenas * const arena_base = interp->arena_base;
@@ -1282,18 +1318,33 @@
 
 =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)>
 
-=item C<int Parrot_is_blocked_GC_mark(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<int Parrot_is_blocked_GC_sweep(PARROT_INTERP)>
+=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
 
 */
@@ -1332,17 +1383,17 @@
 }
 
 PARROT_EXPORT
-int
+unsigned int
 Parrot_is_blocked_GC_mark(PARROT_INTERP)
 {
-    interp->arena_base->gc_mark_block_level;
+    return interp->arena_base->gc_mark_block_level;
 }
 
 PARROT_EXPORT
-int
+unsigned int
 Parrot_is_blocked_GC_sweep(PARROT_INTERP)
 {
-    interp->arena_base->gc_sweep_block_level;
+    return interp->arena_base->gc_sweep_block_level;
 }
 
 void
@@ -1356,6 +1407,8 @@
 
 =item C<void Parrot_gc_pmc_needs_early_collection(PARROT_INTERP, PMC *pmc)>
 
+Mark a PMC as needing timely destruction
+
 =cut
 
 */
@@ -1371,6 +1424,9 @@
 
 =item C<void Parrot_gc_finalize(PARROT_INTERP)>
 
+Finalize the GC system, if the current GC core has defined a finalization
+routine.
+
 =cut
 
 */

Modified: branches/gc_api/src/gc/res_lea.c
==============================================================================
--- branches/gc_api/src/gc/res_lea.c	Sat May  9 14:53:36 2009	(r38644)
+++ branches/gc_api/src/gc/res_lea.c	Sat May  9 15:05:32 2009	(r38645)
@@ -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_gc_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,7 @@
 
 This was never called anyway, so it isn't implemented here.
 
-=item C<void Parrot_gc_allocate_aligned(PARROT_INTERP, Buffer *buffer,
+=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
@@ -176,7 +176,7 @@
 */
 
 void
-Parrot_gc_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;

Modified: branches/gc_api/src/list.c
==============================================================================
--- branches/gc_api/src/list.c	Sat May  9 14:53:36 2009	(r38644)
+++ branches/gc_api/src/list.c	Sat May  9 15:05:32 2009	(r38645)
@@ -367,7 +367,7 @@
     chunk->n_items  = 0;
     chunk->next     = NULL;
     chunk->prev     = NULL;
-    Parrot_gc_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);
@@ -600,7 +600,7 @@
         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);
@@ -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);


More information about the parrot-commits mailing list