[pypy-svn] r22672 - in pypy/dist/pypy/rpython/memory: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jan 26 10:35:19 CET 2006
Author: cfbolz
Date: Thu Jan 26 10:35:17 2006
New Revision: 22672
Modified:
pypy/dist/pypy/rpython/memory/gctransform.py
pypy/dist/pypy/rpython/memory/test/test_gctransform.py
Log:
attach the variables that need to be pop_alived when an exception is raised to
the (in)direct_call.
Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py (original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py Thu Jan 26 10:35:17 2006
@@ -1,6 +1,7 @@
from pypy.rpython.lltypesystem import lltype
from pypy.objspace.flow.model import SpaceOperation, Variable
from pypy.translator.unsimplify import insert_empty_block
+from pypy.rpython import rmodel
import sets
"""
@@ -47,6 +48,8 @@
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:
+ op.args.append(rmodel.inputconst(lltype.Void, livevars[:]))
if var_needsgc(op.result):
if op.opname not in ('direct_call', 'indirect_call'):
newops.extend(self.push_alive(op.result))
@@ -88,4 +91,3 @@
result.concretetype = lltype.Void
return [SpaceOperation("pop_alive", [var], 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 Thu Jan 26 10:35:17 2006
@@ -88,4 +88,20 @@
passedname = link.target.exits[0].args[0].name
assert dyingname != passedname
-
+def test_cleanup_vars_on_call():
+ S = lltype.GcStruct("S", ('x', lltype.Signed))
+ def f():
+ return lltype.malloc(S)
+ def g():
+ s1 = f()
+ s2 = f()
+ s3 = f()
+ return s1
+ t = rtype_and_transform(g, [], gctransform.GCTransformer)
+ 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] == direct_calls[0].result
+ assert direct_calls[2].args[1].value == [direct_calls[0].result, direct_calls[1].result]
+
More information about the Pypy-commit
mailing list