Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r468:454ae0c1eb07
Date: 2013-07-28 15:56 +0200
http://bitbucket.org/pypy/stmgc/changeset/454ae0c1eb07/

Log:    "static inline" functions are not quite as good as macros. gcc
        seems to inline the functions partially only.

diff --git a/c4/stmgc.h b/c4/stmgc.h
--- a/c4/stmgc.h
+++ b/c4/stmgc.h
@@ -69,8 +69,10 @@
      do stm_write_barrier() again if we ended the transaction, or
      if we did a potential collection (e.g. stm_allocate()).
 */
-static inline gcptr stm_read_barrier(gcptr);
-static inline gcptr stm_write_barrier(gcptr);
+#if 0     // (optimized version below)
+gcptr stm_read_barrier(gcptr);
+gcptr stm_write_barrier(gcptr);
+#endif
 
 /* start a new transaction, calls callback(), and when it returns
    finish that transaction.  callback() is called with the 'arg'
@@ -139,16 +141,12 @@
 /************************************************************/
 
 
-/* macro-like functionality */
+/* macro functionality */
 
 extern __thread gcptr *stm_shadowstack;
 
-static inline void stm_push_root(gcptr obj) {
-    *stm_shadowstack++ = obj;
-}
-static inline gcptr stm_pop_root(void) {
-    return *--stm_shadowstack;
-}
+#define stm_push_root(obj)  (*stm_shadowstack++ = (obj))
+#define stm_pop_root()      (*--stm_shadowstack)
 
 extern __thread revision_t stm_private_rev_num;
 gcptr stm_DirectReadBarrier(gcptr);
@@ -160,21 +158,18 @@
     (*(gcptr *)(stm_read_barrier_cache + ((revision_t)(obj) & FX_MASK)))
 
 #define UNLIKELY(test)  __builtin_expect(test, 0)
-static inline gcptr stm_read_barrier(gcptr obj) {
-    /* XXX optimize to get the smallest code */
-    if (UNLIKELY((obj->h_revision != stm_private_rev_num) &&
-                 (FXCACHE_AT(obj) != obj)))
-        obj = stm_DirectReadBarrier(obj);
-    return obj;
-}
 
-static inline gcptr stm_write_barrier(gcptr obj) {
-    if (UNLIKELY((obj->h_revision != stm_private_rev_num) |
-                 ((obj->h_tid & GCFLAG_WRITE_BARRIER) != 0)))
-        obj = stm_WriteBarrier(obj);
-    return obj;
-}
-#undef UNLIKELY
+#define stm_read_barrier(obj)                                   \
+    (UNLIKELY(((obj)->h_revision != stm_private_rev_num) &      \
+              (FXCACHE_AT(obj) != (obj))) ?                     \
+        stm_DirectReadBarrier(obj)                              \
+     :  (obj))
+
+#define stm_write_barrier(obj)                                  \
+    (UNLIKELY(((obj)->h_revision != stm_private_rev_num) |      \
+              (((obj)->h_tid & GCFLAG_WRITE_BARRIER) != 0)) ?   \
+        stm_WriteBarrier(obj)                                   \
+     :  (obj))
 
 
 #endif
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to