[pypy-svn] r47648 - in pypy/dist/pypy/rpython/memory: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Oct 20 19:30:19 CEST 2007


Author: cfbolz
Date: Sat Oct 20 19:30:18 2007
New Revision: 47648

Modified:
   pypy/dist/pypy/rpython/memory/gcwrapper.py
   pypy/dist/pypy/rpython/memory/test/test_gc.py
Log:
don't invoke the write barrier for nongc (outer) pointers in the gcwrapper
either.


Modified: pypy/dist/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gcwrapper.py	(original)
+++ pypy/dist/pypy/rpython/memory/gcwrapper.py	Sat Oct 20 19:30:18 2007
@@ -72,7 +72,8 @@
         self.setinterior(array, addr, ARRAY.OF, newitem)
 
     def setinterior(self, toplevelcontainer, inneraddr, INNERTYPE, newvalue):
-        if isinstance(INNERTYPE, lltype.Ptr) and INNERTYPE.TO._gckind == 'gc':
+        if (lltype.typeOf(toplevelcontainer).TO._gckind == 'gc' and
+            isinstance(INNERTYPE, lltype.Ptr) and INNERTYPE.TO._gckind == 'gc'):
             self.gc.write_barrier(llmemory.cast_ptr_to_adr(newvalue),
                                   inneraddr,
                                   llmemory.cast_ptr_to_adr(toplevelcontainer))

Modified: pypy/dist/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gc.py	Sat Oct 20 19:30:18 2007
@@ -327,6 +327,21 @@
         res = self.interpret(f, [20])  # for GenerationGC, enough for a minor collection
         assert res == 20 + 20
 
+    def test_nongc_static_root(self):
+        from pypy.rpython.lltypesystem import lltype
+        T1 = lltype.GcStruct("C", ('x', lltype.Signed))
+        T2 = lltype.Struct("C", ('p', lltype.Ptr(T1)))
+        static = lltype.malloc(T2, immortal=True)
+        def f():
+            t1 = lltype.malloc(T1)
+            t1.x = 42
+            static.p = t1
+            llop.gc__collect(lltype.Void)
+            return static.p.x
+        res = self.interpret(f, [])
+        assert res == 42
+
+
 class TestMarkSweepGC(GCTest):
     from pypy.rpython.memory.gc.marksweep import MarkSweepGC as GCClass
 



More information about the Pypy-commit mailing list