[pypy-commit] pypy default: Fix the test_pypy_c tests for 51224696c078.
arigo
noreply at buildbot.pypy.org
Sun Oct 16 10:00:00 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r48075:979996a75c9a
Date: 2011-10-16 09:59 +0200
http://bitbucket.org/pypy/pypy/changeset/979996a75c9a/
Log: Fix the test_pypy_c tests for 51224696c078.
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
@@ -225,6 +225,8 @@
# strip comment
if '#' in line:
line = line[:line.index('#')]
+ if line.strip() == 'guard_not_invalidated?':
+ return 'guard_not_invalidated', None, [], '...', False
# find the resvar, if any
if ' = ' in line:
resvar, _, line = line.partition(' = ')
@@ -249,7 +251,7 @@
descr = descr[len('descr='):]
else:
descr = None
- return opname, resvar, args, descr
+ return opname, resvar, args, descr, True
@classmethod
def preprocess_expected_src(cls, src):
@@ -258,13 +260,23 @@
# replaced with the corresponding operations, so that tests don't have
# to repeat it every time
ticker_check = """
+ guard_not_invalidated?
+ ticker0 = getfield_raw(ticker_address, descr=<SignedFieldDescr pypysig_long_struct.c_value .*>)
+ ticker_cond0 = int_lt(ticker0, 0)
+ guard_false(ticker_cond0, descr=...)
+ """
+ src = src.replace('--TICK--', ticker_check)
+ #
+ # this is the ticker check generated if we have threads
+ thread_ticker_check = """
+ guard_not_invalidated?
ticker0 = getfield_raw(ticker_address, descr=<SignedFieldDescr pypysig_long_struct.c_value .*>)
ticker1 = int_sub(ticker0, 1)
setfield_raw(ticker_address, ticker1, descr=<SignedFieldDescr pypysig_long_struct.c_value .*>)
ticker_cond0 = int_lt(ticker1, 0)
guard_false(ticker_cond0, descr=...)
"""
- src = src.replace('--TICK--', ticker_check)
+ src = src.replace('--THREAD-TICK--', thread_ticker_check)
#
# this is the ticker check generated in PyFrame.handle_operation_error
exc_ticker_check = """
@@ -298,7 +310,7 @@
if not cond:
raise InvalidMatch(message, frame=sys._getframe(1))
- def match_op(self, op, (exp_opname, exp_res, exp_args, exp_descr)):
+ def match_op(self, op, (exp_opname, exp_res, exp_args, exp_descr, _)):
self._assert(op.name == exp_opname, "operation mismatch")
self.match_var(op.res, exp_res)
if exp_args != ['...']:
@@ -341,7 +353,7 @@
what is after the '...'
"""
iter_exp_ops = iter(expected_ops)
- iter_ops = iter(self.ops)
+ iter_ops = RevertableIterator(self.ops)
for opindex, exp_op in enumerate(iter_exp_ops):
try:
if exp_op == '...':
@@ -360,6 +372,9 @@
break
self.match_op(op, exp_op)
except InvalidMatch, e:
+ if exp_op[4] is False: # optional operation
+ iter_ops.revert_one()
+ continue # try to match with the next exp_op
e.opindex = opindex
raise
#
@@ -398,3 +413,18 @@
else:
return True
+
+class RevertableIterator(object):
+ def __init__(self, sequence):
+ self.sequence = sequence
+ self.index = 0
+ def __iter__(self):
+ return self
+ def next(self):
+ index = self.index
+ if index == len(self.sequence):
+ raise StopIteration
+ self.index = index + 1
+ return self.sequence[index]
+ def revert_one(self):
+ self.index -= 1
diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -145,15 +145,17 @@
def test_parse_op(self):
res = OpMatcher.parse_op(" a = int_add( b, 3 ) # foo")
- assert res == ("int_add", "a", ["b", "3"], None)
+ assert res == ("int_add", "a", ["b", "3"], None, True)
res = OpMatcher.parse_op("guard_true(a)")
- assert res == ("guard_true", None, ["a"], None)
+ assert res == ("guard_true", None, ["a"], None, True)
res = OpMatcher.parse_op("setfield_gc(p0, i0, descr=<foobar>)")
- assert res == ("setfield_gc", None, ["p0", "i0"], "<foobar>")
+ assert res == ("setfield_gc", None, ["p0", "i0"], "<foobar>", True)
res = OpMatcher.parse_op("i1 = getfield_gc(p0, descr=<foobar>)")
- assert res == ("getfield_gc", "i1", ["p0"], "<foobar>")
+ assert res == ("getfield_gc", "i1", ["p0"], "<foobar>", True)
res = OpMatcher.parse_op("p0 = force_token()")
- assert res == ("force_token", "p0", [], None)
+ assert res == ("force_token", "p0", [], None, True)
+ res = OpMatcher.parse_op("guard_not_invalidated?")
+ assert res == ("guard_not_invalidated", None, [], '...', False)
def test_exact_match(self):
loop = """
@@ -341,7 +343,7 @@
# this is the actual loop
'int_lt', 'guard_true', 'int_add',
# this is the signal checking stuff
- 'getfield_raw', 'int_sub', 'setfield_raw', 'int_lt', 'guard_false',
+ 'guard_not_invalidated', 'getfield_raw', 'int_lt', 'guard_false',
'jump'
]
@@ -407,7 +409,7 @@
# this is the actual loop
'int_lt', 'guard_true', 'force_token', 'int_add',
# this is the signal checking stuff
- 'getfield_raw', 'int_sub', 'setfield_raw', 'int_lt', 'guard_false',
+ 'guard_not_invalidated', 'getfield_raw', 'int_lt', 'guard_false',
'jump'
]
@@ -425,10 +427,9 @@
guard_true(i6, descr=...)
i8 = int_add(i4, 1)
# signal checking stuff
+ guard_not_invalidated(descr=...)
i10 = getfield_raw(37212896, descr=<.* pypysig_long_struct.c_value .*>)
- i12 = int_sub(i10, 1)
- setfield_raw(37212896, i12, descr=<.* pypysig_long_struct.c_value .*>)
- i14 = int_lt(i12, 0)
+ i14 = int_lt(i10, 0)
guard_false(i14, descr=...)
jump(p0, p1, p2, p3, i8, descr=...)
""")
More information about the pypy-commit
mailing list