]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libitm: Handle HTM fastpath in status query functions.
authorTorvald Riegel <triegel@redhat.com>
Thu, 20 Jun 2013 16:40:54 +0000 (16:40 +0000)
committerTorvald Riegel <torvald@gcc.gnu.org>
Thu, 20 Jun 2013 16:40:54 +0000 (16:40 +0000)
* query.cc (_ITM_inTransaction): Abort when using the HTM fastpath.
(_ITM_getTransactionId): Same.
* config/x86/target.h (htm_transaction_active): New.

From-SVN: r200251

libitm/ChangeLog
libitm/config/x86/target.h
libitm/query.cc

index 26001b670bd5e89817a49ff27336c0b4aded8a8a..81e5b6f447ba7ab90954fd36b287c2a79ffd8339 100644 (file)
@@ -1,3 +1,9 @@
+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
index 77b627f95bbd14eff0bb4efab3678b33b768f85e..063c09ed974292e8c59635398d547b334c11624e 100644 (file)
@@ -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
 
 
index 5707321f6c2cf7bd75b411e96992ee6ac91184e6..39a35b3e3b9492132779abc6fd4e702e345b08a6 100644 (file)
@@ -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;
 }