Clean up some minor white space issues in trans-decl.c and trans-expr.c
[official-gcc.git] / libitm / beginend.cc
blob00d28f4efb64d96f37d7be23b0bd897a0ab5cc61
1 /* Copyright (C) 2008-2016 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.com>.
4 This file is part of the GNU Transactional Memory Library (libitm).
6 Libitm is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #include "libitm_i.h"
26 #include <pthread.h>
29 using namespace GTM;
31 #if !defined(HAVE_ARCH_GTM_THREAD) || !defined(HAVE_ARCH_GTM_THREAD_DISP)
32 extern __thread gtm_thread_tls _gtm_thr_tls;
33 #endif
35 gtm_rwlock GTM::gtm_thread::serial_lock;
36 gtm_thread *GTM::gtm_thread::list_of_threads = 0;
37 unsigned GTM::gtm_thread::number_of_threads = 0;
39 /* ??? Move elsewhere when we figure out library initialization. */
40 uint64_t GTM::gtm_spin_count_var = 1000;
42 #ifdef HAVE_64BIT_SYNC_BUILTINS
43 static atomic<_ITM_transactionId_t> global_tid;
44 #else
45 static _ITM_transactionId_t global_tid;
46 static pthread_mutex_t global_tid_lock = PTHREAD_MUTEX_INITIALIZER;
47 #endif
50 // Provides a on-thread-exit callback used to release per-thread data.
51 static pthread_key_t thr_release_key;
52 static pthread_once_t thr_release_once = PTHREAD_ONCE_INIT;
54 // See gtm_thread::begin_transaction.
55 uint32_t GTM::htm_fastpath = 0;
57 /* Allocate a transaction structure. */
58 void *
59 GTM::gtm_thread::operator new (size_t s)
61 void *tx;
63 assert(s == sizeof(gtm_thread));
65 tx = xmalloc (sizeof (gtm_thread), true);
66 memset (tx, 0, sizeof (gtm_thread));
68 return tx;
71 /* Free the given transaction. Raises an error if the transaction is still
72 in use. */
73 void
74 GTM::gtm_thread::operator delete(void *tx)
76 free(tx);
79 static void
80 thread_exit_handler(void *)
82 gtm_thread *thr = gtm_thr();
83 if (thr)
84 delete thr;
85 set_gtm_thr(0);
88 static void
89 thread_exit_init()
91 if (pthread_key_create(&thr_release_key, thread_exit_handler))
92 GTM_fatal("Creating thread release TLS key failed.");
96 GTM::gtm_thread::~gtm_thread()
98 if (nesting > 0)
99 GTM_fatal("Thread exit while a transaction is still active.");
101 // Deregister this transaction.
102 serial_lock.write_lock ();
103 gtm_thread **prev = &list_of_threads;
104 for (; *prev; prev = &(*prev)->next_thread)
106 if (*prev == this)
108 *prev = (*prev)->next_thread;
109 break;
112 number_of_threads--;
113 number_of_threads_changed(number_of_threads + 1, number_of_threads);
114 serial_lock.write_unlock ();
117 GTM::gtm_thread::gtm_thread ()
119 // This object's memory has been set to zero by operator new, so no need
120 // to initialize any of the other primitive-type members that do not have
121 // constructors.
122 shared_state.store(-1, memory_order_relaxed);
124 // Register this transaction with the list of all threads' transactions.
125 serial_lock.write_lock ();
126 next_thread = list_of_threads;
127 list_of_threads = this;
128 number_of_threads++;
129 number_of_threads_changed(number_of_threads - 1, number_of_threads);
130 serial_lock.write_unlock ();
132 init_cpp_exceptions ();
134 if (pthread_once(&thr_release_once, thread_exit_init))
135 GTM_fatal("Initializing thread release TLS key failed.");
136 // Any non-null value is sufficient to trigger destruction of this
137 // transaction when the current thread terminates.
138 if (pthread_setspecific(thr_release_key, this))
139 GTM_fatal("Setting thread release TLS key failed.");
142 static inline uint32_t
143 choose_code_path(uint32_t prop, abi_dispatch *disp)
145 if ((prop & pr_uninstrumentedCode) && disp->can_run_uninstrumented_code())
146 return a_runUninstrumentedCode;
147 else
148 return a_runInstrumentedCode;
151 uint32_t
152 GTM::gtm_thread::begin_transaction (uint32_t prop, const gtm_jmpbuf *jb)
154 static const _ITM_transactionId_t tid_block_size = 1 << 16;
156 gtm_thread *tx;
157 abi_dispatch *disp;
158 uint32_t ret;
160 // ??? pr_undoLogCode is not properly defined in the ABI. Are barriers
161 // omitted because they are not necessary (e.g., a transaction on thread-
162 // local data) or because the compiler thinks that some kind of global
163 // synchronization might perform better?
164 if (unlikely(prop & pr_undoLogCode))
165 GTM_fatal("pr_undoLogCode not supported");
167 #ifdef USE_HTM_FASTPATH
168 // HTM fastpath. Only chosen in the absence of transaction_cancel to allow
169 // using an uninstrumented code path.
170 // The fastpath is enabled only by dispatch_htm's method group, which uses
171 // serial-mode methods as fallback. Serial-mode transactions cannot execute
172 // concurrently with HW transactions because the latter monitor the serial
173 // lock's writer flag and thus abort if another thread is or becomes a
174 // serial transaction. Therefore, if the fastpath is enabled, then a
175 // transaction is not executing as a HW transaction iff the serial lock is
176 // write-locked. This allows us to use htm_fastpath and the serial lock's
177 // writer flag to reliable determine whether the current thread runs a HW
178 // transaction, and thus we do not need to maintain this information in
179 // per-thread state.
180 // If an uninstrumented code path is not available, we can still run
181 // instrumented code from a HW transaction because the HTM fastpath kicks
182 // in early in both begin and commit, and the transaction is not canceled.
183 // HW transactions might get requests to switch to serial-irrevocable mode,
184 // but these can be ignored because the HTM provides all necessary
185 // correctness guarantees. Transactions cannot detect whether they are
186 // indeed in serial mode, and HW transactions should never need serial mode
187 // for any internal changes (e.g., they never abort visibly to the STM code
188 // and thus do not trigger the standard retry handling).
189 #ifndef HTM_CUSTOM_FASTPATH
190 if (likely(htm_fastpath && (prop & pr_hasNoAbort)))
192 for (uint32_t t = htm_fastpath; t; t--)
194 uint32_t ret = htm_begin();
195 if (htm_begin_success(ret))
197 // We are executing a transaction now.
198 // Monitor the writer flag in the serial-mode lock, and abort
199 // if there is an active or waiting serial-mode transaction.
200 // Note that this can also happen due to an enclosing
201 // serial-mode transaction; we handle this case below.
202 if (unlikely(serial_lock.is_write_locked()))
203 htm_abort();
204 else
205 // We do not need to set a_saveLiveVariables because of HTM.
206 return (prop & pr_uninstrumentedCode) ?
207 a_runUninstrumentedCode : a_runInstrumentedCode;
209 // The transaction has aborted. Don't retry if it's unlikely that
210 // retrying the transaction will be successful.
211 if (!htm_abort_should_retry(ret))
212 break;
213 // Wait until any concurrent serial-mode transactions have finished.
214 // This is an empty critical section, but won't be elided.
215 if (serial_lock.is_write_locked())
217 tx = gtm_thr();
218 if (unlikely(tx == NULL))
220 // See below.
221 tx = new gtm_thread();
222 set_gtm_thr(tx);
224 // Check whether there is an enclosing serial-mode transaction;
225 // if so, we just continue as a nested transaction and don't
226 // try to use the HTM fastpath. This case can happen when an
227 // outermost relaxed transaction calls unsafe code that starts
228 // a transaction.
229 if (tx->nesting > 0)
230 break;
231 // Another thread is running a serial-mode transaction. Wait.
232 serial_lock.read_lock(tx);
233 serial_lock.read_unlock(tx);
234 // TODO We should probably reset the retry count t here, unless
235 // we have retried so often that we should go serial to avoid
236 // starvation.
240 #else
241 // If we have a custom HTM fastpath in ITM_beginTransaction, we implement
242 // just the retry policy here. We communicate with the custom fastpath
243 // through additional property bits and return codes, and either transfer
244 // control back to the custom fastpath or run the fallback mechanism. The
245 // fastpath synchronization algorithm itself is the same.
246 // pr_HTMRetryableAbort states that a HW transaction started by the custom
247 // HTM fastpath aborted, and that we thus have to decide whether to retry
248 // the fastpath (returning a_tryHTMFastPath) or just proceed with the
249 // fallback method.
250 if (likely(htm_fastpath && (prop & pr_HTMRetryableAbort)))
252 tx = gtm_thr();
253 if (unlikely(tx == NULL))
255 // See below.
256 tx = new gtm_thread();
257 set_gtm_thr(tx);
259 // If this is the first abort, reset the retry count. We abuse
260 // restart_total for the retry count, which is fine because our only
261 // other fallback will use serial transactions, which don't use
262 // restart_total but will reset it when committing.
263 if (!(prop & pr_HTMRetriedAfterAbort))
264 tx->restart_total = htm_fastpath;
266 if (--tx->restart_total > 0)
268 // Wait until any concurrent serial-mode transactions have finished.
269 // Essentially the same code as above.
270 if (serial_lock.is_write_locked())
272 if (tx->nesting > 0)
273 goto stop_custom_htm_fastpath;
274 serial_lock.read_lock(tx);
275 serial_lock.read_unlock(tx);
277 // Let ITM_beginTransaction retry the custom HTM fastpath.
278 return a_tryHTMFastPath;
281 stop_custom_htm_fastpath:
282 #endif
283 #endif
285 tx = gtm_thr();
286 if (unlikely(tx == NULL))
288 // Create the thread object. The constructor will also set up automatic
289 // deletion on thread termination.
290 tx = new gtm_thread();
291 set_gtm_thr(tx);
294 if (tx->nesting > 0)
296 // This is a nested transaction.
297 // Check prop compatibility:
298 // The ABI requires pr_hasNoFloatUpdate, pr_hasNoVectorUpdate,
299 // pr_hasNoIrrevocable, pr_aWBarriersOmitted, pr_RaRBarriersOmitted, and
300 // pr_hasNoSimpleReads to hold for the full dynamic scope of a
301 // transaction. We could check that these are set for the nested
302 // transaction if they are also set for the parent transaction, but the
303 // ABI does not require these flags to be set if they could be set,
304 // so the check could be too strict.
305 // ??? For pr_readOnly, lexical or dynamic scope is unspecified.
307 if (prop & pr_hasNoAbort)
309 // We can use flat nesting, so elide this transaction.
310 if (!(prop & pr_instrumentedCode))
312 if (!(tx->state & STATE_SERIAL) ||
313 !(tx->state & STATE_IRREVOCABLE))
314 tx->serialirr_mode();
316 // Increment nesting level after checking that we have a method that
317 // allows us to continue.
318 tx->nesting++;
319 return choose_code_path(prop, abi_disp());
322 // The transaction might abort, so use closed nesting if possible.
323 // pr_hasNoAbort has lexical scope, so the compiler should really have
324 // generated an instrumented code path.
325 assert(prop & pr_instrumentedCode);
327 // Create a checkpoint of the current transaction.
328 gtm_transaction_cp *cp = tx->parent_txns.push();
329 cp->save(tx);
330 new (&tx->alloc_actions) aa_tree<uintptr_t, gtm_alloc_action>();
332 // Check whether the current method actually supports closed nesting.
333 // If we can switch to another one, do so.
334 // If not, we assume that actual aborts are infrequent, and rather
335 // restart in _ITM_abortTransaction when we really have to.
336 disp = abi_disp();
337 if (!disp->closed_nesting())
339 // ??? Should we elide the transaction if there is no alternative
340 // method that supports closed nesting? If we do, we need to set
341 // some flag to prevent _ITM_abortTransaction from aborting the
342 // wrong transaction (i.e., some parent transaction).
343 abi_dispatch *cn_disp = disp->closed_nesting_alternative();
344 if (cn_disp)
346 disp = cn_disp;
347 set_abi_disp(disp);
351 else
353 // Outermost transaction
354 disp = tx->decide_begin_dispatch (prop);
355 set_abi_disp (disp);
358 // Initialization that is common for outermost and nested transactions.
359 tx->prop = prop;
360 tx->nesting++;
362 tx->jb = *jb;
364 // As long as we have not exhausted a previously allocated block of TIDs,
365 // we can avoid an atomic operation on a shared cacheline.
366 if (tx->local_tid & (tid_block_size - 1))
367 tx->id = tx->local_tid++;
368 else
370 #ifdef HAVE_64BIT_SYNC_BUILTINS
371 // We don't really care which block of TIDs we get but only that we
372 // acquire one atomically; therefore, relaxed memory order is
373 // sufficient.
374 tx->id = global_tid.fetch_add(tid_block_size, memory_order_relaxed);
375 tx->local_tid = tx->id + 1;
376 #else
377 pthread_mutex_lock (&global_tid_lock);
378 global_tid += tid_block_size;
379 tx->id = global_tid;
380 tx->local_tid = tx->id + 1;
381 pthread_mutex_unlock (&global_tid_lock);
382 #endif
385 // Log the number of uncaught exceptions if we might have to roll back this
386 // state.
387 if (tx->cxa_uncaught_count_ptr != 0)
388 tx->cxa_uncaught_count = *tx->cxa_uncaught_count_ptr;
390 // Run dispatch-specific restart code. Retry until we succeed.
391 GTM::gtm_restart_reason rr;
392 while ((rr = disp->begin_or_restart()) != NO_RESTART)
394 tx->decide_retry_strategy(rr);
395 disp = abi_disp();
398 // Determine the code path to run. Only irrevocable transactions cannot be
399 // restarted, so all other transactions need to save live variables.
400 ret = choose_code_path(prop, disp);
401 if (!(tx->state & STATE_IRREVOCABLE))
402 ret |= a_saveLiveVariables;
403 return ret;
407 void
408 GTM::gtm_transaction_cp::save(gtm_thread* tx)
410 // Save everything that we might have to restore on restarts or aborts.
411 jb = tx->jb;
412 undolog_size = tx->undolog.size();
413 memcpy(&alloc_actions, &tx->alloc_actions, sizeof(alloc_actions));
414 user_actions_size = tx->user_actions.size();
415 id = tx->id;
416 prop = tx->prop;
417 cxa_catch_count = tx->cxa_catch_count;
418 cxa_uncaught_count = tx->cxa_uncaught_count;
419 disp = abi_disp();
420 nesting = tx->nesting;
423 void
424 GTM::gtm_transaction_cp::commit(gtm_thread* tx)
426 // Restore state that is not persistent across commits. Exception handling,
427 // information, nesting level, and any logs do not need to be restored on
428 // commits of nested transactions. Allocation actions must be committed
429 // before committing the snapshot.
430 tx->jb = jb;
431 memcpy(&tx->alloc_actions, &alloc_actions, sizeof(alloc_actions));
432 tx->id = id;
433 tx->prop = prop;
437 void
438 GTM::gtm_thread::rollback (gtm_transaction_cp *cp, bool aborting)
440 // The undo log is special in that it used for both thread-local and shared
441 // data. Because of the latter, we have to roll it back before any
442 // dispatch-specific rollback (which handles synchronization with other
443 // transactions).
444 undolog.rollback (this, cp ? cp->undolog_size : 0);
446 // Perform dispatch-specific rollback.
447 abi_disp()->rollback (cp);
449 // Roll back all actions that are supposed to happen around the transaction.
450 rollback_user_actions (cp ? cp->user_actions_size : 0);
451 commit_allocations (true, (cp ? &cp->alloc_actions : 0));
452 revert_cpp_exceptions (cp);
454 if (cp)
456 // We do not yet handle restarts of nested transactions. To do that, we
457 // would have to restore some state (jb, id, prop, nesting) not to the
458 // checkpoint but to the transaction that was started from this
459 // checkpoint (e.g., nesting = cp->nesting + 1);
460 assert(aborting);
461 // Roll back the rest of the state to the checkpoint.
462 jb = cp->jb;
463 id = cp->id;
464 prop = cp->prop;
465 if (cp->disp != abi_disp())
466 set_abi_disp(cp->disp);
467 memcpy(&alloc_actions, &cp->alloc_actions, sizeof(alloc_actions));
468 nesting = cp->nesting;
470 else
472 // Roll back to the outermost transaction.
473 // Restore the jump buffer and transaction properties, which we will
474 // need for the longjmp used to restart or abort the transaction.
475 if (parent_txns.size() > 0)
477 jb = parent_txns[0].jb;
478 id = parent_txns[0].id;
479 prop = parent_txns[0].prop;
481 // Reset the transaction. Do not reset this->state, which is handled by
482 // the callers. Note that if we are not aborting, we reset the
483 // transaction to the point after having executed begin_transaction
484 // (we will return from it), so the nesting level must be one, not zero.
485 nesting = (aborting ? 0 : 1);
486 parent_txns.clear();
489 if (this->eh_in_flight)
491 _Unwind_DeleteException ((_Unwind_Exception *) this->eh_in_flight);
492 this->eh_in_flight = NULL;
496 void ITM_REGPARM
497 _ITM_abortTransaction (_ITM_abortReason reason)
499 gtm_thread *tx = gtm_thr();
501 assert (reason == userAbort || reason == (userAbort | outerAbort));
502 assert ((tx->prop & pr_hasNoAbort) == 0);
504 if (tx->state & gtm_thread::STATE_IRREVOCABLE)
505 abort ();
507 // Roll back to innermost transaction.
508 if (tx->parent_txns.size() > 0 && !(reason & outerAbort))
510 // If the current method does not support closed nesting but we are
511 // nested and must only roll back the innermost transaction, then
512 // restart with a method that supports closed nesting.
513 abi_dispatch *disp = abi_disp();
514 if (!disp->closed_nesting())
515 tx->restart(RESTART_CLOSED_NESTING);
517 // The innermost transaction is a closed nested transaction.
518 gtm_transaction_cp *cp = tx->parent_txns.pop();
519 uint32_t longjmp_prop = tx->prop;
520 gtm_jmpbuf longjmp_jb = tx->jb;
522 tx->rollback (cp, true);
524 // Jump to nested transaction (use the saved jump buffer).
525 GTM_longjmp (a_abortTransaction | a_restoreLiveVariables,
526 &longjmp_jb, longjmp_prop);
528 else
530 // There is no nested transaction or an abort of the outermost
531 // transaction was requested, so roll back to the outermost transaction.
532 tx->rollback (0, true);
534 // Aborting an outermost transaction finishes execution of the whole
535 // transaction. Therefore, reset transaction state.
536 if (tx->state & gtm_thread::STATE_SERIAL)
537 gtm_thread::serial_lock.write_unlock ();
538 else
539 gtm_thread::serial_lock.read_unlock (tx);
540 tx->state = 0;
542 GTM_longjmp (a_abortTransaction | a_restoreLiveVariables,
543 &tx->jb, tx->prop);
547 bool
548 GTM::gtm_thread::trycommit ()
550 nesting--;
552 // Skip any real commit for elided transactions.
553 if (nesting > 0 && (parent_txns.size() == 0 ||
554 nesting > parent_txns[parent_txns.size() - 1].nesting))
555 return true;
557 if (nesting > 0)
559 // Commit of a closed-nested transaction. Remove one checkpoint and add
560 // any effects of this transaction to the parent transaction.
561 gtm_transaction_cp *cp = parent_txns.pop();
562 commit_allocations(false, &cp->alloc_actions);
563 cp->commit(this);
564 return true;
567 // Commit of an outermost transaction.
568 gtm_word priv_time = 0;
569 if (abi_disp()->trycommit (priv_time))
571 // The transaction is now finished but we will still access some shared
572 // data if we have to ensure privatization safety.
573 bool do_read_unlock = false;
574 if (state & gtm_thread::STATE_SERIAL)
576 gtm_thread::serial_lock.write_unlock ();
577 // There are no other active transactions, so there's no need to
578 // enforce privatization safety.
579 priv_time = 0;
581 else
583 // If we have to ensure privatization safety, we must not yet
584 // release the read lock and become inactive because (1) we still
585 // have to go through the list of all transactions, which can be
586 // modified by serial mode threads, and (2) we interpret each
587 // transactions' shared_state in the context of what we believe to
588 // be the current method group (and serial mode transactions can
589 // change the method group). Therefore, if we have to ensure
590 // privatization safety, delay becoming inactive but set a maximum
591 // snapshot time (we have committed and thus have an empty snapshot,
592 // so it will always be most recent). Use release MO so that this
593 // synchronizes with other threads observing our snapshot time.
594 if (priv_time)
596 do_read_unlock = true;
597 shared_state.store((~(typeof gtm_thread::shared_state)0) - 1,
598 memory_order_release);
600 else
601 gtm_thread::serial_lock.read_unlock (this);
603 state = 0;
605 // We can commit the undo log after dispatch-specific commit and after
606 // making the transaction inactive because we only have to reset
607 // gtm_thread state.
608 undolog.commit ();
609 // Reset further transaction state.
610 cxa_catch_count = 0;
611 restart_total = 0;
613 // Ensure privatization safety, if necessary.
614 if (priv_time)
616 // There must be a seq_cst fence between the following loads of the
617 // other transactions' shared_state and the dispatch-specific stores
618 // that signal updates by this transaction (e.g., lock
619 // acquisitions). This ensures that if we read prior to other
620 // reader transactions setting their shared_state to 0, then those
621 // readers will observe our updates. We can reuse the seq_cst fence
622 // in serial_lock.read_unlock() if we performed that; if not, we
623 // issue the fence.
624 if (do_read_unlock)
625 atomic_thread_fence (memory_order_seq_cst);
626 // TODO Don't just spin but also block using cond vars / futexes
627 // here. Should probably be integrated with the serial lock code.
628 for (gtm_thread *it = gtm_thread::list_of_threads; it != 0;
629 it = it->next_thread)
631 if (it == this) continue;
632 // We need to load other threads' shared_state using acquire
633 // semantics (matching the release semantics of the respective
634 // updates). This is necessary to ensure that the other
635 // threads' memory accesses happen before our actions that
636 // assume privatization safety.
637 // TODO Are there any platform-specific optimizations (e.g.,
638 // merging barriers)?
639 while (it->shared_state.load(memory_order_acquire) < priv_time)
640 cpu_relax();
644 // After ensuring privatization safety, we are now truly inactive and
645 // thus can release the read lock. We will also execute potentially
646 // privatizing actions (e.g., calling free()). User actions are first.
647 if (do_read_unlock)
648 gtm_thread::serial_lock.read_unlock (this);
649 commit_user_actions ();
650 commit_allocations (false, 0);
652 return true;
654 return false;
657 void ITM_NORETURN
658 GTM::gtm_thread::restart (gtm_restart_reason r, bool finish_serial_upgrade)
660 // Roll back to outermost transaction. Do not reset transaction state because
661 // we will continue executing this transaction.
662 rollback ();
664 // If we have to restart while an upgrade of the serial lock is happening,
665 // we need to finish this here, after rollback (to ensure privatization
666 // safety despite undo writes) and before deciding about the retry strategy
667 // (which could switch to/from serial mode).
668 if (finish_serial_upgrade)
669 gtm_thread::serial_lock.write_upgrade_finish(this);
671 decide_retry_strategy (r);
673 // Run dispatch-specific restart code. Retry until we succeed.
674 abi_dispatch* disp = abi_disp();
675 GTM::gtm_restart_reason rr;
676 while ((rr = disp->begin_or_restart()) != NO_RESTART)
678 decide_retry_strategy(rr);
679 disp = abi_disp();
682 GTM_longjmp (choose_code_path(prop, disp) | a_restoreLiveVariables,
683 &jb, prop);
686 void ITM_REGPARM
687 _ITM_commitTransaction(void)
689 #if defined(USE_HTM_FASTPATH)
690 // HTM fastpath. If we are not executing a HW transaction, then we will be
691 // a serial-mode transaction. If we are, then there will be no other
692 // concurrent serial-mode transaction.
693 // See gtm_thread::begin_transaction.
694 if (likely(htm_fastpath && !gtm_thread::serial_lock.is_write_locked()))
696 htm_commit();
697 return;
699 #endif
700 gtm_thread *tx = gtm_thr();
701 if (!tx->trycommit ())
702 tx->restart (RESTART_VALIDATE_COMMIT);
705 void ITM_REGPARM
706 _ITM_commitTransactionEH(void *exc_ptr)
708 #if defined(USE_HTM_FASTPATH)
709 // See _ITM_commitTransaction.
710 if (likely(htm_fastpath && !gtm_thread::serial_lock.is_write_locked()))
712 htm_commit();
713 return;
715 #endif
716 gtm_thread *tx = gtm_thr();
717 if (!tx->trycommit ())
719 tx->eh_in_flight = exc_ptr;
720 tx->restart (RESTART_VALIDATE_COMMIT);