[pypy-svn] r47174 - pypy/branch/kill-keepalives-again/pypy/translator/backendopt/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Oct 5 00:36:21 CEST 2007
Author: cfbolz
Date: Fri Oct 5 00:36:21 2007
New Revision: 47174
Modified:
pypy/branch/kill-keepalives-again/pypy/translator/backendopt/test/test_malloc.py
Log:
add some backend removal tests about the removal of the intermediate small
structs that are passed around. Works out of a box.
Also add a test about getinteriorptr and setinteriorptr. Fails, because the
malloc remover does not know these ops. I am not sure how imporant it is to add
them, since these ops are hopefully kind of rare. I guess it would be nice for
completeness.
Modified: pypy/branch/kill-keepalives-again/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/translator/backendopt/test/test_malloc.py (original)
+++ pypy/branch/kill-keepalives-again/pypy/translator/backendopt/test/test_malloc.py Fri Oct 5 00:36:21 2007
@@ -330,6 +330,45 @@
[link] = entrymap[graph.returnblock]
assert link.prevblock.operations[-1].opname == 'keepalive'
+ def test_interior_ptr(self):
+ py.test.skip("fails")
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcStruct("T", ('s', S))
+ def f(x):
+ t = lltype.malloc(T)
+ t.s.x = x
+ return t.s.x
+ graph = self.check(f, [int], [42], 42)
+
+ def test_interior_ptr_with_index(self):
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcArray(S)
+ def f(x):
+ t = lltype.malloc(T, 1)
+ t[0].x = x
+ return t[0].x
+ graph = self.check(f, [int], [42], 42)
+
+ def test_interior_ptr_with_field_and_index(self):
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.GcStruct("T", ('items', lltype.Array(S)))
+ def f(x):
+ t = lltype.malloc(T, 1)
+ t.items[0].x = x
+ return t.items[0].x
+ graph = self.check(f, [int], [42], 42)
+
+ def test_interior_ptr_with_index_and_field(self):
+ S = lltype.Struct("S", ('x', lltype.Signed))
+ T = lltype.Struct("T", ('s', S))
+ U = lltype.GcArray(T)
+ def f(x):
+ u = lltype.malloc(U, 1)
+ u[0].s.x = x
+ return u[0].s.x
+ graph = self.check(f, [int], [42], 42)
+
+
class TestOOTypeMallocRemoval(BaseMallocRemovalTest):
type_system = 'ootype'
MallocRemover = OOTypeMallocRemover
More information about the pypy-svn
mailing list