1. Remi Meier
  2. pypy-stm-logging

Commits

Maciej Fijalkowski  committed 562571a

use smaller int, for fun

  • Participants
  • Parent commits c1833b6
  • Branches rdict-experiments

Comments (0)

Files changed (2)

File pypy/rlib/dict.py

View file
 from pypy.rlib.jit_hooks import _cast_to_gcref
 from pypy.rlib import rgc
-from pypy.rpython.lltypesystem import lltype, llmemory, rclass
+from pypy.rpython.lltypesystem import lltype, llmemory, rclass, rffi
 from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
 
 # Placeholder constants
 
-FREE = -1
-DUMMY = -2
 
 TP = lltype.GcArray(lltype.Struct('dictentry',
                                   ('key', lltype.Signed),
                                   ('value', llmemory.GCREF)))
-MAIN_TP = lltype.GcArray(lltype.Signed)
+MAIN_TP = lltype.GcArray(rffi.INT_real)
 
+FREE = rffi.cast(rffi.INT_real, -1)
+DUMMY = rffi.cast(rffi.INT_real, -2)
 
 class Dict(object):
     'Space efficient dictionary with fast iteration and cheap resizes.'
         n = len(self.indices)
         i = perturb & (n - 1)
         while True:
-            index = self.indices[i]
+            index = rffi.cast(lltype.Signed, self.indices[i])
             if index == FREE:
                 return (FREE, i) if freeslot == -1 else (DUMMY, freeslot)
             elif index == DUMMY:
                 i = 5 * i + perturb + 1
                 i = i & (n - 1)
                 perturb >>= PERTURB_SHIFT
-            self.indices[i] = index
+            self.indices[i] = rffi.cast(rffi.INT_real, index)
         self.filled = self.used
         old_values = self.values
         self.values = lltype.malloc(TP, new_size * 2 / 3 + 1)
         hashvalue = key # hash
         index, i = self._lookup(key, hashvalue)
         if index < 0:
-            self.indices[i] = self.used
+            self.indices[i] = rffi.cast(rffi.INT_real, self.used)
             self.values[self.used].key = key
             self.values[self.used].value = _cast_to_gcref(value)
             self.used += 1

File pypy/rpython/lltypesystem/opimpl.py

View file
     A = lltype.typeOf(source)
     assert A == lltype.typeOf(dest)
     assert isinstance(A.TO, lltype.GcArray)
-    assert isinstance(A.TO.OF, lltype.Ptr)
-    assert A.TO.OF.TO._gckind == 'gc'
-    assert type(source_start) is int
-    assert type(dest_start) is int
-    assert type(length) is int
+    if isinstance(A.TO.OF, lltype.Ptr):
+        assert A.TO.OF.TO._gckind == 'gc'
+        assert type(source_start) is int
+        assert type(dest_start) is int
+        assert type(length) is int
     return True
 
 def op_getfield(p, name):