[pypy-svn] r25958 - in pypy/dist/pypy/translator/backendopt: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Apr 18 17:51:10 CEST 2006
Author: arigo
Date: Tue Apr 18 17:51:09 2006
New Revision: 25958
Modified:
pypy/dist/pypy/translator/backendopt/malloc.py
pypy/dist/pypy/translator/backendopt/test/test_malloc.py
Log:
A case where malloc removal would hang, trying repeatedly
to "remove" the same GcStruct without progress.
Modified: pypy/dist/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/malloc.py Tue Apr 18 17:51:09 2006
@@ -164,6 +164,14 @@
return False
except (ValueError, AttributeError), e:
pass
+
+ # to avoid an infinite loop of "removals" without actual progress,
+ # be careful when trying to remove something that already looks like
+ # a GcStruct wrapper
+ if (len(STRUCT._names) == 1 and
+ isinstance(STRUCT._flds[STRUCT._names[0]], lltype.ContainerType) and
+ not equivalent_substruct(STRUCT, STRUCT._names[0])):
+ return False
# success: replace each variable with a family of variables (one per field)
example = STRUCT._container_example()
Modified: pypy/dist/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_malloc.py Tue Apr 18 17:51:09 2006
@@ -196,3 +196,16 @@
return a[0]-a[2]
check(fn, [int, int], [100, 42], 58)
+
+def test_wrapper_cannot_be_removed():
+ from pypy.rpython.lltypesystem import lltype
+ SMALL = lltype.OpaqueType('SMALL')
+ BIG = lltype.GcStruct('BIG', ('z', lltype.Signed), ('s', SMALL))
+
+ def g(small):
+ return -1
+ def fn():
+ b = lltype.malloc(BIG)
+ g(b.s)
+
+ check(fn, [], [], None, must_be_removed=False)
More information about the Pypy-commit
mailing list