[pypy-commit] stmgc default: add test and fix
Raemi
noreply at buildbot.pypy.org
Thu Jul 4 10:27:24 CEST 2013
Author: Remi Meier <meierrem at student.ethz.ch>
Branch:
Changeset: r346:38fcfb8212e2
Date: 2013-07-04 10:27 +0200
http://bitbucket.org/pypy/stmgc/changeset/38fcfb8212e2/
Log: add test and fix
diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -220,6 +220,11 @@
hash in h_original */
if (id_copy && !(obj->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
if (!(id_copy->h_tid & GCFLAG_PREBUILT_ORIGINAL)) {
+ id_copy->h_tid &= ~GCFLAG_PUBLIC_TO_PRIVATE;
+ /* see fix_outdated() */
+ id_copy->h_tid |= GCFLAG_VISITED;
+
+ /* XXX: may not always need tracing? */
gcptrlist_insert(&objects_to_trace, id_copy);
}
else {
diff --git a/c4/test/support.py b/c4/test/support.py
--- a/c4/test/support.py
+++ b/c4/test/support.py
@@ -298,6 +298,8 @@
undef_macros=['NDEBUG'],
define_macros=[('GC_NURSERY', str(16 * WORD)),
('_GC_DEBUG', '2'),
+ ('_GC_DEBUGPRINTS', '1'),
+ ('DUMP_EXTRA', '1'),
('GC_PAGE_SIZE', '1000'),
('GC_MIN', '200000'),
('GC_EXPAND', '90000'),
@@ -576,6 +578,13 @@
if p1.h_tid & GCFLAG_PREBUILT_ORIGINAL:
lib.stm_add_prebuilt_root(p1)
+def delegate_original(p1, p2):
+ assert p1.h_original == 0
+ assert p2.h_original == 0
+ assert p1 != p2
+ p2.h_original = ffi.cast("revision_t", p1)
+
+
def make_public(p1):
"""Hack at an object returned by oalloc() to force it public."""
assert classify(p1) == "protected"
diff --git a/c4/test/test_gcpage.py b/c4/test/test_gcpage.py
--- a/c4/test/test_gcpage.py
+++ b/c4/test/test_gcpage.py
@@ -200,6 +200,20 @@
assert p3 != p2
assert p3 == lib.stm_write_barrier(p2)
+def test_new_version_id_alive():
+ p1 = oalloc(HDR); make_public(p1)
+ p2 = oalloc(HDR); make_public(p2)
+ delegate(p1, p2)
+ delegate_original(p1, p2)
+ p2.h_original = ffi.cast("revision_t", p1)
+ lib.stm_push_root(p1)
+ major_collect()
+ major_collect()
+ p1b = lib.stm_pop_root()
+ check_not_free(p1) # id copy
+ check_not_free(p2)
+
+
def test_new_version_kill_intermediate():
p1 = oalloc(HDR); make_public(p1)
p2 = oalloc(HDR); make_public(p2)
@@ -249,6 +263,34 @@
print 'p5:', p5
assert rawgetptr(p1, 0) == p5
+def test_new_version_not_kill_intermediate_original():
+ p1 = oalloc_refs(1); make_public(p1)
+ p2 = oalloc(HDR); make_public(p2)
+ p3 = oalloc(HDR); make_public(p3)
+ p4 = oalloc(HDR); make_public(p4)
+ p5 = oalloc(HDR); make_public(p5)
+ delegate(p2, p3)
+ delegate(p3, p4)
+ delegate(p4, p5)
+ rawsetptr(p1, 0, p3)
+ delegate_original(p3, p1)
+ delegate_original(p3, p2)
+ delegate_original(p3, p4)
+ delegate_original(p3, p5)
+
+ lib.stm_push_root(p1)
+ major_collect()
+ lib.stm_pop_root()
+ check_not_free(p1)
+ check_free_old(p2)
+ check_not_free(p3) # original
+ check_free_old(p4)
+ check_not_free(p5)
+ assert rawgetptr(p1, 0) == p5
+ assert follow_original(p1) == p3
+ assert follow_original(p5) == p3
+
+
def test_prebuilt_version_1():
p1 = lib.pseudoprebuilt(HDR, 42 + HDR)
check_prebuilt(p1)
More information about the pypy-commit
mailing list