[pypy-svn] r52909 - in pypy/branch/jit-hotpath/pypy/jit/rainbow: . test

arigo at codespeak.net arigo at codespeak.net
Tue Mar 25 14:03:41 CET 2008


Author: arigo
Date: Tue Mar 25 14:03:40 2008
New Revision: 52909

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/graphopt.py
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_graphopt.py
Log:
Bug, test and fix.  Another coming soon...


Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/graphopt.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/graphopt.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/graphopt.py	Tue Mar 25 14:03:40 2008
@@ -92,21 +92,23 @@
             unsafe -= self.graph2safeargs[graph]
         unsafe -= self.safe_variables
 
-        pending_blocks = set([graph.startblock])
+        def notsafe(v):
+            if v not in self.safe_variables:
+                unsafe.add(v)
+
+        pending_blocks = set(graph.iterblocks())
         while pending_blocks:
             block = pending_blocks.pop()
             for op in block.operations:
-                if is_vableptr(op.result.concretetype):
-                    if op.opname == 'cast_pointer':
-                        if op.args[0] in unsafe:
-                            unsafe.add(op.result)
-                    else:
-                        unsafe.add(op.result)
-                    unsafe -= self.safe_variables
+                if op.opname == 'cast_pointer':
+                    if op.args[0] in unsafe:
+                        notsafe(op.result)
+                else:
+                    notsafe(op.result)
             for link in block.exits:
                 for v1, v2 in zip(link.args, link.target.inputargs):
                     if v1 in unsafe and v2 not in unsafe:
-                        unsafe.add(v2)
+                        notsafe(v2)
                         pending_blocks.add(link.target)
 
         # done following, now find and record all calls

Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_graphopt.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_graphopt.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_graphopt.py	Tue Mar 25 14:03:40 2008
@@ -110,3 +110,33 @@
         assert self.setters[XY.__init__.im_func] == 0
         assert self.getters[f] == 4     # 2 in the copy before the portal,
                                         # 2 in the portal itself
+
+    def test_track_in_graph_bug(self):
+        class MyJitDriver(JitDriver):
+            greens = []
+            reds = ['i']
+
+        class State:
+            pass
+        state = State()
+        state.lst = [XY(6, 7), XY(8, 9)]
+
+        def operate(xy):
+            xy.y = 27
+
+        def debug1(n):
+            if n:
+                xy = XY(4, 5)
+            else:
+                operate(state.lst[0])
+
+        def f():
+            i = 1024
+            while i > 0:
+                i >>= 1
+                debug1(i)
+                MyJitDriver.jit_merge_point(i=i)
+                MyJitDriver.can_enter_jit(i=i)
+
+        self.run(f, [], 2)
+        assert self.setters[operate] == 1



More information about the Pypy-commit mailing list