[svn:parrot] r43694 - branches/gc_encapsulate/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Feb 1 21:08:46 UTC 2010


Author: bacek
Date: Mon Feb  1 21:08:45 2010
New Revision: 43694
URL: https://trac.parrot.org/parrot/changeset/43694

Log:
Add flags parameter into allocate_buffer to separate constant vs
non-constant allocations. Whiteknight++

Modified:
   branches/gc_encapsulate/src/gc/api.c
   branches/gc_encapsulate/src/gc/gc_ms.c
   branches/gc_encapsulate/src/gc/gc_private.h

Modified: branches/gc_encapsulate/src/gc/api.c
==============================================================================
--- branches/gc_encapsulate/src/gc/api.c	Mon Feb  1 21:08:23 2010	(r43693)
+++ branches/gc_encapsulate/src/gc/api.c	Mon Feb  1 21:08:45 2010	(r43694)
@@ -467,7 +467,7 @@
     Buffer_buflen(buffer) = 0;
     Buffer_bufstart(buffer) = NULL;
     new_size = aligned_size(buffer, size);
-    mem = (char*)interp->gc_sys->allocate_buffer(interp, new_size);
+    mem = (char*)interp->gc_sys->allocate_buffer(interp, new_size, 0);
     mem = aligned_mem(buffer, mem);
     Buffer_bufstart(buffer) = mem;
     if (PObj_is_COWable_TEST(buffer))
@@ -591,7 +591,7 @@
 #endif
 
     new_size = aligned_string_size(size);
-    mem      = (char *)interp->gc_sys->allocate_buffer(interp, new_size);
+    mem      = (char *)interp->gc_sys->allocate_buffer(interp, new_size, str->flags);
     mem     += sizeof (void*);
 
     Buffer_bufstart(str) = str->strstart = mem;
@@ -687,7 +687,7 @@
     /* only copy used memory, not total string buffer */
     copysize = str->bufused;
 
-    mem = (char *)interp->gc_sys->allocate_buffer(interp, new_size);
+    mem = (char *)interp->gc_sys->allocate_buffer(interp, new_size, str->flags);
     mem += sizeof (void *);
 
     /* copy mem from strstart, *not* bufstart */

Modified: branches/gc_encapsulate/src/gc/gc_ms.c
==============================================================================
--- branches/gc_encapsulate/src/gc/gc_ms.c	Mon Feb  1 21:08:23 2010	(r43693)
+++ branches/gc_encapsulate/src/gc/gc_ms.c	Mon Feb  1 21:08:45 2010	(r43694)
@@ -45,7 +45,9 @@
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
-static void* gc_ms_allocate_buffer(PARROT_INTERP, size_t size)
+static void* gc_ms_allocate_buffer(PARROT_INTERP,
+    size_t size,
+    UINTVAL flags)
         __attribute__nonnull__(1);
 
 PARROT_CAN_RETURN_NULL
@@ -533,11 +535,14 @@
 
 PARROT_CAN_RETURN_NULL
 static void*
-gc_ms_allocate_buffer(PARROT_INTERP, size_t size)
+gc_ms_allocate_buffer(PARROT_INTERP, size_t size, UINTVAL flags)
 {
     ASSERT_ARGS(gc_ms_allocate_buffer)
     Memory_Pools * const mem_pools = (Memory_Pools*)interp->gc_sys->gc_private;
-    return mem_allocate(interp, mem_pools, size, mem_pools->memory_pool);
+    Variable_Size_Pool * const pool      = flags & PObj_constant_FLAG
+                ? mem_pools->constant_string_pool
+                : mem_pools->memory_pool;
+    return mem_allocate(interp, mem_pools, size, pool);
 }
 
 PARROT_CAN_RETURN_NULL
@@ -557,7 +562,7 @@
      * If there is no old buffer just allocate new one
      */
     if (!buffer)
-        return gc_ms_allocate_buffer(interp, newsize);
+        return gc_ms_allocate_buffer(interp, newsize, 0);
 
     /*
      * we don't shrink buffers
@@ -595,7 +600,7 @@
         pool->possibly_reclaimable   += copysize;
 #endif
 
-    mem = (char *)gc_ms_allocate_buffer(interp, new_size);
+    mem = (char *)gc_ms_allocate_buffer(interp, new_size, 0);
     mem = aligned_mem(buffer, mem);
 
     /* We shouldn't ever have a 0 from size, but we do. If we can track down

Modified: branches/gc_encapsulate/src/gc/gc_private.h
==============================================================================
--- branches/gc_encapsulate/src/gc/gc_private.h	Mon Feb  1 21:08:23 2010	(r43693)
+++ branches/gc_encapsulate/src/gc/gc_private.h	Mon Feb  1 21:08:45 2010	(r43694)
@@ -98,6 +98,7 @@
     /* Finalize _child_ interpeter. Update interp->parent_interp if needed */
     void (*finalize_gc_system) (PARROT_INTERP);
 
+    /* Run GC "mark" explicitely */
     void (*do_gc_mark)(PARROT_INTERP, UINTVAL flags);
 
     /* Allocation functions with explicit freeing counterparts */
@@ -112,7 +113,7 @@
 
     /* Buffer allocation routines */
     /* Allocate buffer which doesn't contains interior pointers */
-    void* (*allocate_buffer)(PARROT_INTERP, size_t size);
+    void* (*allocate_buffer)(PARROT_INTERP, size_t size, UINTVAL flags);
     void* (*reallocate_buffer)(PARROT_INTERP, void *buffer, size_t newsize);
 
     /* Allocate buffer which contains interior pointers */


More information about the parrot-commits mailing list