[svn:parrot] r43891 - in branches/boehm_gc_2: config/gen/makefiles src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Feb 11 12:43:22 UTC 2010


Author: bacek
Date: Thu Feb 11 12:43:21 2010
New Revision: 43891
URL: https://trac.parrot.org/parrot/changeset/43891

Log:
Copy gc_inf into gc_boehm and add it into build.

Added:
   branches/boehm_gc_2/src/gc/gc_boehm.c
Modified:
   branches/boehm_gc_2/config/gen/makefiles/root.in
   branches/boehm_gc_2/src/gc/gc_private.h

Modified: branches/boehm_gc_2/config/gen/makefiles/root.in
==============================================================================
--- branches/boehm_gc_2/config/gen/makefiles/root.in	Thu Feb 11 12:28:53 2010	(r43890)
+++ branches/boehm_gc_2/config/gen/makefiles/root.in	Thu Feb 11 12:43:21 2010	(r43891)
@@ -453,6 +453,7 @@
     src/extend_vtable$(O) \
     src/gc/alloc_memory$(O) \
     src/gc/api$(O) \
+    src/gc/gc_boehm$(O) \
     src/gc/gc_ms$(O) \
     src/gc/gc_inf$(O) \
     src/gc/mark_sweep$(O) \
@@ -1188,6 +1189,8 @@
 
 src/gc/mark_sweep$(O) : $(PARROT_H_HEADERS) src/gc/gc_private.h
 
+src/gc/gc_boehm$(O) : $(PARROT_H_HEADERS) src/gc/gc_private.h
+
 src/gc/gc_ms$(O) : $(PARROT_H_HEADERS) src/gc/gc_private.h
 
 src/gc/gc_inf$(O) : $(PARROT_H_HEADERS) src/gc/gc_private.h

Added: branches/boehm_gc_2/src/gc/gc_boehm.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/boehm_gc_2/src/gc/gc_boehm.c	Thu Feb 11 12:43:21 2010	(r43891)
@@ -0,0 +1,431 @@
+/*
+Copyright (C) 2001-2009, Parrot Foundation.
+$Id$
+
+=head1 NAME
+
+src/gc/gc_boehm.c - A Boehm GC
+
+=head1 DESCRIPTION
+
+TODO
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+#include "gc_private.h"
+
+#ifdef PARROT_HAS_BOEHM_GC
+
+/* HEADERIZER HFILE: src/gc/gc_private.h */
+
+/* HEADERIZER BEGIN: static */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+static void gc_boehm_allocate_buffer_storage(PARROT_INTERP,
+    ARGMOD(Buffer *buffer),
+    size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
+
+static Buffer* gc_boehm_allocate_bufferlike_header(PARROT_INTERP,
+    size_t size)
+        __attribute__nonnull__(1);
+
+static void* gc_boehm_allocate_fixed_size_storage(PARROT_INTERP,
+    size_t size)
+        __attribute__nonnull__(1);
+
+static void* gc_boehm_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)
+        __attribute__nonnull__(1);
+
+static PMC* gc_boehm_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
+        __attribute__nonnull__(1);
+
+static STRING* gc_boehm_allocate_string_header(PARROT_INTERP, UINTVAL flags)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_allocate_string_storage(PARROT_INTERP,
+    STRING *str,
+    size_t size)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_compact_memory_pool(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_free_bufferlike_header(PARROT_INTERP,
+    Buffer *b,
+    size_t size)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_free_fixed_size_storage(PARROT_INTERP,
+    size_t size,
+    void *data)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_free_pmc_attributes(PARROT_INTERP, PMC *pmc)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_free_pmc_header(PARROT_INTERP, PMC *pmc)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_free_string_header(PARROT_INTERP, STRING *s)
+        __attribute__nonnull__(1);
+
+static size_t gc_boehm_get_gc_info(PARROT_INTERP, Interpinfo_enum what)
+        __attribute__nonnull__(1);
+
+static void gc_boehm_mark_and_sweep(SHIM_INTERP, UINTVAL flags);
+static void gc_boehm_reallocate_buffer_storage(PARROT_INTERP,
+    ARGMOD(Buffer *buffer),
+    size_t size)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
+
+static void gc_boehm_reallocate_string_storage(PARROT_INTERP,
+    STRING *str,
+    size_t size)
+        __attribute__nonnull__(1);
+
+#define ASSERT_ARGS_gc_boehm_allocate_buffer_storage \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(buffer))
+#define ASSERT_ARGS_gc_boehm_allocate_bufferlike_header \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#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_pmc_attributes \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_allocate_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_allocate_string_header \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_allocate_string_storage \
+     __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_free_bufferlike_header \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#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_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 = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_get_gc_info __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_gc_boehm_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_gc_boehm_reallocate_buffer_storage \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(buffer))
+#define ASSERT_ARGS_gc_boehm_reallocate_string_storage \
+     __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 */
+
+/*
+
+=head1 Functions
+
+=over 4
+
+=item C<static void gc_boehm_mark_and_sweep(PARROT_INTERP, UINTVAL flags)>
+
+This function would perform a GC run.
+
+This function is called from the GC API function C<Parrot_gc_mark_and_sweep>.
+
+Flags can be a combination of these values:
+
+  GC_finish_FLAG
+  GC_lazy_FLAG
+  GC_trace_stack_FLAG
+
+=cut
+
+*/
+
+static void
+gc_boehm_mark_and_sweep(SHIM_INTERP, UINTVAL flags)
+{
+    ASSERT_ARGS(gc_boehm_mark_and_sweep)
+    UNUSED(flags);
+}
+
+/*
+
+=item C<static void gc_boehm_compact_memory_pool(PARROT_INTERP)>
+
+Stub for compacting memory pools.
+
+=cut
+
+*/
+static void
+gc_boehm_compact_memory_pool(PARROT_INTERP)
+{
+}
+
+/*
+
+=item C<static PMC* gc_boehm_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)>
+
+=item C<static void gc_boehm_free_pmc_header(PARROT_INTERP, PMC *pmc)>
+
+=item C<static STRING* gc_boehm_allocate_string_header(PARROT_INTERP, UINTVAL
+flags)>
+
+=item C<static void gc_boehm_free_string_header(PARROT_INTERP, STRING *s)>
+
+=item C<static Buffer* gc_boehm_allocate_bufferlike_header(PARROT_INTERP, size_t
+size)>
+
+=item C<static void gc_boehm_free_bufferlike_header(PARROT_INTERP, Buffer *b,
+size_t size)>
+
+=item C<static void* gc_boehm_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
+
+=item C<static void gc_boehm_free_pmc_attributes(PARROT_INTERP, PMC *pmc)>
+
+=item C<static void gc_boehm_allocate_string_storage(PARROT_INTERP, STRING *str,
+size_t size)>
+
+=item C<static void gc_boehm_reallocate_string_storage(PARROT_INTERP, STRING
+*str, size_t size)>
+
+=item C<static void gc_boehm_allocate_buffer_storage(PARROT_INTERP, Buffer
+*buffer, size_t size)>
+
+=item C<static void gc_boehm_reallocate_buffer_storage(PARROT_INTERP, Buffer
+*buffer, size_t size)>
+
+=item C<static void* gc_boehm_allocate_fixed_size_storage(PARROT_INTERP, size_t
+size)>
+
+=item C<static void gc_boehm_free_fixed_size_storage(PARROT_INTERP, size_t size,
+void *data)>
+
+Functions for allocating/deallocating various objects.
+
+*/
+
+static PMC*
+gc_boehm_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
+{
+    return (PMC*)calloc(sizeof(PMC), 1);
+}
+
+static void
+gc_boehm_free_pmc_header(PARROT_INTERP, PMC *pmc)
+{
+    if (pmc)
+        free(pmc);
+}
+
+
+static STRING*
+gc_boehm_allocate_string_header(PARROT_INTERP, UINTVAL flags)
+{
+    return (STRING*)calloc(sizeof(STRING), 1);
+}
+
+static void
+gc_boehm_free_string_header(PARROT_INTERP, STRING *s)
+{
+    if (s)
+        free(s);
+}
+
+
+static Buffer*
+gc_boehm_allocate_bufferlike_header(PARROT_INTERP, size_t size)
+{
+    return (Buffer*)calloc(sizeof(Buffer), 1);
+}
+
+static void
+gc_boehm_free_bufferlike_header(PARROT_INTERP, Buffer *b, size_t size)
+{
+    if (b)
+        free(b);
+}
+
+
+static void*
+gc_boehm_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)
+{
+    const size_t attr_size = pmc->vtable->attr_size;
+    PMC_data(pmc) = calloc(attr_size, 1);
+    return PMC_data(pmc);
+}
+
+static void
+gc_boehm_free_pmc_attributes(PARROT_INTERP, PMC *pmc)
+{
+    if (PMC_data(pmc))
+        free(PMC_data(pmc));
+}
+
+
+static void
+gc_boehm_allocate_string_storage(PARROT_INTERP, STRING *str, size_t size)
+{
+    char *mem;
+
+    Buffer_buflen(str)   = 0;
+    Buffer_bufstart(str) = NULL;
+
+    if (size == 0)
+        return;
+
+    mem      = (char *)mem_sys_allocate(size);
+
+    Buffer_bufstart(str) = str->strstart = mem;
+    Buffer_buflen(str)   = size;
+}
+
+static void
+gc_boehm_reallocate_string_storage(PARROT_INTERP, STRING *str, size_t size)
+{
+    char *mem;
+
+    mem      = (char *)mem_sys_realloc(Buffer_bufstart(str), size);
+
+    Buffer_bufstart(str) = str->strstart = mem;
+    Buffer_buflen(str)   = size;
+}
+
+static void
+gc_boehm_allocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t size)
+{
+    char *mem;
+
+    Buffer_buflen(buffer)   = 0;
+    Buffer_bufstart(buffer) = NULL;
+
+    if (size == 0)
+        return;
+
+    mem      = (char *)mem_sys_allocate(size);
+
+    Buffer_bufstart(buffer) = mem;
+    Buffer_buflen(buffer)   = size;
+}
+
+static void
+gc_boehm_reallocate_buffer_storage(PARROT_INTERP, ARGMOD(Buffer *buffer), size_t size)
+{
+    char *mem;
+
+    mem = (char *)mem_sys_realloc(Buffer_bufstart(buffer), size);
+
+    Buffer_bufstart(buffer) = mem;
+    Buffer_buflen(buffer)   = size;
+}
+
+
+static void*
+gc_boehm_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
+{
+    return calloc(size, 1);
+}
+
+static void
+gc_boehm_free_fixed_size_storage(PARROT_INTERP, size_t size, void *data)
+{
+    if (data)
+        free(data);
+}
+
+/*
+
+=item C<static size_t gc_boehm_get_gc_info(PARROT_INTERP, Interpinfo_enum what)>
+
+Stub for GC introspection function.
+
+=cut
+
+*/
+static size_t
+gc_boehm_get_gc_info(PARROT_INTERP, Interpinfo_enum what)
+{
+    return 0;
+}
+
+
+/*
+
+=item C<void Parrot_gc_boehm_init(PARROT_INTERP)>
+
+=cut
+
+*/
+
+void
+Parrot_gc_boehm_init(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_gc_boehm_init)
+
+    interp->gc_sys->do_gc_mark         = gc_boehm_mark_and_sweep;
+    interp->gc_sys->finalize_gc_system = NULL;
+
+    interp->gc_sys->do_gc_mark              = gc_boehm_mark_and_sweep;
+    interp->gc_sys->compact_string_pool     = gc_boehm_compact_memory_pool;
+
+    interp->gc_sys->allocate_pmc_header     = gc_boehm_allocate_pmc_header;
+    interp->gc_sys->free_pmc_header         = gc_boehm_free_pmc_header;
+
+    interp->gc_sys->allocate_string_header  = gc_boehm_allocate_string_header;
+    interp->gc_sys->free_string_header      = gc_boehm_free_string_header;
+
+    interp->gc_sys->allocate_bufferlike_header  = gc_boehm_allocate_bufferlike_header;
+    interp->gc_sys->free_bufferlike_header      = gc_boehm_free_bufferlike_header;
+
+    interp->gc_sys->allocate_pmc_attributes = gc_boehm_allocate_pmc_attributes;
+    interp->gc_sys->free_pmc_attributes     = gc_boehm_free_pmc_attributes;
+
+    interp->gc_sys->allocate_string_storage = gc_boehm_allocate_string_storage;
+    interp->gc_sys->reallocate_string_storage = gc_boehm_reallocate_string_storage;
+
+    interp->gc_sys->allocate_buffer_storage = gc_boehm_allocate_buffer_storage;
+    interp->gc_sys->reallocate_buffer_storage = gc_boehm_reallocate_buffer_storage;
+
+    interp->gc_sys->allocate_fixed_size_storage = gc_boehm_allocate_fixed_size_storage;
+    interp->gc_sys->free_fixed_size_storage     = gc_boehm_free_fixed_size_storage;
+
+    interp->gc_sys->get_gc_info      = gc_boehm_get_gc_info;
+
+}
+
+#endif
+
+/*
+
+=back
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */

Modified: branches/boehm_gc_2/src/gc/gc_private.h
==============================================================================
--- branches/boehm_gc_2/src/gc/gc_private.h	Thu Feb 11 12:28:53 2010	(r43890)
+++ branches/boehm_gc_2/src/gc/gc_private.h	Thu Feb 11 12:43:21 2010	(r43891)
@@ -678,6 +678,17 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/gc_inf.c */
 
+/* HEADERIZER BEGIN: src/gc/gc_boehm.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+void Parrot_gc_boehm_init(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+#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. */
+/* HEADERIZER END: src/gc/gc_boehm.c */
+
 #endif /* PARROT_GC_PRIVATE_H_GUARD */
 
 


More information about the parrot-commits mailing list