[svn:parrot] r38637 - in branches/gc_api: include/parrot src/gc src/pmc src/string

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat May 9 12:34:46 UTC 2009


Author: whiteknight
Date: Sat May  9 12:34:46 2009
New Revision: 38637
URL: https://trac.parrot.org/parrot/changeset/38637

Log:
[gc_api] add a new api function Parrot_gc_free_string_header, use that to get references of Small_Object_Pool out of src/string/api.c. Also, use API functions in retcontinuation PMC to preserve encapsulation

Modified:
   branches/gc_api/include/parrot/gc_api.h
   branches/gc_api/src/gc/api.c
   branches/gc_api/src/pmc/retcontinuation.pmc
   branches/gc_api/src/string/api.c

Modified: branches/gc_api/include/parrot/gc_api.h
==============================================================================
--- branches/gc_api/include/parrot/gc_api.h	Sat May  9 12:24:59 2009	(r38636)
+++ branches/gc_api/include/parrot/gc_api.h	Sat May  9 12:34:46 2009	(r38637)
@@ -386,6 +386,11 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
+void Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*s);
+
 int Parrot_gc_get_pmc_index(PARROT_INTERP, ARGIN(PMC* pmc))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -478,6 +483,9 @@
 #define ASSERT_ARGS_Parrot_gc_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_gc_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(s)
 #define ASSERT_ARGS_Parrot_gc_get_pmc_index __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(pmc)

Modified: branches/gc_api/src/gc/api.c
==============================================================================
--- branches/gc_api/src/gc/api.c	Sat May  9 12:24:59 2009	(r38636)
+++ branches/gc_api/src/gc/api.c	Sat May  9 12:34:46 2009	(r38637)
@@ -261,6 +261,23 @@
     pool->num_free_objects++;
 }
 
+/*
+
+=item C<void Parrot_gc_free_string_header(PARROT_INTERP, STRING *s)>
+
+=cut
+
+*/
+
+void
+Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
+{
+    ASSERT_ARGS(Parrot_gc_free_string_header);
+    if (!PObj_constant_TEST(s)) {
+        Small_Object_Pool * const pool = interp->arena_base->string_header_pool;
+        pool->add_free_object(interp, pool, s);
+    }
+}
 
 /*
 

Modified: branches/gc_api/src/pmc/retcontinuation.pmc
==============================================================================
--- branches/gc_api/src/pmc/retcontinuation.pmc	Sat May  9 12:24:59 2009	(r38636)
+++ branches/gc_api/src/pmc/retcontinuation.pmc	Sat May  9 12:34:46 2009	(r38637)
@@ -101,16 +101,8 @@
 #ifdef NDEBUG
         /* the continuation is dead - delete and destroy it */
         VTABLE_destroy(interp, SELF);
-        {
-            Arenas            *arena_base = interp->arena_base;
-            Small_Object_Pool *pool       = arena_base->pmc_pool;
-            Small_Object_Pool *ext_pool   = arena_base->pmc_ext_pool;
-            ext_pool->add_free_object(interp, ext_pool,
-                    (PObj *)SELF->pmc_ext);
-            PObj_flags_SETTO((PObj *)SELF, PObj_on_free_list_FLAG);
-            pool->add_free_object(interp, pool, (PObj *)SELF);
-            pool->num_free_objects++;
-        }
+        Parrot_gc_free_pmc_ext(interp, SELF);
+        Parrot_gc_free_pmc_header(interp, SELF);
 #else
         cc->from_ctx = NULL;
 

Modified: branches/gc_api/src/string/api.c
==============================================================================
--- branches/gc_api/src/string/api.c	Sat May  9 12:24:59 2009	(r38636)
+++ branches/gc_api/src/string/api.c	Sat May  9 12:34:46 2009	(r38637)
@@ -242,10 +242,7 @@
 Parrot_str_free(PARROT_INTERP, ARGIN(STRING *s))
 {
     ASSERT_ARGS(Parrot_str_free)
-    if (!PObj_constant_TEST(s)) {
-        Small_Object_Pool * const pool = interp->arena_base->string_header_pool;
-        pool->add_free_object(interp, pool, s);
-    }
+    Parrot_gc_free_string_header(interp, s);
 }
 
 /*


More information about the parrot-commits mailing list