[pypy-svn] r7415 - pypy/trunk/src/pypy/translator

hpk at codespeak.net hpk at codespeak.net
Fri Nov 19 11:01:00 CET 2004


Author: hpk
Date: Fri Nov 19 11:01:00 2004
New Revision: 7415

Modified:
   pypy/trunk/src/pypy/translator/transform.py
Log:
improve the removal of dead operations, it now
checks if an operation returns a SomeImpossibleValue()
which is - as Armin said - meant to indicate that
an operation has side effects. IOW analysis of
operations (like the one for setattr or list's
method_extend) should return SomeImpossibleValue()
to signal that it has side effects and thus cannot
be removed even if the result is not used anywhere. 

In the future, we probably want to mark operations
as having side effects more directly ... 



Modified: pypy/trunk/src/pypy/translator/transform.py
==============================================================================
--- pypy/trunk/src/pypy/translator/transform.py	(original)
+++ pypy/trunk/src/pypy/translator/transform.py	Fri Nov 19 11:01:00 2004
@@ -160,10 +160,11 @@
                 if op.opname in CanRemove: 
                     del block.operations[i]
                 elif op.opname == 'simple_call': 
-                    if op.args and isinstance(op.args[0], Constant):
-                        func = op.args[0].value 
-                        if func is isinstance: 
-                            del block.operations[i]
+                    # XXX if the result is SomeImpossibleValue()
+                    # we assume the operation has side effects
+                    # and don't delete it 
+                    if op.result != annmodel.SomeImpossibleValue():
+                        del block.operations[i]
                 
         # look for output variables never used
         # warning: this must be completely done *before* we attempt to



More information about the Pypy-commit mailing list