[pypy-commit] pypy gc_no_cleanup_nursery: add zero_gc_pointers for array of GcPointer

wenzhuman noreply at buildbot.pypy.org
Tue Jul 22 04:34:27 CEST 2014


Author: wenzhuman <manwenzhu at gmail.com>
Branch: gc_no_cleanup_nursery
Changeset: r72478:50b677698120
Date: 2014-07-21 17:49 +0000
http://bitbucket.org/pypy/pypy/changeset/50b677698120/

Log:	add zero_gc_pointers for array of GcPointer

diff --git a/rpython/jit/metainterp/gc.py b/rpython/jit/metainterp/gc.py
--- a/rpython/jit/metainterp/gc.py
+++ b/rpython/jit/metainterp/gc.py
@@ -26,7 +26,7 @@
     malloc_zero_filled = True
 
 class GC_incminimark(GcDescription):
-    malloc_zero_filled = True
+    malloc_zero_filled = False
 
 
 def get_description(config):
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1266,20 +1266,38 @@
 def gen_zero_gc_pointers(TYPE, v, llops, previous_steps=None):
     if previous_steps is None:
         previous_steps = []
-    assert isinstance(TYPE, lltype.Struct)
-    for name in TYPE._names:
-        c_name = rmodel.inputconst(lltype.Void, name)
-        FIELD = getattr(TYPE, name)
-        if isinstance(FIELD, lltype.Ptr) and FIELD._needsgc():
-            c_null = rmodel.inputconst(FIELD, lltype.nullptr(FIELD.TO))
-            if not previous_steps:
-                llops.genop('bare_setfield', [v, c_name, c_null])
-            else:
-                llops.genop('bare_setinteriorfield',
+    assert (isinstance(TYPE, lltype.Struct) or isinstance(TYPE, lltype.Array))
+    if isinstance(TYPE, lltype.Struct):
+        for name in TYPE._names:
+            c_name = rmodel.inputconst(lltype.Void, name)
+            FIELD = getattr(TYPE, name)
+            #handle ptr field in GcStruct
+            if isinstance(FIELD, lltype.Ptr) and FIELD._needsgc():
+                c_null = rmodel.inputconst(FIELD, lltype.nullptr(FIELD.TO))
+                if not previous_steps:
+                    llops.genop('bare_setfield', [v, c_name, c_null])
+                else:
+                    llops.genop('bare_setinteriorfield',
                             [v] + previous_steps + [c_name, c_null])
-        elif isinstance(FIELD, lltype.Struct):
-            gen_zero_gc_pointers(FIELD, v, llops, previous_steps + [c_name])
-
+            #handle inside GcStruct field
+            elif isinstance(FIELD, lltype.Struct):
+                gen_zero_gc_pointers(FIELD, v, llops, previous_steps + [c_name])
+            #handle inside GcArray field 
+            elif isinstance(FIELD, lltype.Array):
+                gen_zero_gc_pointers(FIELD, v, llops, previous_steps + [c_name])
+    if isinstance(TYPE, lltype.Array):
+        ITEM = TYPE.OF
+        if previous_steps:
+            v = llop.genop('getinteriorfield',[v]+previous_steps)
+        arr_size = llops.genop('getarraysize',[v])
+        for i in range(arr_size):
+            #handle an array of GcPtr
+            if isinstance(ITEM, lltype.Ptr) and ITEM._needsgc():
+                c_null = rmodel.inputconst(ITEM, lltype.nullptr(ITEM.TO))
+                llops.genop('bare_setarrayitem',[v, i, c_null])
+            if isinstance(ITEM, lltype.Struct) or isinstance(ITEM, lltype.GcArray):
+                array_item = llops.genop('getarrayitem',[v,i])
+                gen_zero_gc_pointers(FIELD, array_item, llops, previous_steps)
 # ____________________________________________________________
 
 


More information about the pypy-commit mailing list