[svn:parrot] r40641 - in trunk: include/parrot src

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Tue Aug 18 22:39:00 UTC 2009


Author: whiteknight
Date: Tue Aug 18 22:39:00 2009
New Revision: 40641
URL: https://trac.parrot.org/parrot/changeset/40641

Log:
[GC] change the allocator system to use a macro for fixed-size attribute allocations instead of just saying #if 0 in various places

Modified:
   trunk/include/parrot/gc_api.h
   trunk/src/pmc.c

Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h	Tue Aug 18 22:38:22 2009	(r40640)
+++ trunk/include/parrot/gc_api.h	Tue Aug 18 22:39:00 2009	(r40641)
@@ -17,6 +17,10 @@
 
 #include "parrot/parrot.h"
 
+/* Set to 1 if we want to use the fixed-size allocator. Set to 0 if we want
+   to allocate these things using mem_sys_allocate instead */
+#define GC_USE_FIXED_SIZE_ALLOCATOR 1
+
 /*
  * we need an alignment that is the same as malloc(3) have for
  * allocating Buffer items like FLOATVAL (double)

Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c	Tue Aug 18 22:38:22 2009	(r40640)
+++ trunk/src/pmc.c	Tue Aug 18 22:39:00 2009	(r40641)
@@ -242,18 +242,18 @@
     pmc->vtable = new_vtable;
 
     if (PMC_data(pmc) && pmc->vtable->attr_size) {
-#if 0
-        mem_sys_free(PMC_data(pmc));
-#else
+#if GC_USE_FIXED_SIZE_ALLOCATOR
         Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#else
+        mem_sys_free(PMC_data(pmc));
 #endif
     }
 
     if (new_vtable->attr_size) {
-#if 0
-        PMC_data(pmc) = mem_sys_allocate_zeroed(new_vtable->attr_size);
-#else
+#if GC_USE_FIXED_SIZE_ALLOCATOR
         Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#else
+        PMC_data(pmc) = mem_sys_allocate_zeroed(new_vtable->attr_size);
 #endif
 }
     else
@@ -380,10 +380,10 @@
     INTVAL const has_ext = (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext);
 
     if (PMC_data(pmc) && pmc->vtable->attr_size) {
-#if 0
-        mem_sys_free(PMC_data(pmc));
-#else
+#if GC_USE_FIXED_SIZE_ALLOCATOR
         Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#else
+        mem_sys_free(PMC_data(pmc));
 #endif
     }
 
@@ -492,10 +492,10 @@
     pmc->vtable    = vtable;
 
     if (vtable->attr_size) {
-#if 0
-        PMC_data(pmc) = mem_sys_allocate_zeroed(vtable->attr_size);
-#else
+#if GC_USE_FIXED_SIZE_ALLOCATOR
         Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size);
+#else
+        PMC_data(pmc) = mem_sys_allocate_zeroed(vtable->attr_size);
 #endif
     }
 


More information about the parrot-commits mailing list