[pypy-svn] r32020 - in pypy/dist/pypy/translator/c: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Sep 5 18:46:06 CEST 2006
Author: pedronis
Date: Tue Sep 5 18:46:05 2006
New Revision: 32020
Modified:
pypy/dist/pypy/translator/c/exceptiontransform.py
pypy/dist/pypy/translator/c/test/test_boehm.py
Log:
(arre, pedronis)
at least for the cases of "allocation" operations where a null pointer return can only mean
failure and that an exception is being raised, just check for the result of the operation
instead of in the global exception values. This allows in the hint-annotator more control
over avoding virtual container construction (which is compile-time) to be surrounded
by confusing runtime malloc exception checking.
Modified: pypy/dist/pypy/translator/c/exceptiontransform.py
==============================================================================
--- pypy/dist/pypy/translator/c/exceptiontransform.py (original)
+++ pypy/dist/pypy/translator/c/exceptiontransform.py Tue Sep 5 18:46:05 2006
@@ -299,9 +299,28 @@
#block.operations.append(SpaceOperation("safe_call", [self.rpyexc_occured_ptr], var_exc_occured))
llops = rtyper.LowLevelOpList(None)
- v_exc_type = self.ExcData_repr.getfield(self.cexcdata, 'exc_type', llops)
- llops.genop('debug_log_exc', [v_exc_type], lltype.Void)
- var_exc_occured = llops.genop('ptr_ne', [v_exc_type, self.cnulltype], lltype.Bool)
+ alloc_shortcut = False
+
+ spaceop = block.operations[-1]
+ if spaceop.opname in ('malloc', 'malloc_varsize'):
+ alloc_shortcut = True
+ elif spaceop.opname == 'direct_call':
+ fnobj = spaceop.args[0].value._obj
+ if hasattr(fnobj, '_callable'):
+ oopspec = getattr(fnobj._callable, 'oopspec', None)
+ if oopspec and oopspec == 'newlist(length)':
+ alloc_shortcut = True
+
+ if alloc_shortcut:
+ T = spaceop.result.concretetype
+ var_exc_occured = llops.genop('ptr_eq', [spaceop.result,
+ Constant(lltype.nullptr(T.TO), T)],
+ lltype.Bool)
+ else:
+ v_exc_type = self.ExcData_repr.getfield(self.cexcdata, 'exc_type', llops)
+ llops.genop('debug_log_exc', [v_exc_type], lltype.Void)
+ var_exc_occured = llops.genop('ptr_ne', [v_exc_type, self.cnulltype], lltype.Bool)
+
block.operations.extend(llops)
block.exitswitch = var_exc_occured
Modified: pypy/dist/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_boehm.py (original)
+++ pypy/dist/pypy/translator/c/test/test_boehm.py Tue Sep 5 18:46:05 2006
@@ -111,6 +111,7 @@
a = A()
# this should not keep a alive
s.a = cast_object_to_weakgcaddress(a)
+ a = None
llop.gc__collect(lltype.Void)
llop.gc__collect(lltype.Void)
llop.gc__collect(lltype.Void)
More information about the Pypy-commit
mailing list