[svn:parrot] r45168 - in trunk: include/parrot src/gc

petdance at svn.parrot.org petdance at svn.parrot.org
Thu Mar 25 00:34:11 UTC 2010


Author: petdance
Date: Thu Mar 25 00:34:10 2010
New Revision: 45168
URL: https://trac.parrot.org/parrot/changeset/45168

Log:
more const correctness and dropping of unused args

Modified:
   trunk/include/parrot/gc_api.h
   trunk/src/gc/api.c
   trunk/src/gc/gc_ms.c
   trunk/src/gc/gc_private.h
   trunk/src/gc/mark_sweep.c

Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h	Thu Mar 25 00:26:08 2010	(r45167)
+++ trunk/include/parrot/gc_api.h	Thu Mar 25 00:34:10 2010	(r45168)
@@ -256,8 +256,7 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
-void Parrot_gc_free_pmc_sync(PARROT_INTERP, ARGMOD(PMC *p))
-        __attribute__nonnull__(1)
+void Parrot_gc_free_pmc_sync(SHIM_INTERP, ARGMOD(PMC *p))
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*p);
 
@@ -421,8 +420,7 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
 #define ASSERT_ARGS_Parrot_gc_free_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(p))
+       PARROT_ASSERT_ARG(p))
 #define ASSERT_ARGS_Parrot_gc_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(s))

Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c	Thu Mar 25 00:26:08 2010	(r45167)
+++ trunk/src/gc/api.c	Thu Mar 25 00:34:10 2010	(r45168)
@@ -382,7 +382,7 @@
 */
 
 void
-Parrot_gc_free_pmc_sync(PARROT_INTERP, ARGMOD(PMC *p))
+Parrot_gc_free_pmc_sync(SHIM_INTERP, ARGMOD(PMC *p))
 {
     ASSERT_ARGS(Parrot_gc_free_pmc_sync)
 

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Thu Mar 25 00:26:08 2010	(r45167)
+++ trunk/src/gc/gc_ms.c	Thu Mar 25 00:34:10 2010	(r45168)
@@ -31,16 +31,13 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-static int gc_ms_active_sized_buffers(PARROT_INTERP,
-    ARGIN(Memory_Pools * const mem_pools))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+static int gc_ms_active_sized_buffers(ARGIN(const Memory_Pools *mem_pools))
+        __attribute__nonnull__(1);
 
 static void gc_ms_add_free_object(SHIM_INTERP,
-    ARGIN(Memory_Pools *mem_pools),
+    SHIM(Memory_Pools *mem_pools),
     ARGMOD(Fixed_Size_Pool *pool),
     ARGIN(void *to_add))
-        __attribute__nonnull__(2)
         __attribute__nonnull__(3)
         __attribute__nonnull__(4)
         FUNC_MODIFIES(*pool);
@@ -67,13 +64,11 @@
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size)
-        __attribute__nonnull__(1);
+static void * gc_ms_allocate_memory_chunk(SHIM_INTERP, size_t size);
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * gc_ms_allocate_memory_chunk_zeroed(PARROT_INTERP, size_t size)
-        __attribute__nonnull__(1);
+static void * gc_ms_allocate_memory_chunk_zeroed(SHIM_INTERP, size_t size);
 
 PARROT_CAN_RETURN_NULL
 static PMC* gc_ms_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
@@ -104,12 +99,11 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-static void gc_ms_free_attributes_from_pool(PARROT_INTERP,
+static void gc_ms_free_attributes_from_pool(
     ARGMOD(PMC_Attribute_Pool *pool),
     ARGMOD(void *data))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*data);
 
@@ -120,9 +114,7 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*obj);
 
-static void gc_ms_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
-        __attribute__nonnull__(1);
-
+static void gc_ms_free_memory_chunk(SHIM_INTERP, ARGFREE(void *data));
 static void gc_ms_free_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -180,18 +172,16 @@
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * gc_ms_reallocate_memory_chunk(PARROT_INTERP,
+static void * gc_ms_reallocate_memory_chunk(SHIM_INTERP,
     ARGFREE(void *from),
-    size_t size)
-        __attribute__nonnull__(1);
+    size_t size);
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * gc_ms_reallocate_memory_chunk_zeroed(PARROT_INTERP,
+static void * gc_ms_reallocate_memory_chunk_zeroed(SHIM_INTERP,
     ARGFREE(void *data),
     size_t newsize,
-    size_t oldsize)
-        __attribute__nonnull__(1);
+    size_t oldsize);
 
 static void gc_ms_reallocate_string_storage(PARROT_INTERP,
     ARGMOD(STRING *str),
@@ -212,10 +202,8 @@
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*arg);
 
-static int gc_ms_total_sized_buffers(PARROT_INTERP,
-    ARGIN(Memory_Pools * const mem_pools))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+static int gc_ms_total_sized_buffers(ARGIN(const Memory_Pools *mem_pools))
+        __attribute__nonnull__(1);
 
 static int gc_ms_trace_active_PMCs(PARROT_INTERP,
     Parrot_gc_trace_type trace)
@@ -228,11 +216,9 @@
         __attribute__nonnull__(1);
 
 #define ASSERT_ARGS_gc_ms_active_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(mem_pools))
+       PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_gc_ms_add_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(mem_pools) \
-    , PARROT_ASSERT_ARG(pool) \
+       PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(to_add))
 #define ASSERT_ARGS_gc_ms_alloc_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -244,11 +230,9 @@
 #define ASSERT_ARGS_gc_ms_allocate_bufferlike_header \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_allocate_memory_chunk_zeroed \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_allocate_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms_allocate_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -267,14 +251,12 @@
     , PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_gc_ms_free_attributes_from_pool \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(pool) \
+       PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(data))
 #define ASSERT_ARGS_gc_ms_free_bufferlike_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(obj))
-#define ASSERT_ARGS_gc_ms_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
@@ -306,11 +288,9 @@
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(buffer))
-#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_reallocate_memory_chunk_zeroed \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_reallocate_string_storage \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -321,8 +301,7 @@
     , PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(arg))
 #define ASSERT_ARGS_gc_ms_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(mem_pools))
+       PARROT_ASSERT_ARG(mem_pools))
 #define ASSERT_ARGS_gc_ms_trace_active_PMCs __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms_unblock_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -807,9 +786,9 @@
         const size_t item_size = attr_size < sizeof (void *) ? sizeof (void *) : attr_size;
         PMC_Attribute_Pool ** const pools = interp->mem_pools->attrib_pools;
         const size_t idx = item_size - sizeof (void *);
-        gc_ms_free_attributes_from_pool(interp, pools[idx], data);
+        gc_ms_free_attributes_from_pool(pools[idx], data);
 #else
-        gc_ms_free_memory_chunk(PMC_data(pmc));
+        gc_ms_free_memory_chunk(intepr,PMC_data(pmc));
         PMC_data(pmc) = NULL;
 #endif
     }
@@ -817,8 +796,8 @@
 
 /*
 
-=item C<static void gc_ms_free_attributes_from_pool(PARROT_INTERP,
-PMC_Attribute_Pool *pool, void *data)>
+=item C<static void gc_ms_free_attributes_from_pool(PMC_Attribute_Pool *pool,
+void *data)>
 
 Frees a fixed-size data item back to the pool for later reallocation.  Private
 to this file.
@@ -826,9 +805,7 @@
 */
 
 static void
-gc_ms_free_attributes_from_pool(PARROT_INTERP,
-    ARGMOD(PMC_Attribute_Pool *pool),
-    ARGMOD(void *data))
+gc_ms_free_attributes_from_pool(ARGMOD(PMC_Attribute_Pool *pool), ARGMOD(void *data))
 {
     ASSERT_ARGS(gc_ms_free_attributes_from_pool)
     PMC_Attribute_Free_List * const item = (PMC_Attribute_Free_List *)data;
@@ -1101,7 +1078,7 @@
 
     const size_t idx   = size - sizeof (void *);
     PMC_Attribute_Pool ** const pools = interp->mem_pools->attrib_pools;
-    gc_ms_free_attributes_from_pool(interp, pools[idx], data);
+    gc_ms_free_attributes_from_pool(pools[idx], data);
 }
 
 /*
@@ -1126,7 +1103,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
-gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size)
+gc_ms_allocate_memory_chunk(SHIM_INTERP, size_t size)
 {
     ASSERT_ARGS(gc_ms_allocate_memory_chunk)
     void * const ptr = malloc(size);
@@ -1141,7 +1118,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
-gc_ms_reallocate_memory_chunk(PARROT_INTERP, ARGFREE(void *from), size_t size)
+gc_ms_reallocate_memory_chunk(SHIM_INTERP, ARGFREE(void *from), size_t size)
 {
     ASSERT_ARGS(gc_ms_reallocate_memory_chunk)
     void *ptr;
@@ -1163,7 +1140,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
-gc_ms_allocate_memory_chunk_zeroed(PARROT_INTERP, size_t size)
+gc_ms_allocate_memory_chunk_zeroed(SHIM_INTERP, size_t size)
 {
     ASSERT_ARGS(gc_ms_allocate_memory_chunk_zeroed)
     void * const ptr = calloc(1, (size_t)size);
@@ -1178,7 +1155,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
-gc_ms_reallocate_memory_chunk_zeroed(PARROT_INTERP, ARGFREE(void *data),
+gc_ms_reallocate_memory_chunk_zeroed(SHIM_INTERP, ARGFREE(void *data),
         size_t newsize, size_t oldsize)
 {
     ASSERT_ARGS(gc_ms_reallocate_memory_chunk_zeroed)
@@ -1189,7 +1166,7 @@
 }
 
 static void
-gc_ms_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
+gc_ms_free_memory_chunk(SHIM_INTERP, ARGFREE(void *data))
 {
     ASSERT_ARGS(gc_ms_free_memory_chunk)
 #ifdef DETAIL_MEMORY_DEBUG
@@ -1336,7 +1313,7 @@
 
 static void
 gc_ms_add_free_object(SHIM_INTERP,
-        ARGIN(Memory_Pools *mem_pools),
+        SHIM(Memory_Pools *mem_pools),
         ARGMOD(Fixed_Size_Pool *pool),
         ARGIN(void *to_add))
 {
@@ -1580,11 +1557,11 @@
             return mem_pools->pmc_pool->total_objects -
                    mem_pools->pmc_pool->num_free_objects;
         case ACTIVE_BUFFERS:
-            return gc_ms_active_sized_buffers(interp, mem_pools);
+            return gc_ms_active_sized_buffers(mem_pools);
         case TOTAL_PMCS:
             return mem_pools->pmc_pool->total_objects;
         case TOTAL_BUFFERS:
-            return gc_ms_total_sized_buffers(interp, mem_pools);
+            return gc_ms_total_sized_buffers(mem_pools);
         case HEADER_ALLOCS_SINCE_COLLECT:
             return mem_pools->header_allocs_since_last_collect;
         case MEM_ALLOCS_SINCE_COLLECT:
@@ -1604,8 +1581,7 @@
 
 /*
 
-=item C<static int gc_ms_active_sized_buffers(PARROT_INTERP, Memory_Pools *
-const mem_pools)>
+=item C<static int gc_ms_active_sized_buffers(const Memory_Pools *mem_pools)>
 
 Returns the number of actively used sized buffers.
 
@@ -1614,8 +1590,7 @@
 */
 
 static int
-gc_ms_active_sized_buffers(PARROT_INTERP,
-        ARGIN(Memory_Pools * const mem_pools))
+gc_ms_active_sized_buffers(ARGIN(const Memory_Pools *mem_pools))
 {
     ASSERT_ARGS(gc_ms_active_sized_buffers)
     int j, ret = 0;
@@ -1631,8 +1606,7 @@
 
 /*
 
-=item C<static int gc_ms_total_sized_buffers(PARROT_INTERP, Memory_Pools * const
-mem_pools)>
+=item C<static int gc_ms_total_sized_buffers(const Memory_Pools *mem_pools)>
 
 Returns the total number of sized buffers that we are managing.
 
@@ -1641,8 +1615,7 @@
 */
 
 static int
-gc_ms_total_sized_buffers(PARROT_INTERP,
-        ARGIN(Memory_Pools * const mem_pools))
+gc_ms_total_sized_buffers(ARGIN(const Memory_Pools *mem_pools))
 {
     ASSERT_ARGS(gc_ms_total_sized_buffers)
     int j, ret = 0;

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Thu Mar 25 00:26:08 2010	(r45167)
+++ trunk/src/gc/gc_private.h	Thu Mar 25 00:34:10 2010	(r45168)
@@ -346,7 +346,7 @@
 PARROT_IGNORABLE_RESULT
 int /*@alt void@*/
 header_pools_iterate_callback(PARROT_INTERP,
-    ARGIN(Memory_Pools * const mem_pools),
+    ARGIN(Memory_Pools *mem_pools),
     int flag,
     ARGIN_NULLOK(void *arg),
     NOTNULL(pool_iter_fn func))
@@ -393,9 +393,10 @@
 
 PARROT_CANNOT_RETURN_NULL
 PMC_Attribute_Pool * Parrot_gc_get_attribute_pool(SHIM_INTERP,
-    ARGIN(Memory_Pools * const mem_pools),
+    ARGMOD(Memory_Pools *mem_pools),
     size_t attrib_size)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*mem_pools);
 
 PARROT_CANNOT_RETURN_NULL
 void * Parrot_gc_get_attributes_from_pool(PARROT_INTERP,
@@ -405,9 +406,10 @@
         FUNC_MODIFIES(* pool);
 
 void Parrot_gc_initialize_fixed_size_pools(SHIM_INTERP,
-    ARGIN(Memory_Pools * const mem_pools),
+    ARGMOD(Memory_Pools *mem_pools),
     size_t init_num_pools)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*mem_pools);
 
 void Parrot_gc_run_init(SHIM_INTERP, ARGMOD(Memory_Pools *mem_pools))
         __attribute__nonnull__(2)

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Thu Mar 25 00:26:08 2010	(r45167)
+++ trunk/src/gc/mark_sweep.c	Thu Mar 25 00:34:10 2010	(r45168)
@@ -83,6 +83,7 @@
         FUNC_MODIFIES(*pool);
 
 PARROT_CANNOT_RETURN_NULL
+PARROT_MALLOC
 static PMC_Attribute_Pool * Parrot_gc_create_attrib_pool(size_t attrib_idx);
 
 #define ASSERT_ARGS_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -814,8 +815,8 @@
 
 /*
 
-=item C<int header_pools_iterate_callback(PARROT_INTERP, Memory_Pools * const
-mem_pools, int flag, void *arg, pool_iter_fn func)>
+=item C<int header_pools_iterate_callback(PARROT_INTERP, Memory_Pools
+*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
@@ -855,7 +856,7 @@
 PARROT_IGNORABLE_RESULT
 int
 header_pools_iterate_callback(PARROT_INTERP,
-        ARGIN(Memory_Pools * const mem_pools),
+        ARGIN(Memory_Pools *mem_pools),
         int flag, ARGIN_NULLOK(void *arg),
         NOTNULL(pool_iter_fn func))
 {
@@ -914,13 +915,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, Memory_Pools *
-const mem_pools, size_t init_num_pools)>
+=item C<void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP, Memory_Pools
+*mem_pools, size_t init_num_pools)>
 
 Initialize the pools (zeroize)
 
 =item C<PMC_Attribute_Pool * Parrot_gc_get_attribute_pool(PARROT_INTERP,
-Memory_Pools * const mem_pools, size_t attrib_size)>
+Memory_Pools *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.
@@ -1009,7 +1010,7 @@
 
 void
 Parrot_gc_initialize_fixed_size_pools(SHIM_INTERP,
-        ARGIN(Memory_Pools * const mem_pools),
+        ARGMOD(Memory_Pools *mem_pools),
         size_t init_num_pools)
 {
     ASSERT_ARGS(Parrot_gc_initialize_fixed_size_pools)
@@ -1027,7 +1028,7 @@
 PARROT_CANNOT_RETURN_NULL
 PMC_Attribute_Pool *
 Parrot_gc_get_attribute_pool(SHIM_INTERP,
-        ARGIN(Memory_Pools * const mem_pools),
+        ARGMOD(Memory_Pools *mem_pools),
         size_t attrib_size)
 {
     ASSERT_ARGS(Parrot_gc_get_attribute_pool)
@@ -1060,6 +1061,7 @@
 }
 
 PARROT_CANNOT_RETURN_NULL
+PARROT_MALLOC
 static PMC_Attribute_Pool *
 Parrot_gc_create_attrib_pool(size_t attrib_idx)
 {


More information about the parrot-commits mailing list