Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: Changeset: r1334:5eb79da39a17 Date: 2014-09-03 10:16 +0200 http://bitbucket.org/pypy/stmgc/changeset/5eb79da39a17/
Log: really pass 2nd test diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -99,3 +99,57 @@ s_mutex_unlock(); } + + +static void abort_data_structures_from_segment_num(int segment_num) +{ +#pragma push_macro("STM_PSEGMENT") +#pragma push_macro("STM_SEGMENT") +#undef STM_PSEGMENT +#undef STM_SEGMENT + /* struct stm_priv_segment_info_s *pseg = get_priv_segment(segment_num); */ + + /* throw_away_nursery(pseg); */ + + /* reset_modified_from_other_segments(segment_num); */ + +#pragma pop_macro("STM_SEGMENT") +#pragma pop_macro("STM_PSEGMENT") +} + + +static stm_thread_local_t *abort_with_mutex_no_longjmp(void) +{ + assert(_has_mutex()); + dprintf(("~~~ ABORT\n")); + + assert(STM_PSEGMENT->running_pthread == pthread_self()); + + abort_data_structures_from_segment_num(STM_SEGMENT->segment_num); + + stm_thread_local_t *tl = STM_SEGMENT->running_thread; + + _finish_transaction(); + /* cannot access STM_SEGMENT or STM_PSEGMENT from here ! */ + + return tl; +} + + +#ifdef STM_NO_AUTOMATIC_SETJMP +void _test_run_abort(stm_thread_local_t *tl) __attribute__((noreturn)); +#endif + +void stm_abort_transaction(void) +{ + s_mutex_lock(); + stm_thread_local_t *tl = abort_with_mutex_no_longjmp(); + s_mutex_unlock(); + +#ifdef STM_NO_AUTOMATIC_SETJMP + _test_run_abort(tl); +#else + s_mutex_lock(); + stm_rewind_jmp_longjmp(tl); +#endif +} diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -159,6 +159,7 @@ long stm_start_transaction(stm_thread_local_t *tl); void stm_commit_transaction(void); +void stm_abort_transaction(void) __attribute__((noreturn)); /* ==================== END ==================== */ diff --git a/c8/test/support.py b/c8/test/support.py --- a/c8/test/support.py +++ b/c8/test/support.py @@ -46,6 +46,7 @@ void clear_jmpbuf(stm_thread_local_t *tl); long stm_start_transaction(stm_thread_local_t *tl); bool _check_commit_transaction(void); +bool _check_abort_transaction(void); void _set_type_id(object_t *obj, uint32_t h); uint32_t _get_type_id(object_t *obj); @@ -113,6 +114,10 @@ CHECKED(stm_commit_transaction()); } +bool _check_abort_transaction(void) { + CHECKED(stm_abort_transaction()); +} + #undef CHECKED @@ -353,11 +358,12 @@ def teardown_method(self, meth): lib.stmcb_expand_marker = ffi.NULL lib.stmcb_debug_print = ffi.NULL - tl = self.tls[self.current_thread] - assert not lib._stm_in_transaction(tl) # for n, tl in enumerate(self.tls): - assert not lib._stm_in_transaction(tl) + if lib._stm_in_transaction(tl): + if self.current_thread != n: + self.switch(n) + self.abort_transaction() # for tl in self.tls: lib.stm_unregister_thread_local(tl) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit