Author: Gregor Wegberg <[email protected]>
Branch: gc-incminimark-pinning
Changeset: r72817:a2d0b17c975c
Date: 2014-08-15 11:34 +0200
http://bitbucket.org/pypy/pypy/changeset/a2d0b17c975c/
Log: JIT test to check if unpinning an objects works
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -804,3 +804,48 @@
def test_pinned_simple(self):
self.run('pinned_simple')
+ def define_pinned_unpin(cls):
+ from rpython.rlib.jit import promote
+ class H:
+ inst = None
+ pinned = False
+ count_pinned = 0
+ count_unpinned = 0
+ helper = H()
+
+ @dont_look_inside
+ def get_y(n):
+ if not helper.inst:
+ helper.inst = X()
+ helper.inst.x = 101
+ helper.pinned = True
+ assert rgc.pin(helper.inst)
+ elif n < 100 and helper.pinned:
+ rgc.unpin(helper.inst)
+ helper.pinned = False
+ #
+ if helper.pinned:
+ assert rgc._is_pinned(helper.inst)
+ helper.count_pinned += 1
+ else:
+ assert not rgc._is_pinned(helper.inst)
+ helper.count_unpinned += 1
+ return helper.inst
+
+ def fn(n, x, *args):
+ t = get_y(n)
+ promote(t)
+ assert t.x == 101
+ n -= 1
+ return (n, x) + args
+
+ def after(n, x, *args):
+ assert helper.count_pinned > 0
+ assert helper.count_unpinned > 0
+ assert not helper.pinned
+
+ return None, fn, after
+
+ def test_pinned_unpin(self):
+ self.run('pinned_unpin')
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit