Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r79459:75a00a3b038f
Date: 2015-09-05 12:52 +0200
http://bitbucket.org/pypy/pypy/changeset/75a00a3b038f/

Log:    Trying out a variant that makes the branch 'conditional_call_value'
        mostly unneeded (it should jit to two reads of 's.hash', instead of
        only one in that branch)

diff --git a/rpython/rtyper/lltypesystem/rstr.py 
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -358,20 +358,21 @@
         return b
 
     @staticmethod
-    @jit.elidable
-    def ll_strhash(s):
+    def _compute_hash(s):
         # unlike CPython, there is no reason to avoid to return -1
         # but our malloc initializes the memory to zero, so we use zero as the
         # special non-computed-yet value.
+        x = _hash_string(s.chars)
+        if x == 0:
+            x = 29872897
+        s.hash = x
+
+    @staticmethod
+    def ll_strhash(s):
         if not s:
             return 0
-        x = s.hash
-        if x == 0:
-            x = _hash_string(s.chars)
-            if x == 0:
-                x = 29872897
-            s.hash = x
-        return x
+        jit.conditional_call(s.hash == 0, LLHelpers._compute_hash, s)
+        return s.hash
 
     @staticmethod
     def ll_length(s):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to