Author: Remi Meier <remi.me...@gmail.com> Branch: Changeset: r399:6d83a39b28cf Date: 2013-07-15 17:16 +0200 http://bitbucket.org/pypy/stmgc/changeset/6d83a39b28cf/
Log: fix one bug and use a "big stub" in case it is also needed as the h_original of an object diff --git a/c4/demo_random.c b/c4/demo_random.c --- a/c4/demo_random.c +++ b/c4/demo_random.c @@ -75,7 +75,7 @@ // helper functions int classify(gcptr p); void check(gcptr p); - +int in_nursery(gcptr obj); static int is_private(gcptr P) { return (P->h_revision == stm_private_rev_num) || @@ -226,8 +226,7 @@ if (p->h_original && !(p->h_tid & GCFLAG_PREBUILT_ORIGINAL)) { // must point to valid old object gcptr id = (gcptr)p->h_original; - assert(id->h_tid & GCFLAG_OLD); - check_not_free(id); + assert(!in_nursery(id)); #ifdef _GC_DEBUG if (!is_shared_prebuilt(id) && !(id->h_tid & GCFLAG_PREBUILT)) assert(!is_free_old(id)); diff --git a/c4/extra.c b/c4/extra.c --- a/c4/extra.c +++ b/c4/extra.c @@ -107,10 +107,12 @@ else { /* must create shadow original object XXX: or use backup, if exists */ - - /* XXX use stmgcpage_malloc() directly, we don't need to copy - * the contents yet */ - gcptr O = stmgc_duplicate_old(p); + gcptr O = (gcptr)stmgcpage_malloc(stmgc_size(p)); + memcpy(O, p, stmgc_size(p)); /* at least major collections + depend on some content of id_copy. + remove after fixing that XXX */ + O->h_tid |= GCFLAG_OLD; + p->h_original = (revision_t)O; p->h_tid |= GCFLAG_HAS_ID; diff --git a/c4/steal.c b/c4/steal.c --- a/c4/steal.c +++ b/c4/steal.c @@ -39,7 +39,21 @@ goto done; not_found: - stub = stm_stub_malloc(sd->foreign_pd); + if (!obj->h_original && !(obj->h_tid & GCFLAG_OLD)) { + /* There shouldn't be a public, young object without + a h_original. But there can be priv/protected ones. + We have a young protected copy without an h_original + The stub we allocate will be the h_original, but + it must be big enough to be copied over by a major + collection later. */ + assert(!(obj->h_tid & GCFLAG_PUBLIC)); + + stub = (gcptr)stmgcpage_malloc(stmgc_size(obj)); + STUB_THREAD(stub) = sd->foreign_pd; + } + else { + stub = stm_stub_malloc(sd->foreign_pd); + } stub->h_tid = (obj->h_tid & STM_USER_TID_MASK) | GCFLAG_PUBLIC | GCFLAG_STUB | GCFLAG_OLD; @@ -51,10 +65,9 @@ stub->h_original = (revision_t)obj; } else { - /* There shouldn't be a public, young object without - a h_original. But there can be protected ones. */ - assert(!(obj->h_tid & GCFLAG_PUBLIC)); - obj->h_original = (revision_t)stub; + /* this is the big-stub case described above */ + obj->h_original = (revision_t)stub; + stub->h_original = 0; /* stub_malloc does not set to 0... */ if (obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED) { ((gcptr)obj->h_revision)->h_original = (revision_t)stub; } _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit