[svn:parrot] r43926 - branches/boehm_gc_2/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Feb 13 07:14:34 UTC 2010


Author: bacek
Date: Sat Feb 13 07:14:33 2010
New Revision: 43926
URL: https://trac.parrot.org/parrot/changeset/43926

Log:
Use typed allocating of PMC ans STRING.

Modified:
   branches/boehm_gc_2/src/gc/gc_boehm.c

Modified: branches/boehm_gc_2/src/gc/gc_boehm.c
==============================================================================
--- branches/boehm_gc_2/src/gc/gc_boehm.c	Sat Feb 13 07:14:19 2010	(r43925)
+++ branches/boehm_gc_2/src/gc/gc_boehm.c	Sat Feb 13 07:14:33 2010	(r43926)
@@ -20,6 +20,15 @@
 #ifdef PARROT_HAS_BOEHM_GC
 
 #include <gc.h>
+#include <gc_typed.h>
+
+typedef struct boehm_gc_data {
+    GC_word pmc_layout;
+    GC_word pmc_descriptor;
+
+    GC_word string_layout;
+    GC_word string_descriptor;
+} boehm_gc_data;
 
 /* HEADERIZER HFILE: src/gc/gc_private.h */
 
@@ -237,7 +246,9 @@
 static PMC*
 gc_boehm_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
 {
-    PMC *pmc = (PMC*)GC_MALLOC(sizeof(PMC));
+    boehm_gc_data *d = (boehm_gc_data*)interp->gc_sys->gc_private;
+    PMC *pmc = (PMC*)GC_malloc_explicitly_typed(sizeof(PMC), d->pmc_descriptor);
+    //PMC *pmc = (PMC*)GC_MALLOC(sizeof(PMC));
     //GC_REGISTER_FINALIZER_NO_ORDER(pmc, gc_boehm_finalize_cb, interp, NULL, NULL);
     return pmc;
 }
@@ -259,7 +270,8 @@
 static STRING*
 gc_boehm_allocate_string_header(PARROT_INTERP, UINTVAL flags)
 {
-    return (STRING*)GC_MALLOC(sizeof(STRING));
+    boehm_gc_data *d = (boehm_gc_data*)interp->gc_sys->gc_private;
+    return (STRING*)GC_malloc_explicitly_typed(sizeof(STRING), d->string_descriptor);
 }
 
 static void
@@ -424,6 +436,18 @@
     //GC_enable_incremental();
     //GC_time_limit = GC_TIME_UNLIMITED;
 
+    boehm_gc_data *gc_private = (boehm_gc_data*)GC_MALLOC_ATOMIC(sizeof(boehm_gc_data));
+    /* PMC layout */
+    /* 11110 -> 0x1F */
+    gc_private->pmc_layout = 0x1F;
+    gc_private->pmc_descriptor = GC_make_descriptor(&gc_private->pmc_layout, 5);
+    /* STRING layout */
+    /* 000000010 -> 0x2 */
+    gc_private->string_layout = 0x2;
+    gc_private->string_descriptor = GC_make_descriptor(&gc_private->string_layout, 9);
+
+    interp->gc_sys->gc_private = gc_private;
+
     interp->gc_sys->do_gc_mark         = gc_boehm_mark_and_sweep;
     interp->gc_sys->finalize_gc_system = NULL;
 


More information about the parrot-commits mailing list