diff options
author | torvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-20 16:40:54 +0000 |
---|---|---|
committer | torvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-20 16:40:54 +0000 |
commit | 27ca454e9b64ef2b79d0747ab581c88bcb16e28c (patch) | |
tree | f73b28638776b1747b490781d1297b42620eb10e /libitm | |
parent | 00b76ca9c06e131110fb83e1de821d7d69f46bd2 (diff) | |
download | gcc-27ca454e9b64ef2b79d0747ab581c88bcb16e28c.tar.gz |
libitm: Handle HTM fastpath in status query functions.
* query.cc (_ITM_inTransaction): Abort when using the HTM fastpath.
(_ITM_getTransactionId): Same.
* config/x86/target.h (htm_transaction_active): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200251 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libitm')
-rw-r--r-- | libitm/ChangeLog | 6 | ||||
-rw-r--r-- | libitm/config/x86/target.h | 7 | ||||
-rw-r--r-- | libitm/query.cc | 14 |
3 files changed, 27 insertions, 0 deletions
diff --git a/libitm/ChangeLog b/libitm/ChangeLog index 26001b670bd..81e5b6f447b 100644 --- a/libitm/ChangeLog +++ b/libitm/ChangeLog @@ -1,5 +1,11 @@ 2013-06-20 Torvald Riegel <triegel@redhat.com> + * query.cc (_ITM_inTransaction): Abort when using the HTM fastpath. + (_ITM_getTransactionId): Same. + * config/x86/target.h (htm_transaction_active): New. + +2013-06-20 Torvald Riegel <triegel@redhat.com> + PR libitm/57643 * beginend.cc (gtm_thread::begin_transaction): Handle reentrancy in the HTM fastpath. diff --git a/libitm/config/x86/target.h b/libitm/config/x86/target.h index 77b627f95bb..063c09ed974 100644 --- a/libitm/config/x86/target.h +++ b/libitm/config/x86/target.h @@ -125,6 +125,13 @@ htm_abort_should_retry (uint32_t begin_ret) { return begin_ret & _XABORT_RETRY; } + +/* Returns true iff a hardware transaction is currently being executed. */ +static inline bool +htm_transaction_active () +{ + return _xtest() != 0; +} #endif diff --git a/libitm/query.cc b/libitm/query.cc index 5707321f6c2..39a35b3e3b9 100644 --- a/libitm/query.cc +++ b/libitm/query.cc @@ -43,6 +43,15 @@ _ITM_libraryVersion (void) _ITM_howExecuting ITM_REGPARM _ITM_inTransaction (void) { +#if defined(USE_HTM_FASTPATH) + // If we use the HTM fastpath, we cannot reliably detect whether we are + // in a transaction because this function can be called outside of + // a transaction and thus we can't deduce this by looking at just the serial + // lock. This function isn't used in practice currently, so the easiest + // way to handle it is to just abort. + if (htm_fastpath && htm_transaction_active()) + htm_abort(); +#endif struct gtm_thread *tx = gtm_thr(); if (tx && (tx->nesting > 0)) { @@ -58,6 +67,11 @@ _ITM_inTransaction (void) _ITM_transactionId_t ITM_REGPARM _ITM_getTransactionId (void) { +#if defined(USE_HTM_FASTPATH) + // See ITM_inTransaction. + if (htm_fastpath && htm_transaction_active()) + htm_abort(); +#endif struct gtm_thread *tx = gtm_thr(); return (tx && (tx->nesting > 0)) ? tx->id : _ITM_noTransactionId; } |