[pypy-svn] pypy default: find a way not to repeat the same code for ticker check every time
antocuni
commits-noreply at bitbucket.org
Wed Feb 23 18:33:34 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r42235:35e02ea78e2e
Date: 2011-02-23 18:28 +0100
http://bitbucket.org/pypy/pypy/changeset/35e02ea78e2e/
Log: find a way not to repeat the same code for ticker check every time
diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -166,7 +166,23 @@
args = map(str.strip, args)
return opname, resvar, args
+ def preprocess_expected_src(self, src):
+ # all loops decrement the tick-counter at the end. The rpython code is
+ # in jump_absolute() in pypyjit/interp.py. The string --TICK-- is
+ # replaced with the corresponding operations, so that tests don't have
+ # to repeat it every time
+ ticker_check = """
+ ticker0 = getfield_raw(ticker_address)
+ ticker1 = int_sub(ticker0, 1)
+ setfield_raw(ticker_address, ticker1)
+ ticker_cond = int_lt(ticker1, 0)
+ guard_false(ticker_cond)
+ """
+ src = src.replace('--TICK--', ticker_check)
+ return src
+
def match_ops(self, ops, expected_src):
+ expected_src = self.preprocess_expected_src(expected_src)
alpha_map = {}
def match_var(v1, v2):
if v1 not in alpha_map:
diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -31,11 +31,7 @@
i12 = int_and(i8, i11)
i13 = int_add_ovf(i6, i12)
guard_no_overflow()
- i16 = getfield_raw(37212896)
- i18 = int_sub(i16, 1)
- setfield_raw(37212896, i18)
- i20 = int_lt(i18, 0)
- guard_false(i20)
+ --TICK--
jump(p0, p1, p2, p3, p4, p5, i13, i11, i8)
""")
diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_model.py
@@ -198,15 +198,19 @@
jump(p0, p1, p2, p3, i8)
""")
#
+ assert loop.match("""
+ i6 = int_lt(i4, 1003)
+ guard_true(i6)
+ i8 = int_add(i4, 1)
+ --TICK--
+ jump(p0, p1, p2, p3, i8)
+ """)
+ #
py.test.raises(AssertionError, loop.match, """
i6 = int_lt(i4, 1003)
guard_true(i6)
i8 = int_add(i5, 1) # variable mismatch
- i10 = getfield_raw(37212896)
- i12 = int_sub(i10, 1)
- setfield_raw(37212896, i12)
- i14 = int_lt(i12, 0)
- guard_false(i14)
+ --TICK--
jump(p0, p1, p2, p3, i8)
""")
More information about the Pypy-commit
mailing list