[svn:parrot] r41460 - in trunk: include/parrot src/gc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Fri Sep 25 00:58:19 UTC 2009
Author: chromatic
Date: Fri Sep 25 00:58:19 2009
New Revision: 41460
URL: https://trac.parrot.org/parrot/changeset/41460
Log:
[GC] Improved Parrot_gc_mark_PMC_alive() and Parrot_gc_mark_STRING_alive() such
that their backing functions now do all of the necessary work on their own,
which means avoiding costly branch prediction misses in
Parrot_gc_mark_PObj_alive(). As well, in the -DNDEBUG case, these macros can
prevent unnecessary calls for live PMCs and *inline* the STRING marking
directly, avoiding the need for function calls.
This produced 71.749% fewer icache misses in the oofib.pir benchmark.
Modified:
trunk/include/parrot/gc_api.h
trunk/src/gc/api.c
Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h Fri Sep 25 00:58:12 2009 (r41459)
+++ trunk/include/parrot/gc_api.h Fri Sep 25 00:58:19 2009 (r41460)
@@ -466,9 +466,16 @@
#ifdef NDEBUG
# define Parrot_gc_mark_PMC_alive(interp, obj) \
- do if (! PMC_IS_NULL(obj)) Parrot_gc_mark_PObj_alive((interp), (PObj *)(obj)); while (0)
-# define Parrot_gc_mark_STRING_alive(interp, obj) \
- do if (! STRING_IS_NULL(obj)) Parrot_gc_mark_PObj_alive((interp), (PObj *)(obj)); while (0)
+ do if (! PMC_IS_NULL(obj) && !PObj_is_live_or_free_TESTALL(obj)) \
+ Parrot_gc_mark_PMC_alive_fun((interp), (obj)); while (0)
+# ifdef PARROT_IN_CORE
+# define Parrot_gc_mark_STRING_alive(interp, obj) \
+ do if (! STRING_IS_NULL(obj) ) PObj_live_SET(obj); while (0)
+# else
+# define Parrot_gc_mark_STRING_alive(interp, obj) \
+ do if (! STRING_IS_NULL(obj) && !PObj_is_live_or_free_TESTALL(obj)) \
+ Parrot_gc_mark_STRING_alive_fun((interp), (obj)); while (0)
+# endif
#else
# define Parrot_gc_mark_PMC_alive(interp, obj) Parrot_gc_mark_PMC_alive_fun((interp), (obj))
# define Parrot_gc_mark_STRING_alive(interp, obj) Parrot_gc_mark_STRING_alive_fun((interp), (obj))
Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c Fri Sep 25 00:58:12 2009 (r41459)
+++ trunk/src/gc/api.c Fri Sep 25 00:58:19 2009 (r41460)
@@ -251,7 +251,16 @@
ASSERT_ARGS(Parrot_gc_mark_PMC_alive_fun)
if (!PMC_IS_NULL(obj)) {
PARROT_ASSERT(PObj_is_PMC_TEST(obj));
- Parrot_gc_mark_PObj_alive(interp, (PObj *)obj);
+
+ /* mark it live */
+ PObj_live_SET(obj);
+
+ /* if object is a PMC and contains buffers or PMCs, then attach the PMC
+ * to the chained mark list. */
+ if (PObj_is_special_PMC_TEST(obj))
+ mark_special(interp, obj);
+ else if (PMC_metadata(obj))
+ Parrot_gc_mark_PMC_alive(interp, PMC_metadata(obj));
}
}
@@ -272,7 +281,9 @@
ASSERT_ARGS(Parrot_gc_mark_STRING_alive_fun)
if (!STRING_IS_NULL(obj)) {
PARROT_ASSERT(PObj_is_string_TEST(obj));
- Parrot_gc_mark_PObj_alive(interp, (PObj *)obj);
+
+ /* mark it live */
+ PObj_live_SET(obj);
}
}
More information about the parrot-commits
mailing list