Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r90796:5be35c6caec2
Date: 2017-03-23 11:12 +0000
http://bitbucket.org/pypy/pypy/changeset/5be35c6caec2/

Log:    Merged in timfel/pypy (pull request #529)

        Add an assertion, because the annotator doesn't seem to understand
        that index0 is >=0 here and we get an extra guard in the jit

diff --git a/rpython/rlib/rstrategies/rstrategies.py 
b/rpython/rlib/rstrategies/rstrategies.py
--- a/rpython/rlib/rstrategies/rstrategies.py
+++ b/rpython/rlib/rstrategies/rstrategies.py
@@ -1,7 +1,7 @@
 
 import weakref, sys
 from rpython.rlib.rstrategies import logger
-from rpython.rlib import jit, objectmodel, rerased
+from rpython.rlib import jit, objectmodel, rerased, rarithmetic
 from rpython.rlib.objectmodel import specialize, not_rpython
 
 def make_accessors(strategy='strategy', storage='storage'):
@@ -443,6 +443,7 @@
 
     def store(self, w_self, index0, wrapped_value):
         self.check_index_store(w_self, index0)
+        assert index0 >= 0
         if self._check_can_handle(wrapped_value):
             unwrapped = self._unwrap(wrapped_value)
             self.get_storage(w_self)[index0] = unwrapped
@@ -451,6 +452,7 @@
 
     def fetch(self, w_self, index0):
         self.check_index_fetch(w_self, index0)
+        assert index0 >= 0
         unwrapped = self.get_storage(w_self)[index0]
         return self._wrap(unwrapped)
 
@@ -517,7 +519,7 @@
         self.check_index(w_self, start)
         self.check_index(w_self, end)
     def check_index(self, w_self, index0):
-        if index0 < 0 or index0 >= self.size(w_self):
+        if not rarithmetic.int_between(0, index0, self.size(w_self)):
             raise IndexError
 
 class UnsafeIndexingMixin(object):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to