[pypy-commit] pypy jit-targets: extract the peeled loop from the combined preamble and peeled loop trace

hakanardo noreply at buildbot.pypy.org
Sun Nov 27 12:20:39 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-targets
Changeset: r49851:6186c1e4e311
Date: 2011-11-27 12:20 +0100
http://bitbucket.org/pypy/pypy/changeset/6186c1e4e311/

Log:	extract the peeled loop from the combined preamble and peeled loop
	trace

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
@@ -148,6 +148,15 @@
     def allops(self, *args, **kwds):
         return list(self._allops(*args, **kwds))
 
+    def simple_loop_ops(self):
+        ops = self.allops()
+        labels = [op for op in self.allops() if op.name == 'label']
+        jumpop = ops[-1]
+        assert jumpop.name == 'jump'
+        assert jumpop.getdescr() == labels[-1].getdescr()
+        i = ops.index(labels[-1])
+        return ops[i+1:]
+
     def format_ops(self, id=None, **kwds):
         if id is None:
             ops = self.allops(**kwds)
@@ -172,13 +181,13 @@
         return list(self._ops_by_id(*args, **kwds))
 
     def match(self, expected_src, **kwds):
-        ops = list(self.allops())
-        matcher = OpMatcher(ops, src=self.format_ops())
+        ops = list(self.simple_loop_ops())
+        matcher = OpMatcher(ops)
         return matcher.match(expected_src, **kwds)
 
     def match_by_id(self, id, expected_src, **kwds):
         ops = list(self.ops_by_id(id, **kwds))
-        matcher = OpMatcher(ops, src=self.format_ops(id))
+        matcher = OpMatcher(ops)
         return matcher.match(expected_src)
 
 class InvalidMatch(Exception):
@@ -210,9 +219,9 @@
 
 class OpMatcher(object):
 
-    def __init__(self, ops, src=None):
+    def __init__(self, ops):
         self.ops = ops
-        self.src = src
+        self.src = '\n'.join(map(str, ops))
         self.alpha_map = {}
 
     @classmethod
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
@@ -118,7 +118,7 @@
     def match(self, src1, src2, **kwds):
         from pypy.tool.jitlogparser.parser import SimpleParser
         loop = SimpleParser.parse_from_input(src1)
-        matcher = OpMatcher(loop.operations, src=src1)
+        matcher = OpMatcher(loop.operations)
         return matcher.match(src2, **kwds)
 
     def test_match_var(self):


More information about the pypy-commit mailing list