[svn:parrot] r46020 - in trunk: include/parrot src/gc src/string
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Apr 26 05:43:33 UTC 2010
Author: bacek
Date: Mon Apr 26 05:43:32 2010
New Revision: 46020
URL: https://trac.parrot.org/parrot/changeset/46020
Log:
Remove PObj_COW_FLAG. We don't need it anymore
Modified:
trunk/include/parrot/pobj.h
trunk/include/parrot/string.h
trunk/src/gc/alloc_resources.c
trunk/src/gc/gc_ms.c
trunk/src/gc/mark_sweep.c
trunk/src/string/api.c
Modified: trunk/include/parrot/pobj.h
==============================================================================
--- trunk/include/parrot/pobj.h Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/include/parrot/pobj.h Mon Apr 26 05:43:32 2010 (r46020)
@@ -142,8 +142,6 @@
PObj_sysmem_FLAG = POBJ_FLAG(15),
/* PObj usage FLAGs, COW & GC */
- /* Mark the contents as Copy On Write, that we are piggybacking on another string. */
- PObj_COW_FLAG = POBJ_FLAG(16),
/* The Buffer allows COW copies, and may have some. */
PObj_is_COWable_FLAG = POBJ_FLAG(17),
/* Private flag for the GC system. Set if the PObj's in use as
@@ -208,10 +206,6 @@
#define PObj_flags_SETTO(o, f) PObj_get_FLAGS(o) = (f)
#define PObj_flags_CLEARALL(o) PObj_flags_SETTO((o), 0)
-#define PObj_COW_TEST(o) PObj_flag_TEST(COW, o)
-#define PObj_COW_SET(o) PObj_flag_SET(COW, o)
-#define PObj_COW_CLEAR(o) PObj_flag_CLEAR(COW, o)
-
#define PObj_is_COWable_TEST(o) PObj_flag_TEST(is_COWable, o)
#define PObj_is_COWable_SET(o) PObj_flag_SET(is_COWable, o)
@@ -302,17 +296,11 @@
#define PObj_is_shared_CLEAR(o) PObj_flag_CLEAR(is_shared, o)
/* some combinations */
-#define PObj_is_cowed_TESTALL(o) (PObj_get_FLAGS(o) & \
- (PObj_COW_FLAG|PObj_constant_FLAG|PObj_external_FLAG))
-#define PObj_is_cowed_SETALL(o) (PObj_get_FLAGS(o) |= \
- (PObj_COW_FLAG|PObj_constant_FLAG|PObj_external_FLAG))
-
#define PObj_is_external_or_free_TESTALL(o) (PObj_get_FLAGS(o) & \
(UINTVAL)(PObj_external_FLAG|PObj_on_free_list_FLAG))
#define PObj_is_external_CLEARALL(o) (PObj_get_FLAGS(o) &= \
- ~(UINTVAL)(PObj_COW_FLAG| \
- PObj_external_FLAG|PObj_sysmem_FLAG))
+ ~(UINTVAL)(PObj_external_FLAG|PObj_sysmem_FLAG))
#define PObj_is_live_or_free_TESTALL(o) (PObj_get_FLAGS(o) & \
(PObj_live_FLAG | PObj_on_free_list_FLAG))
Modified: trunk/include/parrot/string.h
==============================================================================
--- trunk/include/parrot/string.h Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/include/parrot/string.h Mon Apr 26 05:43:32 2010 (r46020)
@@ -24,7 +24,8 @@
typedef struct parrot_string_t STRING;
typedef enum Forward_flag {
- Buffer_moved_FLAG = 1 << 0
+ Buffer_moved_FLAG = 1 << 0,
+ Buffer_shared_FLAG = 1 << 1
} Forward_flags;
/* String iterator */
Modified: trunk/src/gc/alloc_resources.c
==============================================================================
--- trunk/src/gc/alloc_resources.c Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/src/gc/alloc_resources.c Mon Apr 26 05:43:32 2010 (r46020)
@@ -601,15 +601,16 @@
}
/* buffer has already been moved; just change the header */
- if (PObj_COW_TEST(old_buf)
- && (flags && *flags & Buffer_moved_FLAG)) {
+ 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 */
- PObj_COW_SET(hdr);
+ /* Set Buffer_shared_FLAG in new buffer */
+ *Buffer_bufrefcountptr(hdr) |= Buffer_shared_FLAG;
/* Now make sure we point to where the other guy does */
Buffer_bufstart(old_buf) = Buffer_bufstart(hdr);
@@ -628,26 +629,27 @@
memcpy(new_pool_ptr, Buffer_bufstart(old_buf),
Buffer_buflen(old_buf));
- /* If we're COW */
- if (PObj_COW_TEST(old_buf)) {
+ /* If we're shared */
+ if (flags && (*flags & Buffer_shared_FLAG)) {
PARROT_ASSERT(PObj_is_COWable_TEST(old_buf));
/* Let the old buffer know how to find us */
*((Buffer **)Buffer_bufstart(old_buf)) = old_buf;
- /* No guarantees that our data is still COW, so
- * assume not, and let the above code fix-up */
- PObj_COW_CLEAR(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 */
- if (flags)
- *flags |= Buffer_moved_FLAG;
+ *flags |= Buffer_moved_FLAG;
}
Buffer_bufstart(old_buf) = new_pool_ptr;
+ /* No guarantees that our data is still shared, so
+ * assume not, and let the above code fix-up */
+ /* Drop shared FLAG in new buffer */
+ *Buffer_bufrefcountptr(old_buf) &= ~Buffer_shared_FLAG;
+
+
if (PObj_is_string_TEST(old_buf))
((STRING *)old_buf)->strstart =
(char *)Buffer_bufstart(old_buf) + offset;
Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/src/gc/gc_ms.c Mon Apr 26 05:43:32 2010 (r46020)
@@ -894,11 +894,6 @@
copysize = Buffer_buflen(buffer);
- if (!PObj_COW_TEST(buffer))
- pool->guaranteed_reclaimable += copysize;
- else
- pool->possibly_reclaimable += copysize;
-
mem = (char *)mem_allocate(interp, interp->mem_pools, new_size, pool);
mem = aligned_mem(buffer, mem);
@@ -1008,11 +1003,6 @@
/* only copy used memory, not total string buffer */
copysize = str->bufused;
- if (!PObj_COW_TEST(str))
- pool->guaranteed_reclaimable += Buffer_buflen(str);
- else
- pool->possibly_reclaimable += Buffer_buflen(str);
-
mem = (char *)mem_allocate(interp, interp->mem_pools, new_size, pool);
mem += sizeof (void *);
Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/src/gc/mark_sweep.c Mon Apr 26 05:43:32 2010 (r46020)
@@ -704,15 +704,6 @@
ASSERT_ARGS(free_buffer)
Variable_Size_Pool * const mem_pool = (Variable_Size_Pool *)pool->mem_pool;
- /* XXX Jarkko reported that on irix pool->mem_pool was NULL, which really
- * shouldn't happen */
- if (mem_pool) {
- if (!PObj_COW_TEST(b))
- mem_pool->guaranteed_reclaimable += Buffer_buflen(b);
- else
- mem_pool->possibly_reclaimable += Buffer_buflen(b);
- }
-
Buffer_buflen(b) = 0;
}
Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c Mon Apr 26 05:04:25 2010 (r46019)
+++ trunk/src/string/api.c Mon Apr 26 05:43:32 2010 (r46020)
@@ -374,25 +374,19 @@
/* We set COW flag to avoid cloning buffer in compact_pool */
- if (PObj_constant_TEST(s)) {
- d = Parrot_gc_new_string_header(interp,
- PObj_get_FLAGS(s) & ~PObj_constant_FLAG);
- PObj_COW_SET(s);
- STRUCT_COPY(d, s);
- /* we can't move the memory, because constants aren't
- * scanned in compact_pool, therefore the other end
- * would point to garbage.
- */
- PObj_constant_CLEAR(d);
- PObj_external_SET(d);
- }
- else {
- d = Parrot_gc_new_string_header(interp, PObj_get_FLAGS(s));
- PObj_COW_SET(s);
- STRUCT_COPY(d, s);
- PObj_sysmem_CLEAR(d);
+ d = Parrot_gc_new_string_header(interp,
+ PObj_get_FLAGS(s) & ~PObj_constant_FLAG);
+ STRUCT_COPY(d, s);
+
+ /* Now check that buffer allocated from pool and affected by compacting */
+ if (PObj_is_movable_TESTALL(s)) {
+ /* If so, mark it as shared */
+ INTVAL *buffer_flags = Buffer_bufrefcountptr(d);
+ *buffer_flags |= Buffer_shared_FLAG;
}
+ PARROT_ASSERT(PObj_is_movable_TESTALL(s) == PObj_is_movable_TESTALL(d));
+
return d;
}
More information about the parrot-commits
mailing list