Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: use-gcc Changeset: r1898:983a542003e9 Date: 2015-07-29 08:48 +0200 http://bitbucket.org/pypy/stmgc/changeset/983a542003e9/
Log: use ensure_gs_register in more places diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -1345,6 +1345,9 @@ write_fence(); assert(_stm_detached_inevitable_from_thread == -1); _stm_detached_inevitable_from_thread = 0; + } else { + /* we certainly are not detached right now */ + assert(_stm_detached_inevitable_from_thread != (intptr_t)STM_SEGMENT->running_thread); } bool was_inev = STM_PSEGMENT->transaction_state == TS_INEVITABLE; diff --git a/c8/stm/detach.c b/c8/stm/detach.c --- a/c8/stm/detach.c +++ b/c8/stm/detach.c @@ -122,6 +122,8 @@ dprintf(("reattach_transaction: commit detached from seg %d\n", remote_seg_num)); + assert(tl != old_tl); + tl->last_associated_segment_num = remote_seg_num; ensure_gs_register(remote_seg_num); commit_external_inevitable_transaction(); @@ -135,6 +137,7 @@ { dprintf(("> stm_force_transaction_break()\n")); assert(STM_SEGMENT->running_thread == tl); + assert(!stm_is_atomic(tl)); _stm_commit_transaction(); _stm_start_transaction(tl); } @@ -180,14 +183,9 @@ dprintf(("commit_fetched_detached_transaction from seg %d\n", segnum)); assert(segnum > 0); - if (segnum != mysegnum) { - set_gs_register(get_segment_base(segnum)); - } + ensure_gs_register(segnum); commit_external_inevitable_transaction(); - - if (segnum != mysegnum) { - set_gs_register(get_segment_base(mysegnum)); - } + ensure_gs_register(mysegnum); } static void commit_detached_transaction_if_from(stm_thread_local_t *tl) diff --git a/c8/stm/forksupport.c b/c8/stm/forksupport.c --- a/c8/stm/forksupport.c +++ b/c8/stm/forksupport.c @@ -87,7 +87,7 @@ assert(tl->last_associated_segment_num == i); assert(in_transaction(tl)); assert(pr->transaction_state != TS_INEVITABLE); - set_gs_register(get_segment_base(i)); + ensure_gs_register(i); assert(STM_SEGMENT->segment_num == i); s_mutex_lock(); @@ -155,7 +155,7 @@ int segnum = fork_this_tl->last_associated_segment_num; assert(1 <= segnum && segnum < NB_SEGMENTS); *_get_cpth(fork_this_tl) = pthread_self(); - set_gs_register(get_segment_base(segnum)); + ensure_gs_register(segnum); assert(STM_SEGMENT->segment_num == segnum); if (!fork_was_in_transaction) { diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -723,7 +723,7 @@ /* including the sharing seg0 */ for (i = 0; i < NB_SEGMENTS; i++) { - set_gs_register(get_segment_base(i)); + ensure_gs_register(i); bool ok = _stm_validate(); assert(get_priv_segment(i)->last_commit_log_entry->next == NULL @@ -769,7 +769,7 @@ } } - set_gs_register(get_segment_base(original_num)); + ensure_gs_register(original_num); } diff --git a/c8/stm/sync.c b/c8/stm/sync.c --- a/c8/stm/sync.c +++ b/c8/stm/sync.c @@ -66,7 +66,6 @@ static void ensure_gs_register(long segnum) { - /* XXX use this instead of set_gs_register() in many places */ if (STM_SEGMENT->segment_num != segnum) { set_gs_register(get_segment_base(segnum)); assert(STM_SEGMENT->segment_num == segnum); @@ -211,16 +210,12 @@ assert(_has_mutex()); assert(_is_tl_registered(tl)); - int num = tl->last_associated_segment_num - 1; // 0..NB_SEG-1 + int num = tl->last_associated_segment_num - 1; // 0..NB_SEG-2 OPT_ASSERT(num >= 0); if (sync_ctl.in_use1[num+1] == 0) { /* fast-path: we can get the same segment number than the one - we had before. The value stored in GS is still valid. */ -#ifdef STM_TESTS - /* that can be optimized away, except during tests, because - they use only one thread */ - set_gs_register(get_segment_base(num+1)); -#endif + we had before. The value stored in GS may still be valid. */ + ensure_gs_register(num+1); dprintf(("acquired same segment: %d\n", num+1)); goto got_num; } @@ -234,7 +229,7 @@ int old_num = tl->last_associated_segment_num; dprintf(("acquired different segment: %d->%d\n", old_num, num+1)); tl->last_associated_segment_num = num+1; - set_gs_register(get_segment_base(num+1)); + ensure_gs_register(num+1); dprintf((" %d->%d\n", old_num, num+1)); (void)old_num; goto got_num; @@ -313,14 +308,14 @@ void _stm_test_switch(stm_thread_local_t *tl) { assert(_stm_in_transaction(tl)); - set_gs_register(get_segment_base(tl->last_associated_segment_num)); + ensure_gs_register(tl->last_associated_segment_num); assert(STM_SEGMENT->running_thread == tl); exec_local_finalizers(); } void _stm_test_switch_segment(int segnum) { - set_gs_register(get_segment_base(segnum+1)); + ensure_gs_register(segnum+1); } #if STM_TESTS _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit