[svn:parrot] r44313 - branches/boehm_gc_2/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Feb 22 21:34:53 UTC 2010
Author: bacek
Date: Mon Feb 22 21:34:51 2010
New Revision: 44313
URL: https://trac.parrot.org/parrot/changeset/44313
Log:
Update GC Boehm to recent API
Modified:
branches/boehm_gc_2/src/gc/gc_boehm.c
branches/boehm_gc_2/src/gc/gc_private.h
Modified: branches/boehm_gc_2/src/gc/gc_boehm.c
==============================================================================
--- branches/boehm_gc_2/src/gc/gc_boehm.c Mon Feb 22 21:34:30 2010 (r44312)
+++ branches/boehm_gc_2/src/gc/gc_boehm.c Mon Feb 22 21:34:51 2010 (r44313)
@@ -23,6 +23,8 @@
#include <gc_typed.h>
typedef struct boehm_gc_data {
+ size_t block_level; /* GC disable counter */
+
GC_word pmc_layout[GC_BITMAP_SIZE(PMC)];
GC_descr pmc_descriptor;
@@ -53,6 +55,13 @@
size_t size)
__attribute__nonnull__(1);
+static void * gc_boehm_allocate_memory_chunk(PARROT_INTERP, size_t size)
+ __attribute__nonnull__(1);
+
+static void * gc_boehm_allocate_memory_chunk_zeroed(PARROT_INTERP,
+ size_t size)
+ __attribute__nonnull__(1);
+
static void* gc_boehm_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)
__attribute__nonnull__(1);
@@ -67,6 +76,9 @@
size_t size)
__attribute__nonnull__(1);
+static void gc_boehm_block_mark(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
static void gc_boehm_compact_memory_pool(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -84,6 +96,9 @@
void *data)
__attribute__nonnull__(1);
+static void gc_boehm_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
+ __attribute__nonnull__(1);
+
static void gc_boehm_free_pmc_attributes(PARROT_INTERP, PMC *pmc)
__attribute__nonnull__(1);
@@ -104,11 +119,25 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*buffer);
+static void * gc_boehm_reallocate_memory_chunk(PARROT_INTERP,
+ ARGFREE(void *data),
+ size_t newsize)
+ __attribute__nonnull__(1);
+
+static void * gc_boehm_reallocate_memory_chunk_zeroed(PARROT_INTERP,
+ ARGFREE(void *data),
+ size_t newsize,
+ size_t oldsize)
+ __attribute__nonnull__(1);
+
static void gc_boehm_reallocate_string_storage(PARROT_INTERP,
STRING *str,
size_t size)
__attribute__nonnull__(1);
+static void gc_boehm_unblock_mark(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
#define ASSERT_ARGS_gc_boehm_allocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -119,6 +148,12 @@
#define ASSERT_ARGS_gc_boehm_allocate_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_allocate_memory_chunk \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_allocate_memory_chunk_zeroed \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_allocate_pmc_attributes \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
@@ -130,6 +165,8 @@
#define ASSERT_ARGS_gc_boehm_allocate_string_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_block_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_compact_memory_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_finalize_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -141,6 +178,8 @@
#define ASSERT_ARGS_gc_boehm_free_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_free_pmc_attributes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -154,9 +193,17 @@
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(buffer))
+#define ASSERT_ARGS_gc_boehm_reallocate_memory_chunk \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_reallocate_memory_chunk_zeroed \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_boehm_reallocate_string_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_unblock_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -405,6 +452,66 @@
/*
+=item C<static void * gc_boehm_allocate_memory_chunk(PARROT_INTERP, size_t
+size)>
+
+=item C<static void * gc_boehm_reallocate_memory_chunk(PARROT_INTERP, void
+*data, size_t newsize)>
+
+=item C<static void * gc_boehm_allocate_memory_chunk_zeroed(PARROT_INTERP,
+size_t size)>
+
+=item C<static void * gc_boehm_reallocate_memory_chunk_zeroed(PARROT_INTERP,
+void *data, size_t newsize, size_t oldsize)>
+
+=item C<static void gc_boehm_free_memory_chunk(PARROT_INTERP, void *data)>
+
+TODO Write docu.
+
+*/
+
+static void *
+gc_boehm_allocate_memory_chunk(PARROT_INTERP, size_t size)
+{
+ ASSERT_ARGS(gc_boehm_allocate_memory_chunk)
+ return GC_MALLOC_ATOMIC(size);
+}
+
+static void *
+gc_boehm_reallocate_memory_chunk(PARROT_INTERP, ARGFREE(void *data), size_t newsize)
+{
+ ASSERT_ARGS(gc_boehm_reallocate_memory_chunk)
+ return GC_REALLOC(data, newsize);
+}
+
+static void *
+gc_boehm_allocate_memory_chunk_zeroed(PARROT_INTERP, size_t size)
+{
+ ASSERT_ARGS(gc_boehm_allocate_memory_chunk_zeroed)
+ return GC_MALLOC(size);
+}
+
+static void *
+gc_boehm_reallocate_memory_chunk_zeroed(PARROT_INTERP, ARGFREE(void *data),
+ size_t newsize, size_t oldsize)
+{
+ ASSERT_ARGS(gc_boehm_reallocate_memory_chunk_zeroed)
+ void * const ptr = GC_REALLOC(data, newsize);
+ if (newsize > oldsize)
+ memset((char*)ptr + oldsize, 0, newsize - oldsize);
+ return ptr;
+}
+
+static void
+gc_boehm_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
+{
+ ASSERT_ARGS(gc_boehm_free_memory_chunk)
+ if (data)
+ GC_FREE(data);
+}
+
+/*
+
=item C<static size_t gc_boehm_get_gc_info(PARROT_INTERP, Interpinfo_enum what)>
Stub for GC introspection function.
@@ -439,7 +546,33 @@
Parrot_pmc_destroy(interp, pmc);
}
+static void
+gc_boehm_block_mark(PARROT_INTERP)
+{
+ ASSERT_ARGS(gc_boehm_block_mark)
+ boehm_gc_data *d = (boehm_gc_data*)interp->gc_sys->gc_private;
+ GC_disable();
+ d->block_level++;
+}
+
+static void
+gc_boehm_unblock_mark(PARROT_INTERP)
+{
+ ASSERT_ARGS(gc_boehm_unblock_mark)
+ boehm_gc_data *d = (boehm_gc_data*)interp->gc_sys->gc_private;
+ if (d->block_level) {
+ GC_enable();
+ --d->block_level;
+ }
+}
+unsigned int
+gc_boehm_is_blocked_mark(PARROT_INTERP)
+{
+ ASSERT_ARGS(gc_boehm_is_blocked_mark)
+ boehm_gc_data *d = (boehm_gc_data*)interp->gc_sys->gc_private;
+ return d->block_level;
+}
/*
@@ -463,6 +596,8 @@
boehm_gc_data *gc_private = (boehm_gc_data*)GC_MALLOC_ATOMIC(sizeof(boehm_gc_data));
+ gc_private->block_level = 0;
+
/* Generate bitmaps for allocatable objects */
/* PMC layout */
@@ -510,6 +645,18 @@
gc_sys->allocate_fixed_size_storage = gc_boehm_allocate_fixed_size_storage;
gc_sys->free_fixed_size_storage = gc_boehm_free_fixed_size_storage;
+ gc_sys->allocate_memory_chunk = gc_boehm_allocate_memory_chunk;
+ gc_sys->reallocate_memory_chunk = gc_boehm_reallocate_memory_chunk;
+ gc_sys->allocate_memory_chunk_with_interior_pointers
+ = gc_boehm_allocate_memory_chunk_zeroed;
+ gc_sys->reallocate_memory_chunk_with_interior_pointers
+ = gc_boehm_reallocate_memory_chunk_zeroed;
+ gc_sys->free_memory_chunk = gc_boehm_free_memory_chunk;
+
+ gc_sys->block_mark = gc_boehm_block_mark;
+ gc_sys->unblock_mark = gc_boehm_unblock_mark;
+ gc_sys->is_blocked_mark = gc_boehm_is_blocked_mark;
+
gc_sys->get_gc_info = gc_boehm_get_gc_info;
}
Modified: branches/boehm_gc_2/src/gc/gc_private.h
==============================================================================
--- branches/boehm_gc_2/src/gc/gc_private.h Mon Feb 22 21:34:30 2010 (r44312)
+++ branches/boehm_gc_2/src/gc/gc_private.h Mon Feb 22 21:34:51 2010 (r44313)
@@ -678,9 +678,14 @@
/* HEADERIZER BEGIN: src/gc/gc_boehm.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+unsigned int gc_boehm_is_blocked_mark(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
void Parrot_gc_boehm_init(PARROT_INTERP)
__attribute__nonnull__(1);
+#define ASSERT_ARGS_gc_boehm_is_blocked_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_gc_boehm_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
More information about the parrot-commits
mailing list