[pypy-commit] pypy default: Split tick() into an inlinable fast-path and a regular slow-path.
arigo
noreply at buildbot.pypy.org
Sat Mar 1 15:16:15 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r69573:b7025da78ba8
Date: 2014-03-01 15:15 +0100
http://bitbucket.org/pypy/pypy/changeset/b7025da78ba8/
Log: Split tick() into an inlinable fast-path and a regular slow-path.
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
@@ -100,13 +100,8 @@
return n
_swap._always_inline_ = True
- def tick(self, hash, increment):
- p_entry = self.timetable[self._get_index(hash)]
- subhash = self._get_subhash(hash)
- #
- if p_entry.subhashes[0] == subhash:
- n = 0
- elif p_entry.subhashes[1] == subhash:
+ def _tick_slowpath(self, p_entry, subhash):
+ if p_entry.subhashes[1] == subhash:
n = self._swap(p_entry, 0)
elif p_entry.subhashes[2] == subhash:
n = self._swap(p_entry, 1)
@@ -120,6 +115,16 @@
n -= 1
p_entry.subhashes[n] = rffi.cast(rffi.USHORT, subhash)
p_entry.times[n] = r_singlefloat(0.0)
+ return n
+
+ def tick(self, hash, increment):
+ p_entry = self.timetable[self._get_index(hash)]
+ subhash = self._get_subhash(hash)
+ #
+ if p_entry.subhashes[0] == subhash:
+ n = 0
+ else:
+ n = self._tick_slowpath(p_entry, subhash)
#
counter = float(p_entry.times[n]) + increment
if counter < 1.0:
@@ -129,6 +134,7 @@
# when the bound is reached, we immediately reset the value to 0.0
self.reset(hash)
return True
+ tick._always_inline_ = True
def reset(self, hash):
p_entry = self.timetable[self._get_index(hash)]
diff --git a/rpython/jit/metainterp/test/test_counter.py b/rpython/jit/metainterp/test/test_counter.py
--- a/rpython/jit/metainterp/test/test_counter.py
+++ b/rpython/jit/metainterp/test/test_counter.py
@@ -41,6 +41,7 @@
def test_tick():
jc = JitCounter()
+ jc._tick_slowpath = "not callable in this test!"
incr = jc.compute_threshold(4)
for i in range(5):
r = jc.tick(index2hash(jc, 104), incr)
More information about the pypy-commit
mailing list