[pypy-svn] r25304 - in pypy/branch/explicit-exceptions/translator/c: . test
mwh at codespeak.net
mwh at codespeak.net
Tue Apr 4 17:29:49 CEST 2006
Author: mwh
Date: Tue Apr 4 17:29:48 2006
New Revision: 25304
Modified:
pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py
pypy/branch/explicit-exceptions/translator/c/test/test_exceptiontransform.py
Log:
(hpk, mwh)
insert keepalives as needed (we think!) in the exception transformer.
Modified: pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py
==============================================================================
--- pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py (original)
+++ pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py Tue Apr 4 17:29:48 2006
@@ -5,7 +5,7 @@
c_last_exception, SpaceOperation, checkgraph, FunctionGraph
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.memory.lladdress import NULL
-from pypy.rpython.memory.gctransform import varoftype
+from pypy.rpython.memory.gctransform import varoftype, var_needsgc
from pypy.rpython import rclass
from pypy.rpython.rarithmetic import r_uint, r_longlong, r_ulonglong
from pypy.annotation import model as annmodel
@@ -29,6 +29,19 @@
return Constant(lltype.nullptr(T.TO), T)
assert 0, "not implemented yet"
+def insert_keepalives_along(translator, link, vars):
+ link.args.extend(vars)
+ newvars = [copyvar(translator, v) for v in vars]
+ block = link.target
+ block.inputargs.extend(newvars)
+ block.operations[0:0] = [SpaceOperation('keepalive', [v],
+ varoftype(lltype.Void))
+ for v in newvars]
+
+def vars_to_keepalive(block):
+ # XXX make cleverer
+ return [v for v in block.getvariables() if var_needsgc(v)]
+
class ExceptionTransformer(object):
def __init__(self, translator):
self.translator = translator
@@ -153,7 +166,10 @@
if lastblock is block:
lastblock = afterblock
- self.gen_exc_check(block, graph.returnblock)
+ insert_keepalives_along(self.translator, block.exits[0],
+ vars_to_keepalive(block))
+
+ self.gen_exc_check(block, graph.returnblock)
#non-exception case
block.exits[0].exitcase = block.exits[0].llexitcase = False
Modified: pypy/branch/explicit-exceptions/translator/c/test/test_exceptiontransform.py
==============================================================================
--- pypy/branch/explicit-exceptions/translator/c/test/test_exceptiontransform.py (original)
+++ pypy/branch/explicit-exceptions/translator/c/test/test_exceptiontransform.py Tue Apr 4 17:29:48 2006
@@ -9,7 +9,10 @@
import sys
def check_debug_build():
- if not hasattr(sys, 'gettotalrefcount'):
+ # the 'not conftest.option.view' is because debug builds rarely
+ # have pygame, so if you want to see the graphs pass --view and
+ # don't be surprised when the test then passes when it shouldn't.
+ if not hasattr(sys, 'gettotalrefcount') and not conftest.option.view:
py.test.skip("test needs a debug build of Python")
def transform_func(fn, inputtypes):
More information about the Pypy-commit
mailing list