Commits

Armin Rigo committed 78612a2

Use systematically unsigned numbers for the timetable index.
Generates a bit simpler code.

  • Participants
  • Parent commits a8ce9a9
  • Branches jit-counter

Comments (0)

Files changed (2)

File rpython/jit/metainterp/compile.py

 from rpython.rtyper.annlowlevel import cast_instance_to_gcref
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib.debug import debug_start, debug_stop, debug_print
+from rpython.rlib.rarithmetic import r_uint, intmask
 from rpython.rlib import rstack
 from rpython.rlib.jit import JitDebugInfo, Counters, dont_look_inside
 from rpython.conftest import option
     rd_virtuals = None
     rd_pendingfields = lltype.nullptr(PENDINGFIELDSP.TO)
 
-    status = 0
+    status = r_uint(0)
 
     ST_BUSY_FLAG    = 0x01     # if set, busy tracing from the guard
     ST_TYPE_MASK    = 0x06     # mask for the type (TY_xxx)
                 ty = self.TY_FLOAT
             else:
                 assert 0, box.type
-            self.status = ty | (i << self.ST_SHIFT)
+            self.status = ty | (r_uint(i) << self.ST_SHIFT)
 
     def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
         if self.must_compile(deadframe, metainterp_sd, jitdriver_sd):
         else:    # we have a GUARD_VALUE that fails.
             from rpython.rlib.objectmodel import current_object_addr_as_int
 
-            index = self.status >> self.ST_SHIFT
-            typetag = self.status & self.ST_TYPE_MASK
+            index = intmask(self.status >> self.ST_SHIFT)
+            typetag = intmask(self.status & self.ST_TYPE_MASK)
 
             # fetch the actual value of the guard_value, possibly turning
             # it to an integer

File rpython/jit/metainterp/counter.py

-from rpython.rlib.rarithmetic import r_singlefloat, intmask, r_uint
+from rpython.rlib.rarithmetic import r_singlefloat, r_uint
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 
                                        flavor='raw', zero=True,
                                        track_allocation=False)
         self.celltable = [None] * size
-        self._nextindex = 0
+        self._nextindex = r_uint(0)
         #
         if translator is not None:
             def invoke_after_minor_collection():
         """Return the index (< self.size) from a hash value.  This truncates
         the hash to 32 bits, and then keep the *highest* remaining bits.
         Be sure that hash is computed correctly."""
-        return intmask(r_uint32(r_uint(r_uint32(hash)) >> self.shift))
+        hash32 = r_uint(r_uint32(hash))  # mask off the bits higher than 32
+        index = hash32 >> self.shift     # shift, resulting in a value < size
+        return index                     # return the result as a r_uint
     get_index._always_inline_ = True
 
     def fetch_next_index(self):