[pypy-commit] pypy unicode-utf8: Tweak for the JIT, similar to W_UnicodeObject in the py3.5 branch

arigo pypy.commits at gmail.com
Sat Oct 14 05:43:25 EDT 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: unicode-utf8
Changeset: r92750:40990369b37a
Date: 2017-10-14 07:15 +0200
http://bitbucket.org/pypy/pypy/changeset/40990369b37a/

Log:	Tweak for the JIT, similar to W_UnicodeObject in the py3.5 branch

diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -893,10 +893,11 @@
     descr_rmul = descr_mul
 
     def _get_index_storage(self):
-        if self._index_storage == rutf8.null_storage():
-            self._index_storage = rutf8.create_utf8_index_storage(self._utf8,
-                self._length)
-        return self._index_storage
+        storage = jit.conditional_call_elidable(self._index_storage,
+                    rutf8.create_utf8_index_storage, self._utf8, self._length)
+        if not jit.isconstant(self):
+            self._index_storage = storage
+        return storage
 
     def _getitem_result(self, space, index):
         if index < 0:
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1206,7 +1206,7 @@
 def conditional_call_elidable(value, function, *args):
     """Does the same as:
 
-        if value == <0 or None>:
+        if value == <0 or None or NULL>:
             value = function(*args)
         return value
 
@@ -1236,7 +1236,7 @@
                 value = function(*args)
                 assert isinstance(value, int)
         else:
-            if value is None:
+            if not value:
                 value = function(*args)
                 assert not isinstance(value, int)
         return value


More information about the pypy-commit mailing list