[pypy-svn] r34539 - pypy/dist/pypy/translator

pedronis at codespeak.net pedronis at codespeak.net
Sun Nov 12 22:52:38 CET 2006


Author: pedronis
Date: Sun Nov 12 22:52:36 2006
New Revision: 34539

Modified:
   pypy/dist/pypy/translator/simplify.py
Log:
the keepalive removal code was making assumptions that made sense only if keepalives are used in the context
of inner non-gc structure out of gc structure. We now have usages of keepalive about keeping alive things whose
destruction has side-effects in terms of resource/raw allocated memory release.

Remove the keepalive removal code.



Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py	(original)
+++ pypy/dist/pypy/translator/simplify.py	Sun Nov 12 22:52:36 2006
@@ -468,10 +468,6 @@
     read_vars = {}  # set of variables really used
     variable_flow = {}  # map {Var: list-of-Vars-it-depends-on}
 
-    transport_flow = {} # map {Var: list-of-Vars-depending-on-it-through-links-or-indentity-ops}
-
-    keepalive_vars = {} # set of variables in keepalives 
-
     def canremove(op, block):
         if op.opname not in CanRemove:
             return False
@@ -484,9 +480,7 @@
     for block in blocks:
         # figure out which variables are ever read
         for op in block.operations:
-            if op.opname == 'keepalive':
-                keepalive_vars[op.args[0]] = True
-            elif not canremove(op, block):   # mark the inputs as really needed
+            if not canremove(op, block):   # mark the inputs as really needed
                 for arg in op.args:
                     read_vars[arg] = True
             else:
@@ -494,8 +488,6 @@
                 # on the input variables
                 deps = variable_flow.setdefault(op.result, [])
                 deps.extend(op.args)
-                if op.opname in ('cast_pointer', 'same_as'):
-                    transport_flow.setdefault(op.args[0], []).append(op.result)
 
         if isinstance(block.exitswitch, Variable):
             read_vars[block.exitswitch] = True
@@ -510,7 +502,6 @@
                     for arg, targetarg in zip(link.args, link.target.inputargs):
                         deps = variable_flow.setdefault(targetarg, [])
                         deps.append(arg)
-                        transport_flow.setdefault(arg, []).append(targetarg)                        
         else:
             # return and except blocks implicitely use their input variable(s)
             for arg in block.inputargs:
@@ -533,31 +524,6 @@
 
     flow_read_var_backward(read_vars)
     
-    # compute vars depending on a read-var through the transport-flow
-    read_var_aliases = {}
-    pending = []
-    for var in transport_flow:
-        if var in read_vars:
-            pending.append(var)
-            read_var_aliases[var] = True
-    for var in pending:
-        for nextvar in transport_flow.get(var, []):
-            if nextvar not in read_var_aliases:
-                read_var_aliases[nextvar] = True
-                pending.append(nextvar)
-        
-    # a keepalive var is read-var if it's an alias reached from some read-var
-    # through the transport flow
-    new_read_vars = {}
-    for var in keepalive_vars:
-        if var in read_var_aliases:
-            read_vars[var] = True
-            new_read_vars[var] = True
-
-    # flow backward the new read-vars
-    flow_read_var_backward(new_read_vars)
-    
-
     for block in blocks:
 
         # look for removable operations whose result is never used
@@ -566,9 +532,6 @@
             if op.result not in read_vars: 
                 if canremove(op, block):
                     del block.operations[i]
-                elif op.opname == 'keepalive':
-                    if op.args[0] not in read_vars:
-                        del block.operations[i]                        
                 elif op.opname == 'simple_call': 
                     # XXX we want to have a more effective and safe 
                     # way to check if this operation has side effects



More information about the Pypy-commit mailing list