Author: Armin Rigo <[email protected]>
Branch: array-overallocation-in-nursery
Changeset: r67806:e5790b2e3315
Date: 2013-11-03 09:16 +0100
http://bitbucket.org/pypy/pypy/changeset/e5790b2e3315/

Log:    Fix for refcounting. Deleted items are kept alive with refcounting,
        but too bad.

diff --git a/rpython/memory/gctransform/support.py 
b/rpython/memory/gctransform/support.py
--- a/rpython/memory/gctransform/support.py
+++ b/rpython/memory/gctransform/support.py
@@ -34,8 +34,15 @@
     if isinstance(TYPE, lltype.Array):
         inner = list(_static_deallocator_body_for_type('v_%i'%depth, TYPE.OF, 
depth+1))
         if inner:
+            # NB. in case of overallocated array, we still decref all items
+            # rather than just the used ones.  This is because the unused
+            # items still have a reference.  It's not really nice, but we
+            # don't really care about the refcounting GC in the first place...
             yield '    '*depth + 'i_%d = 0'%(depth,)
-            yield '    '*depth + 'l_%d = len(%s)'%(depth, v)
+            if TYPE._is_overallocated_array():
+                yield '    '*depth + 'l_%d = %s.allocated_length'%(depth, v)
+            else:
+                yield '    '*depth + 'l_%d = len(%s)'%(depth, v)
             yield '    '*depth + 'while i_%d < l_%d:'%(depth, depth)
             yield '    '*depth + '    v_%d = %s[i_%d]'%(depth, v, depth)
             for line in inner:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to