diff options
author | Torvald Riegel <triegel@redhat.com> | 2012-01-13 23:45:06 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2012-01-13 23:45:06 +0000 |
commit | 07b6642b935e1cd499a2aae071db06d845e39a8b (patch) | |
tree | 8ed0df69ae3d1543fa4811e7cb7e72a8d99333b5 /libitm/config | |
parent | 4cce1836bde85844781736f0f87b51ae9393da5f (diff) | |
download | gcc-07b6642b935e1cd499a2aae071db06d845e39a8b.zip gcc-07b6642b935e1cd499a2aae071db06d845e39a8b.tar.gz gcc-07b6642b935e1cd499a2aae071db06d845e39a8b.tar.bz2 |
libitm: Filter out undo writes that overlap with the libitm stack.
PR libitm/51855
* config/generic/tls.h (GTM::mask_stack_top): New.
(GTM::mask_stack_bottom): Declare.
* config/generic/tls.c (GTM::mask_stack_bottom): New.
* local.cc (gtm_undolog::rollback): Filter out any updates that
overlap the libitm stack. Add current transaction as parameter.
* libitm_i.h (GTM::gtm_undolog::rollback): Adapt.
* beginend.cc (GTM::gtm_thread::rollback): Adapt.
* testsuite/libitm.c/stackundo.c: New test.
From-SVN: r183172
Diffstat (limited to 'libitm/config')
-rw-r--r-- | libitm/config/generic/tls.cc | 7 | ||||
-rw-r--r-- | libitm/config/generic/tls.h | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/libitm/config/generic/tls.cc b/libitm/config/generic/tls.cc index e502e50..f07d082 100644 --- a/libitm/config/generic/tls.cc +++ b/libitm/config/generic/tls.cc @@ -30,4 +30,11 @@ namespace GTM HIDDEN { __thread gtm_thread_tls _gtm_thr_tls; #endif +// See tls.h for comments. +void * __attribute__((noinline)) +mask_stack_bottom(gtm_thread *tx) +{ + return (uint8_t*)__builtin_dwarf_cfa() - 256; +} + } // namespace GTM diff --git a/libitm/config/generic/tls.h b/libitm/config/generic/tls.h index 6bbdccf..dfcd76a 100644 --- a/libitm/config/generic/tls.h +++ b/libitm/config/generic/tls.h @@ -60,6 +60,23 @@ static inline abi_dispatch * abi_disp() { return _gtm_thr_tls.disp; } static inline void set_abi_disp(abi_dispatch *x) { _gtm_thr_tls.disp = x; } #endif +#ifndef HAVE_ARCH_GTM_MASK_STACK +// To filter out any updates that overlap the libitm stack, we define +// gtm_mask_stack_top to the entry point to the library and +// gtm_mask_stack_bottom to below the calling function (enforced with the +// noinline attribute). This definition should be fine for all +// stack-grows-down architectures. +// FIXME We fake the bottom to be lower so that we are safe even if we might +// call further functions (compared to where we called gtm_mask_stack_bottom +// in the call hierarchy) to actually undo or redo writes (e.g., memcpy). +// This is a completely arbitrary value; can we instead ensure that there are +// no such calls, or can we determine a future-proof value otherwise? +static inline void * +mask_stack_top(gtm_thread *tx) { return tx->jb.cfa; } +void * __attribute__((noinline)) +mask_stack_bottom(gtm_thread *tx); +#endif + } // namespace GTM #endif // LIBITM_TLS_H |