[pypy-svn] r78283 - in pypy/branch/leak-finder-more/pypy: rpython translator/c/test

afa at codespeak.net afa at codespeak.net
Tue Oct 26 11:19:06 CEST 2010


Author: afa
Date: Tue Oct 26 11:19:05 2010
New Revision: 78283

Modified:
   pypy/branch/leak-finder-more/pypy/rpython/rbuiltin.py
   pypy/branch/leak-finder-more/pypy/translator/c/test/test_lltyped.py
Log:
when translated, lltype.render_immortal() generates a call to the "track_alloc_stop" operation.


Modified: pypy/branch/leak-finder-more/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/branch/leak-finder-more/pypy/rpython/rbuiltin.py	(original)
+++ pypy/branch/leak-finder-more/pypy/rpython/rbuiltin.py	Tue Oct 26 11:19:05 2010
@@ -386,6 +386,14 @@
     hop.exception_cannot_occur()
     hop.genop('free', vlist)
 
+def rtype_render_immortal(hop, i_track_allocation=None):
+    vlist = [hop.inputarg(hop.args_r[0], arg=0)]
+    v_track_allocation = parse_kwds(hop,
+        (i_track_allocation, None))
+    hop.exception_cannot_occur()
+    if i_track_allocation is None or v_track_allocation.value:
+        hop.genop('track_alloc_stop', vlist)
+
 def rtype_const_result(hop):
     hop.exception_cannot_occur()
     return hop.inputconst(hop.r_result.lowleveltype, hop.s_result.const)
@@ -523,6 +531,7 @@
 
 BUILTIN_TYPER[lltype.malloc] = rtype_malloc
 BUILTIN_TYPER[lltype.free] = rtype_free
+BUILTIN_TYPER[lltype.render_immortal] = rtype_render_immortal
 BUILTIN_TYPER[lltype.cast_primitive] = rtype_cast_primitive
 BUILTIN_TYPER[lltype.cast_pointer] = rtype_cast_pointer
 BUILTIN_TYPER[lltype.cast_opaque_ptr] = rtype_cast_opaque_ptr

Modified: pypy/branch/leak-finder-more/pypy/translator/c/test/test_lltyped.py
==============================================================================
--- pypy/branch/leak-finder-more/pypy/translator/c/test/test_lltyped.py	(original)
+++ pypy/branch/leak-finder-more/pypy/translator/c/test/test_lltyped.py	Tue Oct 26 11:19:05 2010
@@ -841,3 +841,17 @@
         assert res == -98765432
         res = fn(1)
         assert res == -9999999
+
+    def test_render_immortal(self):
+        A = FixedSizeArray(Signed, 1)
+        a1 = malloc(A, flavor='raw')
+        render_immortal(a1)
+        a1[0] = 42
+        def llf():
+            a2 = malloc(A, flavor='raw')
+            render_immortal(a2)
+            a2[0] = 3
+            return a1[0] + a2[0]
+        fn = self.getcompiled(llf)
+        assert fn() == 45
+



More information about the Pypy-commit mailing list