Author: Remi Meier <remi.me...@gmail.com> Branch: nonmovable-int-ref Changeset: r485:b19dfb209a10 Date: 2013-08-19 11:36 +0200 http://bitbucket.org/pypy/stmgc/changeset/b19dfb209a10/
Log: merge diff --git a/c4/nursery.c b/c4/nursery.c --- a/c4/nursery.c +++ b/c4/nursery.c @@ -177,10 +177,21 @@ fresh_old_copy = id_obj; fresh_old_copy->h_original = 0; obj->h_tid &= ~GCFLAG_HAS_ID; + + /* priv_from_prot's backup->h_originals already point + to id_obj */ } else { /* make a copy of it outside */ fresh_old_copy = create_old_object_copy(obj); + + if (obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED + && !(obj->h_original)) { + /* the object's backup copy still has + a h_original that is NULL*/ + gcptr B = (gcptr)obj->h_revision; + B->h_original = (revision_t)fresh_old_copy; + } } obj->h_tid |= GCFLAG_MOVED; diff --git a/c4/stmgc.h b/c4/stmgc.h --- a/c4/stmgc.h +++ b/c4/stmgc.h @@ -215,17 +215,18 @@ : (obj)) #define stm_repeat_read_barrier(obj) \ - (UNLIKELY((obj)->h_tid & (GCFLAG_PUBLIC_TO_PRIVATE | GCFLAG_MOVED)) ? \ + (UNLIKELY(((obj)->h_tid & (GCFLAG_PUBLIC_TO_PRIVATE | \ + GCFLAG_MOVED)) != 0) ? \ stm_RepeatReadBarrier(obj) \ : (obj)) #define stm_immut_read_barrier(obj) \ - (UNLIKELY((obj)->h_tid & GCFLAG_STUB) ? \ + (UNLIKELY(((obj)->h_tid & GCFLAG_STUB) != 0) ? \ stm_ImmutReadBarrier(obj) \ : (obj)) #define stm_repeat_write_barrier(obj) \ - (UNLIKELY((obj)->h_tid & GCFLAG_WRITE_BARRIER) ? \ + (UNLIKELY(((obj)->h_tid & GCFLAG_WRITE_BARRIER) != 0) ? \ stm_RepeatWriteBarrier(obj) \ : (obj)) diff --git a/c4/test/test_extra.py b/c4/test/test_extra.py --- a/c4/test/test_extra.py +++ b/c4/test/test_extra.py @@ -157,7 +157,7 @@ 0, 0, 0, 0] -def test_bug(): +def test_clear_original_on_id_copy(): p1 = nalloc(HDR) pid = lib.stm_id(p1) lib.stm_push_root(p1) @@ -167,7 +167,7 @@ assert p1o == ffi.cast("gcptr", pid) assert follow_original(p1o) == ffi.NULL -def test_bug2(): +def test_clear_original_on_priv_from_prot_abort(): p = oalloc(HDR+WORD) def cb(c): @@ -179,6 +179,25 @@ p = lib.stm_pop_root() assert follow_original(p) == ffi.NULL +def test_set_backups_original_on_move_to_id_copy(): + p1 = nalloc(HDR+WORD) + lib.stm_commit_transaction() + lib.stm_begin_inevitable_transaction() + assert classify(p1) == 'protected' + + pw = lib.stm_write_barrier(p1) + assert classify(pw) == 'private_from_protected' + assert pw == p1 + + lib.stm_push_root(pw) + # make pw old + minor_collect() + p1o = lib.stm_pop_root() + + # Backup has updated h_original: + assert classify(p1o) == 'private_from_protected' + B = follow_revision(p1o) + assert follow_original(B) == p1o def test_allocate_public_integer_address(): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit