[pypy-svn] pypy default: add a method for getting all the operations in a loop

antocuni commits-noreply at bitbucket.org
Tue Feb 22 14:45:11 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42202:cd51a50500a9
Date: 2011-02-22 11:09 +0100
http://bitbucket.org/pypy/pypy/changeset/cd51a50500a9/

Log:	add a method for getting all the operations in a loop

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
@@ -93,3 +93,9 @@
 
     def has_id(self, id):
         return id in self.ids
+
+    def allops(self, include_debug_merge_points=False):
+        for chunk in self.chunks:
+            for op in chunk.operations:
+                if op.name != 'debug_merge_point' or include_debug_merge_points:
+                    yield op

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -41,8 +41,9 @@
             return '%s(%s)' % (self.name, arglist)
 
     def __repr__(self):
-        return '<%s (%s)>' % (self.name, ', '.join([repr(a)
-                                                    for a in self.args]))
+        return self.repr()
+        ## return '<%s (%s)>' % (self.name, ', '.join([repr(a)
+        ##                                             for a in self.args]))
 
 class SimpleParser(OpParser):
     def parse_args(self, opname, argspec):

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
@@ -107,3 +107,13 @@
         loop, = log.by_id('increment')
         assert loop.filename == self.filepath
         assert loop.code.co.co_name == 'f'
+        #
+        ops = list(loop.allops())
+        opnames = [op.name for op in ops]
+        assert opnames == [
+            # 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',
+            'jump'
+            ]


More information about the Pypy-commit mailing list