diff options
author | Torvald Riegel <triegel@redhat.com> | 2012-01-08 14:13:49 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2012-01-08 14:13:49 +0000 |
commit | 11f30bb0e4bf666229b6b236cd3e4ed1de13283a (patch) | |
tree | e99be86994cc6e298f8d9dc2f3c832fa4d95755b /libitm/local.cc | |
parent | e478624f6c8d5ff2d43e5159d4435cbd75e4d5a7 (diff) | |
download | gcc-11f30bb0e4bf666229b6b236cd3e4ed1de13283a.zip gcc-11f30bb0e4bf666229b6b236cd3e4ed1de13283a.tar.gz gcc-11f30bb0e4bf666229b6b236cd3e4ed1de13283a.tar.bz2 |
libitm: Optimize undo log.
libitm/
* local.cc (GTM_LB): Use GTM::gtm_undolog.
(GTM::gtm_thread::drop_references_undolog): Remove.
(GTM::gtm_thread::commit_undolog,
GTM::gtm_thread::rollback_undolog): Move to ...
* libitm_i.h (GTM::gtm_undolog): ...here. New.
(GTM::gtm_undolog_entry): Remove.
(GTM::gtm_thread): Adapt.
* beginend.cc (GTM::gtm_thread::rollback): Adapt.
(GTM::gtm_thread::trycommit): Adapt.
* method-serial.cc (serial_dispatch::log): Adapt.
* method-gl.cc (gl_wt_dispatch::pre_write): Adapt.
(gl_wt_dispatch::store): Fix likely/unlikely.
* containers.h (GTM::vector::resize): Add additional_capacity
parameter and handle it.
(GTM::vector::resize_noinline): New/adapt.
(GTM::vector::push): New.
From-SVN: r182992
Diffstat (limited to 'libitm/local.cc')
-rw-r--r-- | libitm/local.cc | 70 |
1 files changed, 8 insertions, 62 deletions
diff --git a/libitm/local.cc b/libitm/local.cc index 4f47ff2..39b6da3 100644 --- a/libitm/local.cc +++ b/libitm/local.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2008, 2009, 2011, 2012 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU Transactional Memory Library (libitm). @@ -26,29 +26,9 @@ namespace GTM HIDDEN { -struct gtm_undolog_entry -{ - void *addr; - size_t len; - char saved[]; -}; - void -gtm_thread::commit_undolog () -{ - size_t i, n = undolog.size(); - - if (n > 0) - { - for (i = 0; i < n; ++i) - free (undolog[i]); - this->undolog.clear(); - } -} - -void -gtm_thread::rollback_undolog (size_t until_size) +gtm_undolog::rollback (size_t until_size) { size_t i, n = undolog.size(); @@ -56,36 +36,11 @@ gtm_thread::rollback_undolog (size_t until_size) { for (i = n; i-- > until_size; ) { - gtm_undolog_entry *u = *undolog.pop(); - if (u) - { - memcpy (u->addr, u->saved, u->len); - free (u); - } - } - } -} - -/* Forget any references to PTR in the local log. */ - -void -gtm_thread::drop_references_undolog (const void *ptr, size_t len) -{ - size_t i, n = undolog.size(); - - if (n > 0) - { - for (i = n; i > 0; i--) - { - gtm_undolog_entry *u = undolog[i]; - /* ?? Do we need such granularity, or can we get away with - just comparing PTR and LEN. ?? */ - if ((const char *)u->addr >= (const char *)ptr - && ((const char *)u->addr + u->len <= (const char *)ptr + len)) - { - free (u); - undolog[i] = NULL; - } + void *ptr = (void *) undolog[i--]; + size_t len = undolog[i]; + size_t words = (len + sizeof(gtm_word) - 1) / sizeof(gtm_word); + i -= words; + __builtin_memcpy (ptr, &undolog[i], len); } } } @@ -94,16 +49,7 @@ void ITM_REGPARM GTM_LB (const void *ptr, size_t len) { gtm_thread *tx = gtm_thr(); - gtm_undolog_entry *undo; - - undo = (gtm_undolog_entry *) - xmalloc (sizeof (struct gtm_undolog_entry) + len); - undo->addr = (void *) ptr; - undo->len = len; - - tx->undolog.push()[0] = undo; - - memcpy (undo->saved, ptr, len); + tx->undolog.log(ptr, len); } } // namespace GTM |