summaryrefslogtreecommitdiffstats
path: root/libitm/local.cc
diff options
context:
space:
mode:
authortorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-08 14:13:49 +0000
committertorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-08 14:13:49 +0000
commitdf4a1bb5025e3bd3b5e1366c44148c2f0d58d57d (patch)
treee99be86994cc6e298f8d9dc2f3c832fa4d95755b /libitm/local.cc
parent49dc2bdc682b9c0d7323fcdb9ad59f5aa17e1545 (diff)
downloadppe42-gcc-df4a1bb5025e3bd3b5e1366c44148c2f0d58d57d.tar.gz
ppe42-gcc-df4a1bb5025e3bd3b5e1366c44148c2f0d58d57d.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182992 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libitm/local.cc')
-rw-r--r--libitm/local.cc70
1 files changed, 8 insertions, 62 deletions
diff --git a/libitm/local.cc b/libitm/local.cc
index 4f47ff2e5f6..39b6da3a5d2 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
OpenPOWER on IntegriCloud