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

cfbolz at codespeak.net cfbolz at codespeak.net
Sat May 6 16:15:58 CEST 2006


Author: cfbolz
Date: Sat May  6 16:15:57 2006
New Revision: 26875

Modified:
   pypy/dist/pypy/translator/backendopt/propagate.py
   pypy/dist/pypy/translator/backendopt/test/test_propagate.py
Log:
move check that certain getsubstructs are not folded into op_dont_fold. rename
wrongly named test


Modified: pypy/dist/pypy/translator/backendopt/propagate.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/propagate.py	(original)
+++ pypy/dist/pypy/translator/backendopt/propagate.py	Sat May  6 16:15:57 2006
@@ -138,6 +138,12 @@
         CONTAINER = op.args[0].concretetype.TO
         if CONTAINER._hints.get('immutable'):
             return False
+    if op.opname in ("getsubstruct", "getarraysubstruct"):
+        # this is needed so that the parent of the result (op.args[0])
+        # does not go away after the op is folded. see test_dont_fold_getsubstruct
+        if not var_needsgc(op.result):
+            return True
+        # XXX if the result is immortal, one could still fold...
     try:
         return not lloperation.LL_OPERATIONS[op.opname].canfold
     except KeyError:
@@ -153,10 +159,6 @@
             if sum([isinstance(arg, Variable) for arg in op.args]):
                 continue
             if not op_dont_fold(op):
-                if op.opname in ("getsubstruct", "getarraysubstruct"):
-                    # XXX why this case?
-                    if not var_needsgc(op.result):
-                        continue
                 try:
                     llframe.eval_operation(op)
                 except:

Modified: pypy/dist/pypy/translator/backendopt/test/test_propagate.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_propagate.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_propagate.py	Sat May  6 16:15:57 2006
@@ -155,7 +155,7 @@
         pass
     check_graph(graph, [10], 10, t)
 
-def test_dont_fold_getfield():
+def test_dont_fold_getsubstruct():
     # must not constant fold this, because the container might be collected
     string = "blablabla"
     def f(x):



More information about the Pypy-commit mailing list