[pypy-svn] pypy default: implement match_by_id
antocuni
commits-noreply at bitbucket.org
Tue Feb 22 14:45:22 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r42206:a3f1c6e8b3d3
Date: 2011-02-22 14:44 +0100
http://bitbucket.org/pypy/pypy/changeset/a3f1c6e8b3d3/
Log: implement match_by_id
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
@@ -146,7 +146,7 @@
args = map(str.strip, args)
return opname, resvar, args
- def match(self, expected_src):
+ def match_ops(self, ops, expected_src):
alpha_map = {}
def match_var(v1, v2):
if v1 not in alpha_map:
@@ -154,7 +154,6 @@
assert alpha_map[v1] == v2, "variable mismatch"
#
expected_ops = self.parse_ops(expected_src)
- ops = list(self.allops())
assert len(ops) == len(expected_ops), "wrong number of operations"
for op, (exp_opname, exp_res, exp_args) in zip(ops, expected_ops):
assert op.name == exp_opname
@@ -163,3 +162,11 @@
for arg, exp_arg in zip(op.args, exp_args):
match_var(arg, exp_arg)
return True
+
+ def match(self, expected_src):
+ ops = list(self.allops())
+ return self.match_ops(ops, expected_src)
+
+ def match_by_id(self, id, expected_src):
+ ops = list(self.ops_by_id(id))
+ return self.match_ops(ops, expected_src)
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
@@ -172,3 +172,17 @@
guard_false(i14)
jump(p0, p1, p2, p3, i8)
""")
+
+ def test_match_by_id(self):
+ def f():
+ i = 0
+ while i < 1003:
+ i += 1 # ID: increment
+ a = 0 # to make sure that JUMP_ABSOLUTE is not part of the ID
+ return i
+ #
+ log = self.run(f)
+ loop, = log.loops_by_id('increment')
+ assert loop.match_by_id('increment', """
+ i1 = int_add(i0, 1)
+ """)
More information about the Pypy-commit
mailing list