[svn:parrot] r43286 - in branches/boehm_gc: include/parrot src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Dec 28 22:13:17 UTC 2009
Author: bacek
Date: Mon Dec 28 22:13:16 2009
New Revision: 43286
URL: https://trac.parrot.org/parrot/changeset/43286
Log:
Add Parrot_gc_switch function to switch GC in "run-time"
Modified:
branches/boehm_gc/include/parrot/gc_api.h
branches/boehm_gc/src/gc/api.c
Modified: branches/boehm_gc/include/parrot/gc_api.h
==============================================================================
--- branches/boehm_gc/include/parrot/gc_api.h Mon Dec 28 22:12:52 2009 (r43285)
+++ branches/boehm_gc/include/parrot/gc_api.h Mon Dec 28 22:13:16 2009 (r43286)
@@ -125,6 +125,10 @@
FUNC_MODIFIES(*obj);
PARROT_EXPORT
+void Parrot_gc_switch(PARROT_INTERP, INTVAL gc)
+ __attribute__nonnull__(1);
+
+PARROT_EXPORT
unsigned int Parrot_is_blocked_GC_mark(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -327,6 +331,8 @@
#define ASSERT_ARGS_Parrot_gc_mark_STRING_alive_fun \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_Parrot_gc_switch __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_is_blocked_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_is_blocked_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Modified: branches/boehm_gc/src/gc/api.c
==============================================================================
--- branches/boehm_gc/src/gc/api.c Mon Dec 28 22:12:52 2009 (r43285)
+++ branches/boehm_gc/src/gc/api.c Mon Dec 28 22:13:16 2009 (r43286)
@@ -337,6 +337,9 @@
case INF:
Parrot_gc_inf_init(interp);
break;
+ case BOEHM_GC:
+ Parrot_gc_boehm_init(interp);
+ break;
default:
/*die horribly because of invalid GC core specified*/
break;
@@ -366,6 +369,43 @@
interp->gc_sys->finalize_gc_system(interp);
}
+/*
+
+=item C<void Parrot_gc_switch(PARROT_INTERP, INTVAL gc)>
+
+Switch GC to different implementations.
+
+Ugly hack because command-line args parsed after initializing GC.
+
+=cut
+
+*/
+PARROT_EXPORT
+void
+Parrot_gc_switch(PARROT_INTERP, INTVAL gc)
+{
+ ASSERT_ARGS(Parrot_gc_switch)
+
+ /* Finalize old GC */
+ Parrot_gc_finalize(interp);
+
+ /*Call appropriate initialization function for GC subsystem*/
+ switch (gc) {
+ case MS:
+ Parrot_gc_ms_init(interp);
+ break;
+ case INF:
+ Parrot_gc_inf_init(interp);
+ break;
+ case BOEHM_GC:
+ Parrot_gc_boehm_init(interp);
+ break;
+ default:
+ /*die horribly because of invalid GC core specified*/
+ break;
+ }
+
+}
/*
More information about the parrot-commits
mailing list