[pypy-commit] pypy gc-incminimark-pinning: fix/extended object pinning test.

groggi noreply at buildbot.pypy.org
Mon Jun 2 17:23:51 CEST 2014


Author: Gregor Wegberg <code at gregorwegberg.com>
Branch: gc-incminimark-pinning
Changeset: r71814:c38c9596e3d1
Date: 2014-05-12 15:59 +0200
http://bitbucket.org/pypy/pypy/changeset/c38c9596e3d1/

Log:	fix/extended object pinning test.

	Forgot to add the object to stackroots. Using now a Linked List like
	data structure for testing.

diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py
--- a/rpython/memory/gc/test/test_object_pinning.py
+++ b/rpython/memory/gc/test/test_object_pinning.py
@@ -4,17 +4,25 @@
 from test_direct import BaseDirectGCTest
 
 S = lltype.GcForwardReference()
-S.become(lltype.GcStruct('S', ('someInt', lltype.Signed)))
+S.become(lltype.GcStruct('S',
+                         ('someInt', lltype.Signed),
+                         ('next', lltype.Ptr(S))))
 
 class PinningGCTest(BaseDirectGCTest):
 
     def test_simple_pin(self):
-        ptr = self.malloc(S)
-        adr = llmemory.cast_ptr_to_adr(ptr)
-        ptr.someInt = 100
-        assert self.gc.pin(adr)
-        self.gc.collect() # ptr should still live
-        assert ptr.someInt == 100
+        ptrRoot = self.malloc(S)
+        self.stackroots.append(ptrRoot)
+
+        ptrNext = self.malloc(S)
+        adrNext = llmemory.cast_ptr_to_adr(ptrNext)
+
+        self.write(ptrRoot, 'next', ptrNext)
+        ptrNext.someInt = 100
+        
+        assert self.gc.pin(adrNext)
+        self.gc.collect() # ptrNext should still live
+        assert ptrNext.someInt == 100
 
     def test_pin_can_move(self):
         # even a pinned object is considered to be movable. Only the caller


More information about the pypy-commit mailing list