[pypy-commit] pypy default: Trying out a variant that makes the branch 'conditional_call_value'
arigo
noreply at buildbot.pypy.org
Sat Sep 5 13:13:37 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
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):
More information about the pypy-commit
mailing list