[pypy-svn] r21282 - in pypy/dist/pypy/jit: . test

arigo at codespeak.net arigo at codespeak.net
Sun Dec 18 19:42:51 CET 2005


Author: arigo
Date: Sun Dec 18 19:42:49 2005
New Revision: 21282

Modified:
   pypy/dist/pypy/jit/llabstractinterp.py
   pypy/dist/pypy/jit/test/test_jit_tl.py
Log:
More useful debugging prints.
Make the factorial tests check exactly what operations are left in the
residual graphs.


Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py	(original)
+++ pypy/dist/pypy/jit/llabstractinterp.py	Sun Dec 18 19:42:49 2005
@@ -597,6 +597,24 @@
             next = pending.pop()
             state = interp.pendingstates[next]
 
+            # debugging: print the current call stack
+            print
+            st = state
+            stlist = []
+            while st.a_back is not None:
+                st = st.a_back
+                stlist.append(st)
+            stlist.reverse()
+            for st in stlist:
+                op = st.origblock.operations[st.origposition]
+                if op.opname == 'direct_call':
+                    v = op.args[0]
+                    if isinstance(v, Constant):
+                        v = v.value
+                else:
+                    v = '?'
+                print 'In %r:' % (v,)
+
             # Before computing each block, we compute a 'key' which is
             # derived from the current state's fixed constants.  Instead
             # of only one residual block per state, there is one residual
@@ -618,8 +636,6 @@
             # with each other.
 
             key = tuple(state.getruntimevars(VarMemo(next.args)))
-            print
-            print 'key=', key
             try:
                 block = state.copyblocks[key]
             except KeyError:

Modified: pypy/dist/pypy/jit/test/test_jit_tl.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_jit_tl.py	(original)
+++ pypy/dist/pypy/jit/test/test_jit_tl.py	Sun Dec 18 19:42:49 2005
@@ -34,10 +34,18 @@
 
     #interp.graphs[0].show()
 
+    # return a summary of the instructions left in graph2
+    insns = {}
+    for copygraph in interp.itercopygraphs():
+        for block in copygraph.iterblocks():
+            for op in block.operations:
+                insns[op.opname] = insns.get(op.opname, 0) + 1
+    return insns
+
 
 def run_jit(code):
     code = tl.compile(code)
-    jit_tl(code)
+    return jit_tl(code)
 
 
 def test_simple1():
@@ -93,7 +101,7 @@
     ''')
 
 def test_factorial():
-    run_jit('''
+    insns = run_jit('''
             PUSH 1   #  accumulator
             PUSH 7   #  N
 
@@ -116,9 +124,17 @@
             POP
             RETURN
     ''')
+    # currently, the condition is turned from the bool to an int and back
+    # so ignore that
+    if 'cast_bool_to_int' in insns:
+        assert insns['cast_bool_to_int'] == 1
+        assert insns['int_is_true'] == 1
+        del insns['cast_bool_to_int']
+        del insns['int_is_true']
+    assert insns == {'int_le': 1, 'int_mul': 1, 'int_sub': 1}
 
 def test_factorial_harder():
-    run_jit('''
+    insns = run_jit('''
             PUSH 1   #  accumulator
             PUSH 7   #  N
 
@@ -143,3 +159,11 @@
             POP
             RETURN
     ''')
+    # currently, the condition is turned from the bool to an int and back
+    # so ignore that
+    if 'cast_bool_to_int' in insns:
+        assert insns['cast_bool_to_int'] == 1
+        assert insns['int_is_true'] == 1
+        del insns['cast_bool_to_int']
+        del insns['int_is_true']
+    assert insns == {'int_le': 1, 'int_mul': 1, 'int_sub': 1}



More information about the Pypy-commit mailing list