[svn:parrot] r48372 - in branches/unshared_buffers: include/parrot src/gc

darbelo at svn.parrot.org darbelo at svn.parrot.org
Mon Aug 9 21:09:18 UTC 2010


Author: darbelo
Date: Mon Aug  9 21:09:18 2010
New Revision: 48372
URL: https://trac.parrot.org/parrot/changeset/48372

Log:
Remove the buffer flags used to tag the low bits of the pool pointer. They are irrelevant if we aren't sharing buffers anymore.

Modified:
   branches/unshared_buffers/include/parrot/string.h
   branches/unshared_buffers/src/gc/alloc_resources.c
   branches/unshared_buffers/src/gc/gc_ms.c
   branches/unshared_buffers/src/gc/mark_sweep.c

Modified: branches/unshared_buffers/include/parrot/string.h
==============================================================================
--- branches/unshared_buffers/include/parrot/string.h	Mon Aug  9 21:09:00 2010	(r48371)
+++ branches/unshared_buffers/include/parrot/string.h	Mon Aug  9 21:09:18 2010	(r48372)
@@ -23,11 +23,6 @@
 
 typedef struct parrot_string_t STRING;
 
-typedef enum Forward_flag {
-    Buffer_moved_FLAG   = 1 << 0,
-    Buffer_shared_FLAG  = 1 << 1
-} Forward_flags;
-
 /* String iterator */
 typedef struct string_iterator_t {
     const STRING *str;

Modified: branches/unshared_buffers/src/gc/alloc_resources.c
==============================================================================
--- branches/unshared_buffers/src/gc/alloc_resources.c	Mon Aug  9 21:09:00 2010	(r48371)
+++ branches/unshared_buffers/src/gc/alloc_resources.c	Mon Aug  9 21:09:18 2010	(r48372)
@@ -598,10 +598,6 @@
         ARGMOD(Buffer *old_buf), ARGMOD(char *new_pool_ptr))
 {
     ASSERT_ARGS(move_one_buffer)
-
-    INTVAL       *flags     = NULL;
-    ptrdiff_t     offset    = 0;
-    Memory_Block *old_block = NULL;
 #if RESOURCE_DEBUG
     if (Buffer_buflen(old_buf) >= RESOURCE_DEBUG_SIZE)
         debug_print_buf(interp, old_buf);
@@ -609,54 +605,18 @@
     UNUSED(interp);
 #endif
 
-    if (PObj_is_COWable_TEST(old_buf)) {
-        flags = Buffer_bufrefcountptr(old_buf);
-        old_block = Buffer_pool(old_buf);
-    }
-
-    /* buffer has already been moved; just change the header */
-    if (flags && (*flags & Buffer_shared_FLAG)
-              && (*flags & Buffer_moved_FLAG)) {
-        /* Find out who else references our data */
-        Buffer * const hdr = *((Buffer **)Buffer_bufstart(old_buf));
-
-        PARROT_ASSERT(PObj_is_COWable_TEST(old_buf));
-
-        /* Make sure they know that we own it too */
-        /* Set Buffer_shared_FLAG in new buffer */
-        *Buffer_bufrefcountptr(hdr) |= Buffer_shared_FLAG;
+    new_pool_ptr = aligned_mem(old_buf, new_pool_ptr);
 
-        /* Now make sure we point to where the other guy does */
-        Buffer_bufstart(old_buf) = Buffer_bufstart(hdr);
-    }
-    else {
-        new_pool_ptr = aligned_mem(old_buf, new_pool_ptr);
+    /* Copy our memory to the new pool */
+    memcpy(new_pool_ptr, Buffer_bufstart(old_buf),
+        Buffer_buflen(old_buf));
 
-        /* Copy our memory to the new pool */
-        memcpy(new_pool_ptr, Buffer_bufstart(old_buf),
-                                Buffer_buflen(old_buf));
-
-        /* If we're shared */
-        if (flags && (*flags & Buffer_shared_FLAG)) {
-            // Hmm. Can this be removed now?
-            PARROT_ASSERT(PObj_is_COWable_TEST(old_buf));
-
-            /* Let the old buffer know how to find us */
-            *((Buffer **)Buffer_bufstart(old_buf)) = old_buf;
-
-            /* Finally, let the tail know that we've moved, so
-                * that any other references can know to look for
-                * us and not re-copy */
-            *flags |= Buffer_moved_FLAG;
-        }
+    Buffer_bufstart(old_buf) = new_pool_ptr;
 
-        Buffer_bufstart(old_buf) = new_pool_ptr;
+    /* Remember new pool inside */
+    *Buffer_poolptr(old_buf) = pool;
 
-        /* Remember new pool inside */
-        *Buffer_poolptr(old_buf) = pool;
-
-        new_pool_ptr += Buffer_buflen(old_buf);
-    }
+    new_pool_ptr += Buffer_buflen(old_buf);
 
     return new_pool_ptr;
 }

Modified: branches/unshared_buffers/src/gc/gc_ms.c
==============================================================================
--- branches/unshared_buffers/src/gc/gc_ms.c	Mon Aug  9 21:09:00 2010	(r48371)
+++ branches/unshared_buffers/src/gc/gc_ms.c	Mon Aug  9 21:09:18 2010	(r48372)
@@ -1255,9 +1255,6 @@
     /* We must not reallocate non-movable buffers! */
     PARROT_ASSERT(PObj_is_movable_TESTALL(str));
 
-    /* We must not reallocate shared buffers! */
-    PARROT_ASSERT(!(*Buffer_bufrefcountptr(str) & Buffer_shared_FLAG));
-
     /* Decrease usage */
     PARROT_ASSERT(Buffer_pool(str));
     Buffer_pool(str)->freed  += ALIGNED_STRING_SIZE(Buffer_buflen(str));

Modified: branches/unshared_buffers/src/gc/mark_sweep.c
==============================================================================
--- branches/unshared_buffers/src/gc/mark_sweep.c	Mon Aug  9 21:09:00 2010	(r48371)
+++ branches/unshared_buffers/src/gc/mark_sweep.c	Mon Aug  9 21:09:18 2010	(r48372)
@@ -681,18 +681,12 @@
     if (mem_pool) {
         /* Update Memory_Block usage */
         if (PObj_is_movable_TESTALL(b)) {
-            INTVAL *buffer_flags = Buffer_bufrefcountptr(b);
-
             /* Mask low 2 bits used for flags */
             Memory_Block * block = Buffer_pool(b);
 
             PARROT_ASSERT(block);
 
-            /* We can have shared buffers. Don't count them (yet) */
-            if (!(*buffer_flags & Buffer_shared_FLAG)) {
-                block->freed  += ALIGNED_STRING_SIZE(Buffer_buflen(b));
-            }
-
+            block->freed  += ALIGNED_STRING_SIZE(Buffer_buflen(b));
         }
     }
 


More information about the parrot-commits mailing list