Author: Armin Rigo <[email protected]>
Branch:
Changeset: r121:17c239320c14
Date: 2013-06-13 23:00 +0200
http://bitbucket.org/pypy/stmgc/changeset/17c239320c14/
Log: Copy more code, the next test passes
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -60,11 +60,20 @@
}
else {
/* a nursery object */
+ assert(!(obj->h_tid & GCFLAG_WRITE_BARRIER));
+ assert(!(obj->h_tid & GCFLAG_OLD));
+ assert(!(obj->h_tid & GCFLAG_PREBUILT_ORIGINAL));
+
+ /* make a copy of it outside */
fresh_old_copy = stmgc_duplicate(obj);
- fresh_old_copy->h_tid |= GCFLAG_OLD;
obj->h_tid |= GCFLAG_NURSERY_MOVED;
obj->h_revision = (revision_t)fresh_old_copy;
+
+ /* fix the original reference */
*root = fresh_old_copy;
+
+ /* add 'fresh_old_copy' to the list of objects to trace */
+ gcptrlist_insert(&d->old_objects_to_trace, fresh_old_copy);
}
}
@@ -76,6 +85,19 @@
}
}
+static void visit_all_outside_objects(struct tx_descriptor *d)
+{
+ while (gcptrlist_size(&d->old_objects_to_trace) > 0) {
+ gcptr obj = gcptrlist_pop(&d->old_objects_to_trace);
+
+ assert(!(obj->h_tid & GCFLAG_OLD));
+ assert(!(obj->h_tid & GCFLAG_WRITE_BARRIER));
+ obj->h_tid |= GCFLAG_OLD | GCFLAG_WRITE_BARRIER;
+
+ stmcb_trace(obj, &visit_if_young);
+ }
+}
+
static void setup_minor_collect(struct tx_descriptor *d)
{
spinlock_acquire(d->public_descriptor->collection_lock, 'M'); /*minor*/
@@ -109,8 +131,10 @@
mark_public_to_young(d);
mark_private_old_pointing_to_young(d);
+#endif
visit_all_outside_objects(d);
+#if 0
fix_list_of_read_objects(d);
/* now all surviving nursery objects have been moved out, and all
diff --git a/c4/test/support.py b/c4/test/support.py
--- a/c4/test/support.py
+++ b/c4/test/support.py
@@ -61,7 +61,7 @@
revision_t stm_global_cur_time(void);
//void stmgcpage_add_prebuilt_root(gcptr);
void stm_clear_between_tests(void);
- //void stmgc_minor_collect(void);
+ void stmgc_minor_collect(void);
gcptr _stm_nonrecord_barrier(gcptr);
int _stm_is_private(gcptr);
void stm_start_sharedlock(void);
@@ -446,6 +446,9 @@
def check_not_free(p):
assert 42 < (p.h_tid & 0xFFFF) < 521
+def check_nursery_free(p):
+ assert p.h_tid == p.h_revision == 0
+
def check_prebuilt(p):
assert 42 < (p.h_tid & 0xFFFF) < 521
assert p.h_tid & GCFLAG_PREBUILT_ORIGINAL
diff --git a/c4/test/test_nursery.py b/c4/test/test_nursery.py
--- a/c4/test/test_nursery.py
+++ b/c4/test/test_nursery.py
@@ -31,3 +31,15 @@
check_not_free(p1)
check_not_free(p3)
assert p2 in seen # the pointer location was reused
+
+def test_nursery_follows():
+ p1 = nalloc_refs(1)
+ p2 = nalloc_refs(1)
+ rawsetptr(p1, 0, p2)
+ lib.stm_push_root(p1)
+ minor_collect()
+ check_nursery_free(p1)
+ check_nursery_free(p2)
+ p1b = lib.stm_pop_root()
+ p2b = rawgetptr(p1b, 0)
+ assert rawgetptr(p2b, 0) == ffi.NULL
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit