[pypy-svn] r25548 - in pypy/branch/stacklesscfg/pypy/translator: . backendopt llvm/backendopt stackless

hpk at codespeak.net hpk at codespeak.net
Sat Apr 8 16:29:40 CEST 2006


Author: hpk
Date: Sat Apr  8 16:29:38 2006
New Revision: 25548

Modified:
   pypy/branch/stacklesscfg/pypy/translator/backendopt/inline.py
   pypy/branch/stacklesscfg/pypy/translator/backendopt/support.py
   pypy/branch/stacklesscfg/pypy/translator/llvm/backendopt/exception.py
   pypy/branch/stacklesscfg/pypy/translator/stackless/transform.py
   pypy/branch/stacklesscfg/pypy/translator/unsimplify.py
Log:
slighg refactoring: split_block_*() now returns the "splitlink" and 
not the afterblock anymore. 


Modified: pypy/branch/stacklesscfg/pypy/translator/backendopt/inline.py
==============================================================================
--- pypy/branch/stacklesscfg/pypy/translator/backendopt/inline.py	(original)
+++ pypy/branch/stacklesscfg/pypy/translator/backendopt/inline.py	Sat Apr  8 16:29:38 2006
@@ -1,7 +1,7 @@
 import sys
 from pypy.translator.simplify import join_blocks, cleanup_graph
 from pypy.translator.simplify import get_graph
-from pypy.translator.unsimplify import copyvar, split_block
+from pypy.translator.unsimplify import copyvar
 from pypy.objspace.flow.model import Variable, Constant, Block, Link
 from pypy.objspace.flow.model import SpaceOperation, c_last_exception
 from pypy.objspace.flow.model import traverse, mkentrymap, checkgraph
@@ -9,7 +9,8 @@
 from pypy.rpython.lltypesystem.lltype import Bool, typeOf, Void
 from pypy.rpython import rmodel
 from pypy.tool.algo import sparsemat
-from pypy.translator.backendopt.support import log, split_block_with_keepalive, generate_keepalive 
+from pypy.translator.backendopt.support import log, split_block_with_keepalive
+from pypy.translator.backendopt.support import generate_keepalive 
 
 BASE_INLINE_THRESHOLD = 32.4    # just enough to inline add__Int_Int()
 # and just small enough to prevend inlining of some rlist functions.
@@ -339,8 +340,9 @@
 
       
     def do_inline(self, block, index_operation):
-        afterblock = split_block_with_keepalive(
+        splitlink = split_block_with_keepalive(
             self.translator, self.graph, block, index_operation)
+        afterblock = splitlink.target
         # these variables have to be passed along all the links in the inlined
         # graph because the original function needs them in the blocks after
         # the inlined function
@@ -350,8 +352,7 @@
                                          if isinstance(arg, Variable)]
         assert afterblock.operations[0] is self.op
         #vars that need to be passed through the blocks of the inlined function
-        linktoinlined = block.exits[0]
-        assert linktoinlined.target is afterblock
+        linktoinlined = splitlink 
         copiedstartblock = self.copy_block(self.graph_to_inline.startblock)
         copiedstartblock.isstartblock = False
         #find args passed to startblock of inlined function

Modified: pypy/branch/stacklesscfg/pypy/translator/backendopt/support.py
==============================================================================
--- pypy/branch/stacklesscfg/pypy/translator/backendopt/support.py	(original)
+++ pypy/branch/stacklesscfg/pypy/translator/backendopt/support.py	Sat Apr  8 16:29:38 2006
@@ -62,7 +62,8 @@
 
 def split_block_with_keepalive(translator, graph, block, index_operation,
                                keep_alive_op_args=True):
-    afterblock = split_block(translator, graph, block, index_operation)
+    splitlink = split_block(translator, graph, block, index_operation)
+    afterblock = splitlink.target
     conservative_keepalives = needs_conservative_livevar_calculation(block)
     if conservative_keepalives:
         keep_alive_vars = [var for var in block.getvariables()
@@ -71,10 +72,10 @@
         # alive by something else. but this is sometimes hard to know
         for i, var in enumerate(keep_alive_vars):
             try:
-                index = block.exits[0].args.index(var)
+                index = splitlink.args.index(var)
                 newvar = afterblock.inputargs[index]
             except ValueError:
-                block.exits[0].args.append(var)
+                splitlink.args.append(var)
                 newvar = copyvar(translator, var)
                 afterblock.inputargs.append(newvar)
             keep_alive_vars[i] = newvar
@@ -92,7 +93,7 @@
             betweenblock.operations = generate_keepalive(fresh_vars)
     else:
         afterblock.operations.extend(generate_keepalive(keep_alive_vars))
-    return afterblock
+    return splitlink
 
 def md5digest(translator):
     import md5

Modified: pypy/branch/stacklesscfg/pypy/translator/llvm/backendopt/exception.py
==============================================================================
--- pypy/branch/stacklesscfg/pypy/translator/llvm/backendopt/exception.py	(original)
+++ pypy/branch/stacklesscfg/pypy/translator/llvm/backendopt/exception.py	Sat Apr  8 16:29:38 2006
@@ -32,7 +32,7 @@
                 continue
             n_calls_patched += 1
 
-            afterblock = split_block(translator, graph, block, i+1)
+            split_block(translator, graph, block, i+1)
 
             res = Variable()
             res.concretetype = Bool

Modified: pypy/branch/stacklesscfg/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/branch/stacklesscfg/pypy/translator/stackless/transform.py	(original)
+++ pypy/branch/stacklesscfg/pypy/translator/stackless/transform.py	Sat Apr  8 16:29:38 2006
@@ -156,9 +156,8 @@
         while i < len(block.operations):
             op = block.operations[i]
             if op.opname in ('direct_call', 'indirect_call'):
-                after_block = support.split_block_with_keepalive(self.translator, self.curr_graph, block, i+1)
-                link = block.exits[0]
-
+                link = support.split_block_with_keepalive(self.translator, 
+                                                          self.curr_graph, block, i+1)
                 var_unwind_exception = varoftype(evalue)
                
                 args = [v for v in link.args if v is not op.result]
@@ -174,7 +173,7 @@
                 self.translator.rtyper._convert_link(block, newlink)
     # ARGH ... 
 
-                block = after_block
+                block = link.target
                 i = 0
             else:
                 i += 1

Modified: pypy/branch/stacklesscfg/pypy/translator/unsimplify.py
==============================================================================
--- pypy/branch/stacklesscfg/pypy/translator/unsimplify.py	(original)
+++ pypy/branch/stacklesscfg/pypy/translator/unsimplify.py	Sat Apr  8 16:29:38 2006
@@ -36,9 +36,10 @@
     return newblock
 
 def split_block(translator, graph, block, index):
-    """split a block in two, inserting a proper link between the new
-    blocks.  if you call this after rtyping, you WILL need to worry
-    about keepalives."""
+    """return a link where prevblock is the block leading up but excluding the
+    index'th operation and target is a new block with the neccessary variables 
+    passed on.  NOTE: if you call this after rtyping, you WILL need to worry
+    about keepalives, you may use backendopt.support.split_block_with_keepalive."""
     assert 0 <= index <= len(block.operations)
     if block.exitswitch == c_last_exception:
         assert index < len(block.operations)
@@ -85,7 +86,7 @@
     block.exitswitch = None
     block.exc_handler = False
     #checkgraph(graph)
-    return newblock
+    return link
 
 def remove_direct_loops(translator, graph):
     """This is useful for code generators: it ensures that no link has



More information about the Pypy-commit mailing list