[pypy-commit] pypy gc_no_cleanup_nursery: add zero_gc_pointers_inside() after gc.malloc()

wenzhuman noreply at buildbot.pypy.org
Wed Jun 25 16:42:46 CEST 2014


Author: wenzhuman <manwenzhu at gmail.com>
Branch: gc_no_cleanup_nursery
Changeset: r72213:3a3b6bee087d
Date: 2014-06-25 10:41 -0400
http://bitbucket.org/pypy/pypy/changeset/3a3b6bee087d/

Log:	add zero_gc_pointers_inside() after gc.malloc()

diff --git a/rpython/memory/gc/test/test_direct.py b/rpython/memory/gc/test/test_direct.py
--- a/rpython/memory/gc/test/test_direct.py
+++ b/rpython/memory/gc/test/test_direct.py
@@ -11,7 +11,7 @@
 from rpython.memory.gctypelayout import TypeLayoutBuilder
 from rpython.rlib.rarithmetic import LONG_BIT, is_valid_int
 from rpython.memory.gc import minimark, incminimark
-
+from rpython.memory.gctypelayout import zero_gc_pointers, zero_gc_pointers_inside
 WORD = LONG_BIT // 8
 
 ADDR_ARRAY = lltype.Array(llmemory.Address)
@@ -46,6 +46,7 @@
         if collect_stack_root:
             stackroots = self.tester.stackroots
             a = lltype.malloc(ADDR_ARRAY, len(stackroots), flavor='raw')
+            zero_gc_pointers_inside(a, ADDR_ARRAY)
             for i in range(len(a)):
                 a[i] = llmemory.cast_ptr_to_adr(stackroots[i])
             a_base = lltype.direct_arrayitems(a)
@@ -106,7 +107,10 @@
 
     def malloc(self, TYPE, n=None):
         addr = self.gc.malloc(self.get_type_id(TYPE), n, zero=True)
-        return llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE))
+        obj_ptr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE))
+        #TODO: only zero fields if there is gc filed add something like has_gc_ptr()
+        zero_gc_pointers_inside(obj_ptr, TYPE)
+        return obj_ptr
 
 
 class DirectGCTest(BaseDirectGCTest):


More information about the pypy-commit mailing list