Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r148:d7c0041a6fa2 Date: 2013-06-16 15:32 +0200 http://bitbucket.org/pypy/stmgc/changeset/d7c0041a6fa2/
Log: in-progress diff --git a/c4/et.c b/c4/et.c --- a/c4/et.c +++ b/c4/et.c @@ -1363,6 +1363,7 @@ assert(d->active == 0); assert(d->public_descriptor->stolen_objects.size == 0); gcptrlist_delete(&d->public_descriptor->stolen_objects); + gcptrlist_delete(&d->public_descriptor->stolen_young_stubs); spinlock_acquire(descriptor_array_lock, 1); i = d->public_descriptor_index; diff --git a/c4/et.h b/c4/et.h --- a/c4/et.h +++ b/c4/et.h @@ -112,6 +112,7 @@ struct stub_block_s *stub_blocks; gcptr stub_free_list; struct GcPtrList stolen_objects; + struct GcPtrList stolen_young_stubs; revision_t free_list_next; /* xxx gcpage data here */ }; diff --git a/c4/nursery.c b/c4/nursery.c --- a/c4/nursery.c +++ b/c4/nursery.c @@ -155,6 +155,48 @@ d->num_private_from_protected_known_old = size; } +static void trace_stub(struct tx_descriptor *d, gcptr S) +{ + revision_t w = ACCESS_ONCE(S->h_revision); + if ((w & 3) != 2) { + /* P has a ptr in h_revision, but this object is not a stub + with a protected pointer. It has likely been the case + in the past, but someone made even more changes. + Nothing to do now. + */ + fprintf(stderr, "trace_stub: %p not a stub, ignored\n", S); + return; + } + + assert(S->h_tid & GCFLAG_STUB); + if (STUB_THREAD(S) != d->public_descriptor) { + /* Bah, it's indeed a stub but for another thread. Nothing + to do now. + */ + fprintf(stderr, "trace_stub: %p stub wrong thread, ignored\n", S); + return; + } + + /* It's a stub for us. It cannot be un-stubbed under our + feet because we hold our own collection_lock. + */ + gcptr L = (gcptr)(w - 2); + fprintf(stderr, "trace_stub: %p stub -> %p\n", S, L); + visit_if_young(&L); + S->h_revision = ((revision_t)L) | 2; +} + +static void mark_stolen_young_stubs(struct tx_descriptor *d) +{ + long i, size = d->public_descriptor->stolen_young_stubs.size; + gcptr *items = d->public_descriptor->stolen_young_stubs.items; + + for (i = 0; i < size; i++) { + trace_stub(d, items[i]); + } + gcptrlist_clear(&d->public_descriptor->stolen_young_stubs); +} + static void mark_public_to_young(struct tx_descriptor *d) { /* "public_with_young_copy" lists the public copies that may have @@ -207,37 +249,8 @@ continue; } - gcptr S = (gcptr)v; - revision_t w = ACCESS_ONCE(S->h_revision); - if ((w & 3) != 2) { - /* P has a ptr in h_revision, but this object is not a stub - with a protected pointer. It has likely been the case - in the past, but someone made even more changes. - Nothing to do now. - */ - fprintf(stderr, "public_to_young: %p -> %p not a stub, ignored\n", - P, S); - continue; - } - - if (STUB_THREAD(S) != d->public_descriptor) { - /* Bah, it's indeed a stub but for another thread. Nothing - to do now. - */ - fprintf(stderr, "public_to_young: %p -> %p stub wrong thread, " - "ignored\n", P, S); - continue; - } - - /* It's a stub for us. It cannot be un-stubbed under our - feet because we hold our own collection_lock. - */ - gcptr L = (gcptr)(w - 2); - fprintf(stderr, "public_to_young: %p -> %p stub -> %p\n", - P, S, L); - - visit_if_young(&L); - S->h_revision = ((revision_t)L) | 2; + fprintf(stderr, "public_to_young: %p -> ", P); + trace_stub(d, (gcptr)v); } gcptrlist_clear(&d->public_with_young_copy); @@ -286,6 +299,8 @@ mark_young_roots(d); + mark_stolen_young_stubs(d); + mark_private_from_protected(d); visit_all_outside_objects(d); @@ -309,6 +324,8 @@ d->nursery_base = stm_malloc(GC_NURSERY); memset(d->nursery_base, 0, GC_NURSERY); d->nursery_end = d->nursery_base + GC_NURSERY; + fprintf(stderr, "minor: nursery moved to [%p to %p]\n", d->nursery_base, + d->nursery_end); #else memset(d->nursery_base, 0, GC_NURSERY); #endif diff --git a/c4/steal.c b/c4/steal.c --- a/c4/steal.c +++ b/c4/steal.c @@ -79,6 +79,9 @@ stub->h_revision = ((revision_t)obj) | 2; g2l_insert(&sd->all_stubs, obj, stub); + if (!(obj->h_tid & GCFLAG_OLD)) + gcptrlist_insert(&sd->foreign_pd->stolen_young_stubs, stub); + done: *pobj = stub; fprintf(stderr, " stolen: fixing *%p: %p -> %p\n", pobj, obj, stub); @@ -116,15 +119,14 @@ L = B; goto already_stolen; } - else { - B->h_tid |= GCFLAG_PUBLIC_TO_PRIVATE; - /* add {B: L} in 'public_to_private', but lazily, because we - don't want to walk over the feet of the foreign thread - */ - gcptrlist_insert2(&foreign_pd->stolen_objects, B, L); - fprintf(stderr, "stolen: %p -> %p <-> %p\n", P, L, B); - L = B; - } + + B->h_tid |= GCFLAG_PUBLIC_TO_PRIVATE; + /* add {B: L} in 'public_to_private', but lazily, because we + don't want to walk over the feet of the foreign thread + */ + gcptrlist_insert2(&foreign_pd->stolen_objects, B, L); + fprintf(stderr, "stolen: %p -> %p <-> %p\n", P, L, B); + L = B; } else { if (L->h_tid & GCFLAG_PUBLIC) { @@ -140,9 +142,8 @@ L = (gcptr)v; goto already_stolen; } - else { - fprintf(stderr, "stolen: %p -> %p\n", P, L); - } + + fprintf(stderr, "stolen: %p -> %p\n", P, L); /* Copy the object out of the other thread's nursery, if needed */ if (!(L->h_tid & GCFLAG_OLD)) { @@ -151,6 +152,7 @@ L->h_tid |= GCFLAG_PUBLIC | GCFLAG_NURSERY_MOVED; L = O; } + assert(L->h_tid & GCFLAG_OLD); } /* Here L is a protected (or backup) copy, and we own the foreign _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit