[svn:parrot] r49041 - branches/string_gc_split/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Sep 16 08:35:50 UTC 2010
Author: bacek
Date: Thu Sep 16 08:35:50 2010
New Revision: 49041
URL: https://trac.parrot.org/parrot/changeset/49041
Log:
Copy-paste logic for iterating live STRING/Buffer from compact_pool into gc_ms_iterate_live_strings.
Modified:
branches/string_gc_split/src/gc/gc_ms.c
Modified: branches/string_gc_split/src/gc/gc_ms.c
==============================================================================
--- branches/string_gc_split/src/gc/gc_ms.c Thu Sep 16 08:35:29 2010 (r49040)
+++ branches/string_gc_split/src/gc/gc_ms.c Thu Sep 16 08:35:50 2010 (r49041)
@@ -162,6 +162,10 @@
static unsigned int gc_ms_is_blocked_GC_sweep(PARROT_INTERP)
__attribute__nonnull__(1);
+static void gc_ms_iterate_live_strings(PARROT_INTERP,
+ string_iterator_callback callback)
+ __attribute__nonnull__(1);
+
static void gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
__attribute__nonnull__(1);
@@ -327,6 +331,8 @@
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_is_blocked_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_ms_iterate_live_strings __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_mark_special __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -456,6 +462,8 @@
interp->gc_sys->get_gc_info = gc_ms_get_gc_info;
+ interp->gc_sys->iterate_live_strings = gc_ms_iterate_live_strings;
+
initialize_var_size_pools(interp, interp->mem_pools);
initialize_fixed_size_pools(interp, interp->mem_pools);
Parrot_gc_initialize_fixed_size_pools(interp, interp->mem_pools,
@@ -1878,6 +1886,50 @@
}
/*
+=item C<static void gc_ms_iterate_live_strings(PARROT_INTERP,
+string_iterator_callback callback)>
+
+Iterate over live string invoking callback for each of them. Used during
+compacting of string pool.
+
+=cut
+*/
+static void
+gc_ms_iterate_live_strings(PARROT_INTERP, string_iterator_callback callback)
+{
+ ASSERT_ARGS(gc_ms_iterate_live_strings)
+
+ Memory_Pools * const mem_pools = interp->mem_pools;
+ INTVAL j;
+
+ /* Run through all the Buffer header pools and invoke callback */
+ for (j = (INTVAL)mem_pools->num_sized - 1; j >= 0; --j) {
+ Fixed_Size_Pool * const header_pool = mem_pools->sized_header_pools[j];
+ Fixed_Size_Arena * cur_buffer_arena;
+ UINTVAL object_size;
+
+ if (!header_pool)
+ continue;
+
+ object_size = header_pool->object_size;
+
+ for (cur_buffer_arena = header_pool->last_Arena;
+ cur_buffer_arena;
+ cur_buffer_arena = cur_buffer_arena->prev) {
+ Buffer *b = (Buffer *) cur_buffer_arena->start_objects;
+ UINTVAL i;
+ const size_t objects_end = cur_buffer_arena->used;
+
+ for (i = objects_end; i; --i) {
+ callback(interp, b);
+ b = (Buffer *)((char *)b + object_size);
+ }
+ }
+ }
+}
+
+
+/*
=back
More information about the parrot-commits
mailing list