[pypy-commit] pypy gc-incminimark-pinning: added test with random pinning, unpinning and adding/removing from stackroots.
groggi
noreply at buildbot.pypy.org
Fri Aug 22 12:45:47 CEST 2014
Author: Gregor Wegberg <code at gregorwegberg.com>
Branch: gc-incminimark-pinning
Changeset: r72958:9b7d961fbb87
Date: 2014-08-22 12:41 +0200
http://bitbucket.org/pypy/pypy/changeset/9b7d961fbb87/
Log: added test with random pinning, unpinning and adding/removing from
stackroots.
Fails right now. Succeeds however if 'self.gc.collect()' is used
instead of 'self.gc.debug_gc_step()'
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
@@ -54,6 +54,32 @@
# XXX test with multiple mallocs, and only part of them is pinned
+ def test_random(self):
+ # scenario: create bunch of objects. randomly pin, unpin, add to
+ # stackroots and remove from stackroots.
+ import random
+
+ for i in xrange(10**3):
+ obj = self.malloc(T)
+ obj.someInt = 100
+ #
+ if random.random() < 0.5:
+ self.stackroots.append(obj)
+ print("+stack")
+ if random.random() < 0.5:
+ self.gc.pin(llmemory.cast_ptr_to_adr(obj))
+ print("+pin")
+ self.gc.debug_gc_step()
+ for o in self.stackroots[:]:
+ assert o.someInt == 100
+ o_adr = llmemory.cast_ptr_to_adr(o)
+ if random.random() < 0.5 and self.gc._is_pinned(o_adr):
+ print("-pin")
+ self.gc.unpin(o_adr)
+ if random.random() < 0.5:
+ print("-stack")
+ self.stackroots.remove(o)
+
class TestIncminimark(PinningGCTest):
from rpython.memory.gc.incminimark import IncrementalMiniMarkGC as GCClass
More information about the pypy-commit
mailing list