[pypy-commit] pypy jit-counter: Use systematically unsigned numbers for the timetable index.
arigo
noreply at buildbot.pypy.org
Thu Oct 31 17:34:52 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-counter
Changeset: r67786:78612a2b8a5a
Date: 2013-10-31 17:27 +0100
http://bitbucket.org/pypy/pypy/changeset/78612a2b8a5a/
Log: Use systematically unsigned numbers for the timetable index.
Generates a bit simpler code.
diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -3,6 +3,7 @@
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
@@ -494,7 +495,7 @@
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)
@@ -531,7 +532,7 @@
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):
@@ -574,8 +575,8 @@
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
diff --git a/rpython/jit/metainterp/counter.py b/rpython/jit/metainterp/counter.py
--- a/rpython/jit/metainterp/counter.py
+++ b/rpython/jit/metainterp/counter.py
@@ -1,4 +1,4 @@
-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
@@ -22,7 +22,7 @@
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():
@@ -42,7 +42,9 @@
"""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):
More information about the pypy-commit
mailing list