Commits

Maciej Fijalkowski committed c1833b6

fix fix fix

Comments (0)

Files changed (2)

 
 @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':
 
     TP = lltype.typeOf(source).TO
     assert TP == lltype.typeOf(dest).TO
-    if isinstance(TP.OF, lltype.Ptr) and (TP.OF.TO._gckind == 'gc'
-                                          or _contains_gcptr(TP.OF.TO)):
+    if _contains_gcptr(TP):
         # perform a write barrier that copies necessary flags from
         # source to dest
         if not llop.gc_writebarrier_before_copy(lltype.Bool, source, dest,

pypy/rlib/test/test_rgc.py

     assert a2[2].y == 15
 
 def test__contains_gcptr():
-    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.Struct('x', ('x', lltype.Signed),
-                           ('y', llmemory.GCREF)))
+    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(
+        lltype.Struct('x', ('x', lltype.Signed),
+                      ('y', lltype.Ptr(lltype.GcArray(lltype.Signed))))))
+    assert rgc._contains_gcptr(lltype.GcArray(
+        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'))))
 
 def test_ll_arraycopy_small():
     TYPE = lltype.GcArray(lltype.Signed)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.