[svn:parrot] r46029 - in branches/compact_pool_revamp: include/parrot src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Apr 26 11:59:17 UTC 2010


Author: bacek
Date: Mon Apr 26 11:59:16 2010
New Revision: 46029
URL: https://trac.parrot.org/parrot/changeset/46029

Log:
Introduce Buffer_poolptr macro and use it in assignments. It helped to
spot stupid mistake in setting buffer's pool pointer on initial
allocation.

Modified:
   branches/compact_pool_revamp/include/parrot/pobj.h
   branches/compact_pool_revamp/src/gc/alloc_resources.c
   branches/compact_pool_revamp/src/gc/gc_ms.c
   branches/compact_pool_revamp/src/gc/mark_sweep.c

Modified: branches/compact_pool_revamp/include/parrot/pobj.h
==============================================================================
--- branches/compact_pool_revamp/include/parrot/pobj.h	Mon Apr 26 10:53:47 2010	(r46028)
+++ branches/compact_pool_revamp/include/parrot/pobj.h	Mon Apr 26 11:59:16 2010	(r46029)
@@ -57,8 +57,9 @@
    casts. */
 #define Buffer_alloc_offset sizeof (void*)
 #define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset)
-#define Buffer_bufrefcount(b)    (*(INTVAL *)Buffer_bufallocstart(b))
 #define Buffer_bufrefcountptr(b) ((INTVAL *)Buffer_bufallocstart(b))
+#define Buffer_pool(b) ((Memory_Block *)( *(INTVAL*)(Buffer_bufallocstart(b)) & ~3 ))
+#define Buffer_poolptr(b) ((Memory_Block **)Buffer_bufallocstart(b))
 
 
 typedef enum {

Modified: branches/compact_pool_revamp/src/gc/alloc_resources.c
==============================================================================
--- branches/compact_pool_revamp/src/gc/alloc_resources.c	Mon Apr 26 10:53:47 2010	(r46028)
+++ branches/compact_pool_revamp/src/gc/alloc_resources.c	Mon Apr 26 11:59:16 2010	(r46029)
@@ -491,8 +491,7 @@
             for (i = objects_end; i; --i) {
 
                 if (Buffer_buflen(b) && PObj_is_movable_TESTALL(b)) {
-                    INTVAL *buffer_flags = Buffer_bufrefcountptr(b);
-                    Memory_Block *old_block = (Memory_Block*)(*buffer_flags & ~3);
+                    Memory_Block *old_block = Buffer_pool(b);
 
                     if (!block_is_almost_full(old_block))
                         cur_spot = move_one_buffer(interp, new_block, b, cur_spot);
@@ -615,7 +614,7 @@
         * strstart might be in unallocated memory */
     if (PObj_is_COWable_TEST(old_buf)) {
         flags = Buffer_bufrefcountptr(old_buf);
-        old_block = (Memory_Block *)(*flags & ~3);
+        old_block = Buffer_pool(old_buf);
 
         if (PObj_is_string_TEST(old_buf)) {
             offset = (ptrdiff_t)((STRING *)old_buf)->strstart -
@@ -668,7 +667,7 @@
         Buffer_bufstart(old_buf) = new_pool_ptr;
 
         /* Remember new pool inside */
-        *Buffer_bufrefcountptr(old_buf) = pool;
+        *Buffer_pool(old_buf) = pool;
 
         if (PObj_is_string_TEST(old_buf))
             ((STRING *)old_buf)->strstart =

Modified: branches/compact_pool_revamp/src/gc/gc_ms.c
==============================================================================
--- branches/compact_pool_revamp/src/gc/gc_ms.c	Mon Apr 26 10:53:47 2010	(r46028)
+++ branches/compact_pool_revamp/src/gc/gc_ms.c	Mon Apr 26 11:59:16 2010	(r46029)
@@ -841,7 +841,7 @@
         interp->mem_pools, new_size, interp->mem_pools->memory_pool));
 
     /* Save pool used to allocate into buffer header */
-    *Buffer_bufrefcountptr(buffer) = interp->mem_pools->memory_pool;
+    *Buffer_poolptr(buffer) = interp->mem_pools->memory_pool->top_block;
 
     Buffer_buflen(buffer)   = new_size - sizeof (void *);
 }
@@ -912,7 +912,7 @@
     Buffer_buflen(buffer) = new_size;
 
     /* Save pool used to allocate into buffer header */
-    *Buffer_bufrefcountptr(buffer) = interp->mem_pools->memory_pool;
+    *Buffer_poolptr(buffer) = interp->mem_pools->memory_pool->top_block;
 }
 
 /*
@@ -956,7 +956,7 @@
     Buffer_buflen(str)   = new_size - sizeof (void *);
 
     /* Save pool used to allocate into buffer header */
-    *Buffer_bufrefcountptr(str) = pool;
+    *Buffer_poolptr(str) = pool->top_block;
 }
 
 /*
@@ -1027,7 +1027,7 @@
         memcpy(mem, oldmem, copysize);
 
     /* Save pool used to allocate into buffer header */
-    *Buffer_bufrefcountptr(str) = pool;
+    *Buffer_poolptr(str) = pool->top_block;
 }
 
 /*

Modified: branches/compact_pool_revamp/src/gc/mark_sweep.c
==============================================================================
--- branches/compact_pool_revamp/src/gc/mark_sweep.c	Mon Apr 26 10:53:47 2010	(r46028)
+++ branches/compact_pool_revamp/src/gc/mark_sweep.c	Mon Apr 26 11:59:16 2010	(r46029)
@@ -713,10 +713,10 @@
     if (mem_pool) {
         /* Update Memory_Block usage */
         if (PObj_is_movable_TESTALL(b)) {
-            INTVAL *buffer_flags = buffer_flags = Buffer_bufrefcountptr(b);
+            INTVAL *buffer_flags = Buffer_bufrefcountptr(b);
 
             /* Mask low 2 bits used for flags */
-            Memory_Block * block = (Memory_Block *)(*buffer_flags & ~3);
+            Memory_Block * block = Buffer_pool(b);
 
             PARROT_ASSERT(block);
 


More information about the parrot-commits mailing list