[pypy-svn] r22234 - in pypy/dist/pypy/translator/backendopt: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Jan 16 18:45:06 CET 2006


Author: cfbolz
Date: Mon Jan 16 18:45:04 2006
New Revision: 22234

Modified:
   pypy/dist/pypy/translator/backendopt/escape.py
   pypy/dist/pypy/translator/backendopt/test/test_escape.py
Log:
fixing bug in change register_state_dependency
simplifying getarraysubstruct test


Modified: pypy/dist/pypy/translator/backendopt/escape.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/escape.py	(original)
+++ pypy/dist/pypy/translator/backendopt/escape.py	Mon Jan 16 18:45:04 2006
@@ -210,12 +210,13 @@
     def register_state_dependency(self, state1, state2):
         "state1 depends on state2: if state2 does escape/change, so does state1"
         # change state1 according to how state2 is now
+        print "registering dependency of %s on %s" % (state1, state2)
         escapes = state2.does_escape()
         if escapes and not state1.does_escape():
             changed = state1.setescapes()
             self.handle_changed(changed)
         changes = state2.does_change()
-        if changes and not state1:
+        if changes and not state1.does_change():
             changed = state1.setchanges()
             self.handle_changed(changed)
         # register a dependency of the current block on state2:

Modified: pypy/dist/pypy/translator/backendopt/test/test_escape.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_escape.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_escape.py	Mon Jan 16 18:45:04 2006
@@ -165,7 +165,7 @@
     assert acrep.changes
     assert not acrep.escapes
 
-def DONOTtest_dependencies():
+def test_dependencies():
     class A(object):
         pass
     globala = A()
@@ -179,13 +179,20 @@
         # g(a)
         return globala.l[0]
     t, adi, graph = build_adi(f, [])
-    t.view()
     avar = graph.startblock.operations[0].result
     astate = adi.getstate(avar)
     appendgraph = graph.startblock.operations[3].args[0].value._obj.graph
+    appendarg0 = appendgraph.startblock.inputargs[0]
+    appendstate = adi.getstate(appendarg0)
     resizegraph = appendgraph.startblock.operations[2].args[0].value._obj.graph
+    resizearg0 = resizegraph.startblock.inputargs[0]
+    resizestate = adi.getstate(resizearg0)
     reallygraph = resizegraph.startblock.exits[0].target.operations[0].args[0].value._obj.graph
-#    assert astate.does_escape()
+    reallyarg0 = reallygraph.startblock.inputargs[0]
+    reallystate = adi.getstate(reallyarg0)
+    assert reallystate.does_change()
+    assert resizestate.does_change()
+    assert appendstate.does_change()
     assert astate.does_change()
 
 def test_substruct():
@@ -332,19 +339,15 @@
 
 def test_getarraysubstruct():
     def createdict(i, j):
-        d = {'hello' : 23,
-             'world' : 21}
-        l = ["hello", "world"]    
-        return d[l[i]] + d[l[j]]
+        d = {2 : 23,
+             3 : 21}
+        return d[i] + d[j]
     # does not crash, for now
     t, adi, graph = build_adi(createdict, [int, int])
-    t.view()
     dvar = graph.startblock.operations[0].result
-    lvar = graph.startblock.operations[3].result
     dstate = adi.getstate(dvar)
-    lstate = adi.getstate(lvar)
     assert dstate.does_change()
-    assert lstate.does_change()
+    assert not dstate.does_escape()
 
 def test_raise_escapes():
     def f():



More information about the Pypy-commit mailing list