[pypy-commit] stmgc default: fastpaths for stm_pointer_equal(_prebuilt)
Raemi
noreply at buildbot.pypy.org
Tue Oct 29 10:53:51 CET 2013
Author: Remi Meier <remi.meier at gmail.com>
Branch:
Changeset: r541:73c77375a8a6
Date: 2013-10-29 10:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/73c77375a8a6/
Log: fastpaths for stm_pointer_equal(_prebuilt)
diff --git a/c4/et.h b/c4/et.h
--- a/c4/et.h
+++ b/c4/et.h
@@ -72,7 +72,7 @@
static const revision_t GCFLAG_OLD = STM_FIRST_GCFLAG << 0;
static const revision_t GCFLAG_VISITED = STM_FIRST_GCFLAG << 1;
static const revision_t GCFLAG_PUBLIC = STM_FIRST_GCFLAG << 2;
-static const revision_t GCFLAG_PREBUILT_ORIGINAL = STM_FIRST_GCFLAG << 3;
+// in stmgc.h: GCFLAG_PREBUILT_ORIGINAL = STM_FIRST_GCFLAG << 3;
// in stmgc.h: GCFLAG_PUBLIC_TO_PRIVATE = STM_FIRST_GCFLAG << 4;
// in stmgc.h: GCFLAG_WRITE_BARRIER = STM_FIRST_GCFLAG << 5;
// in stmgc.h: GCFLAG_MOVED = STM_FIRST_GCFLAG << 6;
diff --git a/c4/extra.c b/c4/extra.c
--- a/c4/extra.c
+++ b/c4/extra.c
@@ -246,9 +246,10 @@
return result;
}
-_Bool stm_pointer_equal(gcptr p1, gcptr p2)
+_Bool stm_direct_pointer_equal(gcptr p1, gcptr p2)
{
- if (p1 != NULL && p2 != NULL) {
+ /* commented lines are in the fastpath in stmgc.h */
+ /* if (p1 != NULL && p2 != NULL) { */
/* resolve h_original, but only if !PREBUILT_ORIGINAL */
if (p1->h_original && !(p1->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
p1 = (gcptr)p1->h_original;
@@ -256,22 +257,23 @@
if (p2->h_original && !(p2->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
p2 = (gcptr)p2->h_original;
}
- }
+ /* } */
return (p1 == p2);
}
-_Bool stm_pointer_equal_prebuilt(gcptr p1, gcptr p2)
-{
- assert(p2 != NULL);
- assert(p2->h_tid & GCFLAG_PREBUILT_ORIGINAL);
+/* FULLY IMPLEMENTED AS MACRO IN stmgc.h */
+/* _Bool stm_pointer_equal_prebuilt(gcptr p1, gcptr p2) */
+/* { */
+/* assert(p2 != NULL); */
+/* assert(p2->h_tid & GCFLAG_PREBUILT_ORIGINAL); */
- if (p1 == p2)
- return 1;
+/* if (p1 == p2) */
+/* return 1; */
- /* the only possible case to still get True is if p2 == p1->h_original */
- return (p1 != NULL) && (p1->h_original == (revision_t)p2) &&
- !(p1->h_tid & GCFLAG_PREBUILT_ORIGINAL);
-}
+/* /\* the only possible case to still get True is if p2 == p1->h_original *\/ */
+/* return (p1 != NULL) && (p1->h_original == (revision_t)p2) && */
+/* !(p1->h_tid & GCFLAG_PREBUILT_ORIGINAL); */
+/* } */
/************************************************************/
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -94,7 +94,7 @@
return P;
}
-gcptr stm_allocate(size_t size, unsigned long tid)
+inline gcptr stm_allocate(size_t size, unsigned long tid)
{
/* XXX inline the fast path */
assert(tid == (tid & STM_USER_TID_MASK));
diff --git a/c4/stmgc.h b/c4/stmgc.h
--- a/c4/stmgc.h
+++ b/c4/stmgc.h
@@ -31,7 +31,7 @@
/* push roots around allocating functions! */
/* allocate an object out of the local nursery */
-gcptr stm_allocate(size_t size, unsigned long tid);
+inline gcptr stm_allocate(size_t size, unsigned long tid);
/* allocate an object that is be immutable. it cannot be changed with
a stm_write_barrier() or after the next commit */
gcptr stm_allocate_immutable(size_t size, unsigned long tid);
@@ -49,8 +49,10 @@
revision_t stm_id(gcptr);
/* returns nonzero if the two object-copy pointers belong to the
same original object */
+#if 0 // (optimized version below)
_Bool stm_pointer_equal(gcptr, gcptr);
_Bool stm_pointer_equal_prebuilt(gcptr, gcptr); /* 2nd arg is known prebuilt */
+#endif
/* to push/pop objects into the local shadowstack */
#if 0 // (optimized version below)
@@ -209,6 +211,7 @@
gcptr stm_RepeatReadBarrier(gcptr);
gcptr stm_ImmutReadBarrier(gcptr);
gcptr stm_RepeatWriteBarrier(gcptr);
+static const revision_t GCFLAG_PREBUILT_ORIGINAL = STM_FIRST_GCFLAG << 3;
static const revision_t GCFLAG_PUBLIC_TO_PRIVATE = STM_FIRST_GCFLAG << 4;
static const revision_t GCFLAG_WRITE_BARRIER = STM_FIRST_GCFLAG << 5;
static const revision_t GCFLAG_MOVED = STM_FIRST_GCFLAG << 6;
@@ -220,6 +223,16 @@
#define UNLIKELY(test) __builtin_expect(test, 0)
+_Bool stm_direct_pointer_equal(gcptr, gcptr);
+#define stm_pointer_equal(p1, p2) \
+ (((p1) == (p2)) \
+ || ((p1) != NULL && (p2) != NULL \
+ && stm_direct_pointer_equal(p1, p2)))
+#define stm_pointer_equal_prebuilt(p1, p2) \
+ (((p1) == (p2)) \
+ || (((p1) != NULL) && ((p1)->h_original == (revision_t)(p2)) && \
+ !((p1)->h_tid & GCFLAG_PREBUILT_ORIGINAL)))
+
#ifdef STM_BARRIER_COUNT
# define STM_BARRIER_NUMBERS 12
# define STM_BARRIER_NAMES "stm_read_barrier\n" \
More information about the pypy-commit
mailing list