Author: Remi Meier <[email protected]>
Branch: stmgc-c4
Changeset: r67685:c3a3d6864203
Date: 2013-10-29 10:54 +0100
http://bitbucket.org/pypy/pypy/changeset/c3a3d6864203/

Log:    import stmgc (fastpaths for stm_pointer_equal(_prebuilt))

diff --git a/rpython/translator/stm/src_stm/et.h 
b/rpython/translator/stm/src_stm/et.h
--- a/rpython/translator/stm/src_stm/et.h
+++ b/rpython/translator/stm/src_stm/et.h
@@ -73,7 +73,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/rpython/translator/stm/src_stm/extra.c 
b/rpython/translator/stm/src_stm/extra.c
--- a/rpython/translator/stm/src_stm/extra.c
+++ b/rpython/translator/stm/src_stm/extra.c
@@ -247,9 +247,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;
@@ -257,22 +258,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/rpython/translator/stm/src_stm/nursery.c 
b/rpython/translator/stm/src_stm/nursery.c
--- a/rpython/translator/stm/src_stm/nursery.c
+++ b/rpython/translator/stm/src_stm/nursery.c
@@ -95,7 +95,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/rpython/translator/stm/src_stm/revision 
b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-ba0819e4b5e7
+73c77375a8a6
diff --git a/rpython/translator/stm/src_stm/stmgc.h 
b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -32,7 +32,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);
@@ -50,8 +50,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)
@@ -210,6 +212,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;
@@ -221,6 +224,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"         \
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to