[pypy-commit] pypy stm: Add two __builtin_expect() to optimize the order of the assembler, maybe.

arigo noreply at buildbot.pypy.org
Fri Jan 20 15:00:20 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51521:4f9f97138a8c
Date: 2012-01-20 15:00 +0100
http://bitbucket.org/pypy/pypy/changeset/4f9f97138a8c/

Log:	Add two __builtin_expect() to optimize the order of the assembler,
	maybe.

diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -31,7 +31,7 @@
 
 #define IS_LOCKED(num)  ((num) < 0)
 #define IS_LOCKED_OR_NEWER(num, max_age) \
-    (((unsigned long)(num)) > ((unsigned long)(max_age)))
+  __builtin_expect(((unsigned long)(num)) > ((unsigned long)(max_age)), 0)
 typedef long owner_version_t;
 
 typedef volatile owner_version_t orec_t;
diff --git a/pypy/translator/stm/src_stm/lists.c b/pypy/translator/stm/src_stm/lists.c
--- a/pypy/translator/stm/src_stm/lists.c
+++ b/pypy/translator/stm/src_stm/lists.c
@@ -102,7 +102,7 @@
   unsigned long _key = (unsigned long)(addr1);                  \
   char *_p = (char *)((redolog).toplevel.items);                \
   char *_entry = *(char **)(_p + (_key & TREE_MASK));           \
-  if (_entry == NULL)                                           \
+  if (__builtin_expect(_entry == NULL, 1))                      \
     goto_not_found;    /* common case, hopefully */             \
   result = _redolog_find(_entry, addr1);                        \
   if (result == NULL || result->addr != (addr1))                \


More information about the pypy-commit mailing list