[pypy-svn] r22753 - in pypy/dist/pypy: objspace/flow rpython/memory rpython/memory/test

mwh at codespeak.net mwh at codespeak.net
Fri Jan 27 19:08:36 CET 2006


Author: mwh
Date: Fri Jan 27 19:08:33 2006
New Revision: 22753

Modified:
   pypy/dist/pypy/objspace/flow/model.py
   pypy/dist/pypy/rpython/memory/gctransform.py
   pypy/dist/pypy/rpython/memory/test/test_gctransform.py
Log:
(cfbolz, mwh)
Attach the operations-to-be-executed-for-clean-up to the space
operation as ".cleanup" not as a Void argument.


Modified: pypy/dist/pypy/objspace/flow/model.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/model.py	(original)
+++ pypy/dist/pypy/objspace/flow/model.py	Fri Jan 27 19:08:33 2006
@@ -317,7 +317,7 @@
 
 
 class SpaceOperation(object):
-    __slots__ = "opname args result offset".split()
+    __slots__ = "opname args result offset cleanup".split()
 
     def __init__(self, opname, args, result, offset=-1):
         self.opname = intern(opname)      # operation name

Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py	Fri Jan 27 19:08:33 2006
@@ -21,6 +21,8 @@
 
 """
 
+EXCEPTION_RAISING_OPS = ['direct_call', 'indirect_call']
+
 def var_needsgc(var):
     vartype = var.concretetype
     return isinstance(vartype, lltype.Ptr) and vartype._needsgc()
@@ -55,11 +57,11 @@
         livevars = [var for var in block.inputargs if var_needsgc(var)]
         for op in block.operations:
             newops.extend(self.replacement_operations(op))
-            if op.opname in ('direct_call', 'indirect_call') and livevars:
+            if op.opname in EXCEPTION_RAISING_OPS and livevars:
                 cleanup_on_exception = []
                 for var in livevars:
                     cleanup_on_exception.extend(self.pop_alive(var))
-                op.args.append(rmodel.inputconst(lltype.Void, cleanup_on_exception))
+                op.cleanup = cleanup_on_exception
             if var_needsgc(op.result):
                 if op.opname not in ('direct_call', 'indirect_call'):
                     newops.extend(self.push_alive(op.result))

Modified: pypy/dist/pypy/rpython/memory/test/test_gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gctransform.py	Fri Jan 27 19:08:33 2006
@@ -5,6 +5,10 @@
 from pypy.objspace.flow.model import Variable
 
 def checkblock(block):
+    if not block.operations == ():
+        # a return/exception block -- don't want to think about them
+        # (even though the test passes for somewhat accidental reasons)
+        return
     vars_in = len([v for v in block.inputargs if var_needsgc(v)])
     push_alives = len([op for op in block.operations
                        if op.opname.startswith('gc_push_alive')])
@@ -123,9 +127,9 @@
     ggraph = graphof(t, g)
     direct_calls = [op for op in ggraph.startblock.operations if op.opname == "direct_call"]
     assert len(direct_calls) == 3
-    assert len(direct_calls[0].args) == 1
-    assert direct_calls[1].args[1].value[0].args[0] == direct_calls[0].result
-    assert [op.args[0] for op in direct_calls[2].args[1].value] == [direct_calls[0].result, direct_calls[1].result]
+    assert direct_calls[1].cleanup[0].args[0] == direct_calls[0].result
+    assert [op.args[0] for op in direct_calls[2].cleanup] == \
+           [direct_calls[0].result, direct_calls[1].result]
 
 def test_multiply_passed_var():
     S = lltype.GcStruct("S", ('x', lltype.Signed))



More information about the Pypy-commit mailing list