Commits

mattip  committed f84c2c9 Merge

merge heads

  • Participants
  • Parent commits f07f592, 0603719

Comments (0)

Files changed (2)

File pypy/rlib/rgc.py

 
 @specialize.memo()
 def _contains_gcptr(TP):
-    TP = TP.OF
     if not isinstance(TP, lltype.Struct):
         if isinstance(TP, lltype.Ptr) and TP.TO._gckind == 'gc':
             return True
         return False
     for TP in TP._flds.itervalues():
-        if isinstance(TP, lltype.Ptr) and TP.TO._gckind == 'gc':
+        if _contains_gcptr(TP):
             return True
     return False
 
 
     TP = lltype.typeOf(source).TO
     assert TP == lltype.typeOf(dest).TO
-    if _contains_gcptr(TP):
+    if _contains_gcptr(TP.OF):
         # perform a write barrier that copies necessary flags from
         # source to dest
         if not llop.gc_writebarrier_before_copy(lltype.Bool, source, dest,

File pypy/rlib/test/test_rgc.py

     assert a2[2].y == 15
 
 def test__contains_gcptr():
-    assert not rgc._contains_gcptr(lltype.GcArray(lltype.Signed))
-    assert not rgc._contains_gcptr(lltype.GcArray(
-        lltype.Struct('x', ('x', lltype.Signed))))
-    assert rgc._contains_gcptr(lltype.GcArray(
+    assert not rgc._contains_gcptr(lltype.Signed)
+    assert not rgc._contains_gcptr(
+        lltype.Struct('x', ('x', lltype.Signed)))
+    assert rgc._contains_gcptr(
         lltype.Struct('x', ('x', lltype.Signed),
-                      ('y', lltype.Ptr(lltype.GcArray(lltype.Signed))))))
-    assert rgc._contains_gcptr(lltype.GcArray(
+                      ('y', lltype.Ptr(lltype.GcArray(lltype.Signed)))))
+    assert rgc._contains_gcptr(
         lltype.Struct('x', ('x', lltype.Signed),
-                      ('y', llmemory.GCREF))))
-    assert rgc._contains_gcptr(lltype.GcArray(lltype.Ptr(lltype.GcStruct('x'))))
-    assert not rgc._contains_gcptr(lltype.GcArray(lltype.Ptr(lltype.Struct('x'))))
+                      ('y', llmemory.GCREF)))
+    assert rgc._contains_gcptr(lltype.Ptr(lltype.GcStruct('x')))
+    assert not rgc._contains_gcptr(lltype.Ptr(lltype.Struct('x')))
+    GCPTR = lltype.Ptr(lltype.GcStruct('x'))
+    assert rgc._contains_gcptr(
+        lltype.Struct('FOO', ('s', lltype.Struct('BAR', ('y', GCPTR)))))
 
 def test_ll_arraycopy_small():
     TYPE = lltype.GcArray(lltype.Signed)