Commits

mattip committed f5e5647 Draft Merge

merge heads

Comments (0)

Files changed (2)

rpython/rlib/objectmodel.py

             else:
                 return type(arg)
         def typecheck(*args):
-            from rpython.annotator.model import SomeList, SomeDict, SomeChar
+            from rpython.annotator.model import SomeList, SomeDict, SomeChar,\
+                 SomeInteger
             for i, (expected_type, arg) in enumerate(zip(types, args)):
                 if expected_type is None:
                     continue
                 if isinstance(s_expected, SomeChar) and (
                         isinstance(arg, str) and len(arg) == 1):   # a char
                     continue
+                if (isinstance(s_expected, SomeInteger) and
+                    isinstance(arg, s_expected.knowntype)):
+                    continue
                 #
                 s_argtype = get_annotation(get_type_descr_of_argument(arg))
                 if not s_expected.contains(s_argtype):

rpython/rtyper/lltypesystem/rdict.py

 from rpython.rlib.rarithmetic import r_uint, intmask, LONG_BIT
 from rpython.rtyper import rmodel
 from rpython.rtyper.error import TyperError
+from rpython.annotator.model import SomeInteger
 
 
 HIGHEST_BIT = intmask(1 << (LONG_BIT - 1))
 #  be direct_call'ed from rtyped flow graphs, which means that they will
 #  get flowed and annotated, mostly with SomePtr.
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_everused_from_flag(entries, i):
     return entries[i].f_everused
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_everused_from_key(entries, i):
     return bool(entries[i].key)
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_everused_from_value(entries, i):
     return bool(entries[i].value)
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_valid_from_flag(entries, i):
     return entries[i].f_valid
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_mark_deleted_in_flag(entries, i):
     entries[i].f_valid = False
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_valid_from_key(entries, i):
     ENTRIES = lltype.typeOf(entries).TO
     dummy = ENTRIES.dummy_obj.ll_dummy_value
     return entries.everused(i) and entries[i].key != dummy
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_mark_deleted_in_key(entries, i):
     ENTRIES = lltype.typeOf(entries).TO
     dummy = ENTRIES.dummy_obj.ll_dummy_value
     entries[i].key = dummy
 
-@objectmodel.enforceargs(None, int)
+@objectmodel.enforceargs(None, SomeInteger(nonneg=True))
 def ll_valid_from_value(entries, i):
     ENTRIES = lltype.typeOf(entries).TO
     dummy = ENTRIES.dummy_obj.ll_dummy_value
 
 @jit.look_inside_iff(lambda d, i: jit.isvirtual(d) and jit.isconstant(i))
 def _ll_dict_del(d, i):
+    assert i >= 0
     d.entries.mark_deleted(i)
     d.num_items -= 1
     # clear the key and the value if they are GC pointers
     direct_compare = not hasattr(ENTRIES, 'no_direct_compare')
     mask = len(entries) - 1
     i = hash & mask
+    assert i >= 0
     # do the first try before any looping
     if entries.valid(i):
         checkingkey = entries[i].key
         i = r_uint(i)
         i = (i << 2) + i + perturb + 1
         i = intmask(i) & mask
+        assert i >= 0
         # keep 'i' as a signed number here, to consistently pass signed
         # arguments to the small helper methods.
         if not entries.everused(i):
     entries = d.entries
     mask = len(entries) - 1
     i = hash & mask
+    assert i >= 0
     perturb = r_uint(hash)
     while entries.everused(i):
         i = r_uint(i)
         i = (i << 2) + i + perturb + 1
         i = intmask(i) & mask
+        assert i >= 0
         perturb >>= PERTURB_SHIFT
     return i
 
         if dict:
             entries = dict.entries
             index = iter.index
+            assert index >= 0
             entries_len = len(entries)
             while index < entries_len:
                 entry = entries[index]