Author: Maciej Fijalkowski <[email protected]>
Branch: lightweight-finalizers
Changeset: r47761:44e2476c82c3
Date: 2011-10-01 15:36 -0300
http://bitbucket.org/pypy/pypy/changeset/44e2476c82c3/

Log:    Write a test that should remind that when we implement raw malloc in
        jit, we should deal with lightweight finalizers in the JIT

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3408,6 +3408,30 @@
         assert res == main(1, 10)
         self.check_loops(call=0)
 
+    def test_virtual_lightweight_finalizer(self):
+        py.test.skip("raw mallocs unsupported, otherwise this would be a 
problem")
+        from pypy.rlib import rgc
+        import gc
+
+        S = lltype.Struct('S', ('x', lltype.Signed))
+        
+        @rgc.owns_raw_memory('p')
+        class A(object):
+            def __init__(self):
+                self.p = lltype.malloc(S, flavor='raw')
+
+        driver = JitDriver(greens = [], reds = ['i', 'a'])
+
+        def f(i):
+            a = None
+            while i > 0:
+                driver.jit_merge_point(i=i, a=a)
+                a = A()
+                i -= 1
+            gc.collect()
+
+        self.meta_interp(f, [10])
+
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
     pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to