[svn:parrot] r47470 - branches/gc_massacre/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jun 8 14:05:11 UTC 2010


Author: bacek
Date: Tue Jun  8 14:05:11 2010
New Revision: 47470
URL: https://trac.parrot.org/parrot/changeset/47470

Log:
Rename PoolAllocator functions and made them consistent in accepting interp

Modified:
   branches/gc_massacre/src/gc/fixed_allocator.c
   branches/gc_massacre/src/gc/fixed_allocator.h
   branches/gc_massacre/src/gc/gc_ms2.c
   branches/gc_massacre/src/gc/gc_tms.c

Modified: branches/gc_massacre/src/gc/fixed_allocator.c
==============================================================================
--- branches/gc_massacre/src/gc/fixed_allocator.c	Tue Jun  8 14:04:57 2010	(r47469)
+++ branches/gc_massacre/src/gc/fixed_allocator.c	Tue Jun  8 14:05:11 2010	(r47470)
@@ -110,7 +110,7 @@
     }
 
     if (allocator->pools[index] == NULL)
-        allocator->pools[index] = Parrot_gc_create_pool_allocator(alloc_size);
+        allocator->pools[index] = Parrot_gc_pool_new(interp, alloc_size);
 
     ret = Parrot_gc_pool_allocate(interp, allocator->pools[index]);
     //memset(ret, 0, alloc_size);
@@ -130,7 +130,7 @@
 
     PARROT_ASSERT(allocator->pools[index]);
 
-    Parrot_gc_pool_free(allocator->pools[index], data);
+    Parrot_gc_pool_free(interp, allocator->pools[index], data);
 }
 
 /*
@@ -140,9 +140,27 @@
 
 =over 4
 
-=item C<Pool_Allocator * Parrot_gc_create_pool_allocator(size_t object_size)>
+=item C<Pool_Allocator * Parrot_gc_pool_new(PARROT_INTERP, size_t object_size)>
 
-Create Pool Alocator
+Create Pool Allocator
+
+=item C<void Parrot_gc_pool_destroy(PARROT_INTERP, Pool_Allocator *pool)>
+
+Destroy allocated Pool - free memory for all areanas in the alocated pool
+
+=item C<void * Parrot_gc_pool_allocate(PARROT_INTERP, Pool_Allocator * pool)>
+
+Allocate from Pool
+
+=item C<void Parrot_gc_pool_free(PARROT_INTERP, Pool_Allocator *pool, void
+*data)>
+
+Frees a fixed-size data item back to the Pool for later reallocation
+
+=item C<int Parrot_gc_pool_is_owned(PARROT_INTERP, Pool_Allocator *pool, void
+*ptr)>
+
+check for pool validity
 
 =cut
 
@@ -151,9 +169,9 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_MALLOC
 Pool_Allocator *
-Parrot_gc_create_pool_allocator(size_t object_size)
+Parrot_gc_pool_new(SHIM_INTERP, size_t object_size)
 {
-    ASSERT_ARGS(Parrot_gc_create_pool_allocator)
+    ASSERT_ARGS(Parrot_gc_pool_new)
     const size_t attrib_size = object_size < sizeof (void *) ? sizeof (void*) : object_size;
     const size_t num_objs_raw =
         (GC_FIXED_SIZE_POOL_SIZE - sizeof (Pool_Allocator_Arena)) / attrib_size;
@@ -174,22 +192,11 @@
     return newpool;
 }
 
-/*
-
-=item C<void Parrot_gc_destroy_pool_alloctor(PARROT_INTERP, Pool_Allocator
-*pool)>
-
-Destroy Allocated Pool - free memory for all areanas in the alocated pool
-
-=cut
-
-*/
-
 PARROT_EXPORT
 void
-Parrot_gc_destroy_pool_alloctor(PARROT_INTERP, ARGMOD(Pool_Allocator *pool))
+Parrot_gc_pool_destroy(SHIM_INTERP, ARGMOD(Pool_Allocator *pool))
 {
-    ASSERT_ARGS(Parrot_gc_destroy_pool_alloctor)
+    ASSERT_ARGS(Parrot_gc_pool_destroy)
 
     Pool_Allocator_Arena *arena = pool->top_arena;
 
@@ -202,17 +209,6 @@
     mem_internal_free(pool);
 }
 
-
-/*
-
-=item C<void * Parrot_gc_pool_allocate(PARROT_INTERP, Pool_Allocator * pool)>
-
-Allocate pool
-
-=cut
-
-*/
-
 PARROT_CANNOT_RETURN_NULL
 PARROT_EXPORT
 void *
@@ -241,19 +237,9 @@
     return (void *)item;
 }
 
-/*
-
-=item C<void Parrot_gc_pool_free(Pool_Allocator *pool, void *data)>
-
-Frees a fixed-size data item back to the pool for later reallocation
-
-=cut
-
-*/
-
 PARROT_EXPORT
 void
-Parrot_gc_pool_free(ARGMOD(Pool_Allocator *pool), ARGMOD(void *data))
+Parrot_gc_pool_free(SHIM_INTERP, ARGMOD(Pool_Allocator *pool), ARGMOD(void *data))
 {
     ASSERT_ARGS(Parrot_gc_pool_free)
     Pool_Allocator_Free_List * const item = (Pool_Allocator_Free_List *)data;
@@ -268,19 +254,9 @@
     ++pool->num_free_objects;
 }
 
-/*
-
-=item C<int Parrot_gc_pool_is_owned(Pool_Allocator *pool, void *ptr)>
-
-check for pool validity
-
-=cut
-
-*/
-
 PARROT_EXPORT
 int
-Parrot_gc_pool_is_owned(ARGMOD(Pool_Allocator *pool), ARGMOD(void *ptr))
+Parrot_gc_pool_is_owned(SHIM_INTERP, ARGMOD(Pool_Allocator *pool), ARGMOD(void *ptr))
 {
     ASSERT_ARGS(Parrot_gc_pool_is_owned)
     Pool_Allocator_Arena *arena = pool->top_arena;

Modified: branches/gc_massacre/src/gc/fixed_allocator.h
==============================================================================
--- branches/gc_massacre/src/gc/fixed_allocator.h	Tue Jun  8 14:04:57 2010	(r47469)
+++ branches/gc_massacre/src/gc/fixed_allocator.h	Tue Jun  8 14:05:11 2010	(r47470)
@@ -59,13 +59,6 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_EXPORT
-void Parrot_gc_destroy_pool_alloctor(PARROT_INTERP,
-    ARGMOD(Pool_Allocator *pool))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pool);
-
-PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
 void* Parrot_gc_fixed_allocator_allocate(PARROT_INTERP,
     ARGIN(Fixed_Allocator *allocator),
@@ -101,27 +94,32 @@
         FUNC_MODIFIES(* pool);
 
 PARROT_EXPORT
-void Parrot_gc_pool_free(ARGMOD(Pool_Allocator *pool), ARGMOD(void *data))
-        __attribute__nonnull__(1)
+void Parrot_gc_pool_destroy(SHIM_INTERP, ARGMOD(Pool_Allocator *pool))
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*pool);
+
+PARROT_EXPORT
+void Parrot_gc_pool_free(SHIM_INTERP,
+    ARGMOD(Pool_Allocator *pool),
+    ARGMOD(void *data))
         __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*data);
 
 PARROT_EXPORT
-int Parrot_gc_pool_is_owned(ARGMOD(Pool_Allocator *pool), ARGMOD(void *ptr))
-        __attribute__nonnull__(1)
+int Parrot_gc_pool_is_owned(SHIM_INTERP,
+    ARGMOD(Pool_Allocator *pool),
+    ARGMOD(void *ptr))
         __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*ptr);
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_MALLOC
-Pool_Allocator * Parrot_gc_create_pool_allocator(size_t object_size);
+Pool_Allocator * Parrot_gc_pool_new(SHIM_INTERP, size_t object_size);
 
-#define ASSERT_ARGS_Parrot_gc_destroy_pool_alloctor \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(pool))
 #define ASSERT_ARGS_Parrot_gc_fixed_allocator_allocate \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -140,14 +138,15 @@
 #define ASSERT_ARGS_Parrot_gc_pool_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pool))
+#define ASSERT_ARGS_Parrot_gc_pool_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(pool))
 #define ASSERT_ARGS_Parrot_gc_pool_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(data))
 #define ASSERT_ARGS_Parrot_gc_pool_is_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(ptr))
-#define ASSERT_ARGS_Parrot_gc_create_pool_allocator \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_Parrot_gc_pool_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/fixed_allocator.c */
 

Modified: branches/gc_massacre/src/gc/gc_ms2.c
==============================================================================
--- branches/gc_massacre/src/gc/gc_ms2.c	Tue Jun  8 14:04:57 2010	(r47469)
+++ branches/gc_massacre/src/gc/gc_ms2.c	Tue Jun  8 14:05:11 2010	(r47470)
@@ -615,11 +615,11 @@
     else {
         self = mem_allocate_zeroed_typed(MarkSweep_GC);
 
-        self->pmc_allocator = Parrot_gc_create_pool_allocator(
+        self->pmc_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (PMC));
         self->objects = Parrot_list_new(interp);
 
-        self->string_allocator = Parrot_gc_create_pool_allocator(
+        self->string_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (STRING));
         self->strings = Parrot_list_new(interp);
 
@@ -648,7 +648,7 @@
     }
 
     ptr = (List_Item_Header *)Parrot_gc_pool_allocate(interp,
-        self->pmc_allocator);
+            self->pmc_allocator);
     LIST_APPEND(self->objects, ptr);
 
     ret = LLH2Obj_typed(ptr, PMC);
@@ -669,7 +669,7 @@
 
         Parrot_pmc_destroy(interp, pmc);
 
-        Parrot_gc_pool_free(self->pmc_allocator, Obj2LLH(pmc));
+        Parrot_gc_pool_free(interp, self->pmc_allocator, Obj2LLH(pmc));
     }
 }
 
@@ -761,7 +761,7 @@
     }
 
     ptr = (List_Item_Header *)Parrot_gc_pool_allocate(interp,
-        self->string_allocator);
+            self->string_allocator);
     LIST_APPEND(self->strings, ptr);
 
     ret = LLH2Obj_typed(ptr, STRING);
@@ -783,7 +783,7 @@
         if (Buffer_bufstart(s) && !PObj_external_TEST(s))
             mem_sys_free(Buffer_bufstart(s));
 
-        Parrot_gc_pool_free(self->string_allocator, Obj2LLH(s));
+        Parrot_gc_pool_free(interp, self->string_allocator, Obj2LLH(s));
     }
 }
 
@@ -920,7 +920,7 @@
 
             callback(interp, obj);
 
-            Parrot_gc_pool_free(pool, tmp);
+            Parrot_gc_pool_free(interp, pool, tmp);
         }
         tmp = next;
     }
@@ -949,7 +949,7 @@
     if (!obj || !item)
         return 0;
 
-    if (!Parrot_gc_pool_is_owned(pool, item))
+    if (!Parrot_gc_pool_is_owned(interp, pool, item))
         return 0;
 
     /* black or white objects marked already. */

Modified: branches/gc_massacre/src/gc/gc_tms.c
==============================================================================
--- branches/gc_massacre/src/gc/gc_tms.c	Tue Jun  8 14:04:57 2010	(r47469)
+++ branches/gc_massacre/src/gc/gc_tms.c	Tue Jun  8 14:05:11 2010	(r47470)
@@ -570,10 +570,10 @@
     else {
         self = mem_allocate_zeroed_typed(TriColor_GC);
 
-        self->pmc_allocator = Parrot_gc_create_pool_allocator(
+        self->pmc_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (PMC));
 
-        self->constant_pmc_allocator = Parrot_gc_create_pool_allocator(
+        self->constant_pmc_allocator = Parrot_gc_pool_new(interp,
             sizeof (List_Item_Header) + sizeof (PMC));
 
         self->objects = Parrot_list_new(interp);
@@ -621,7 +621,7 @@
             return;
         Parrot_list_remove(interp, self->objects, Obj2LLH(pmc));
         PObj_on_free_list_SET(pmc);
-        Parrot_gc_pool_free(self->pmc_allocator, Obj2LLH(pmc));
+        Parrot_gc_pool_free(interp, self->pmc_allocator, Obj2LLH(pmc));
     }
 }
 
@@ -703,7 +703,7 @@
         List_Item_Header *next = tmp->next;
         PARROT_ASSERT(tmp->owner == self->dead_objects);
         PObj_on_free_list_SET(LLH2Obj_typed(tmp, PMC));
-        Parrot_gc_pool_free(self->pmc_allocator, tmp);
+        Parrot_gc_pool_free(interp, self->pmc_allocator, tmp);
         tmp = next;
         ++counter;
         PARROT_ASSERT(counter <= self->dead_objects->count);
@@ -835,7 +835,7 @@
     if (!ptr || !item)
         return 0;
 
-    if (!Parrot_gc_pool_is_owned(self->pmc_allocator, item))
+    if (!Parrot_gc_pool_is_owned(interp, self->pmc_allocator, item))
         return 0;
 
     /* black or grey objects marked already. Dead objects are dead */


More information about the parrot-commits mailing list