aboutsummaryrefslogtreecommitdiff
path: root/libitm/libitm_i.h
diff options
context:
space:
mode:
authorTorvald Riegel <triegel@redhat.com>2012-01-08 14:13:49 +0000
committerTorvald Riegel <torvald@gcc.gnu.org>2012-01-08 14:13:49 +0000
commit11f30bb0e4bf666229b6b236cd3e4ed1de13283a (patch)
treee99be86994cc6e298f8d9dc2f3c832fa4d95755b /libitm/libitm_i.h
parente478624f6c8d5ff2d43e5159d4435cbd75e4d5a7 (diff)
downloadgcc-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/libitm_i.h')
-rw-r--r--libitm/libitm_i.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/libitm/libitm_i.h b/libitm/libitm_i.h
index b53792a..f922d22 100644
--- a/libitm/libitm_i.h
+++ b/libitm/libitm_i.h
@@ -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).
@@ -93,9 +93,6 @@ struct gtm_alloc_action
bool allocated;
};
-// This type is private to local.c.
-struct gtm_undolog_entry;
-
struct gtm_thread;
// A transaction checkpoint: data that has to saved and restored when doing
@@ -121,6 +118,29 @@ struct gtm_transaction_cp
void commit(gtm_thread* tx);
};
+// An undo log for writes.
+struct gtm_undolog
+{
+ vector<gtm_word> undolog;
+
+ // Log the previous value at a certain address.
+ // The easiest way to inline this is to just define this here.
+ void log(const void *ptr, size_t len)
+ {
+ size_t words = (len + sizeof(gtm_word) - 1) / sizeof(gtm_word);
+ gtm_word *undo = undolog.push(words + 2);
+ memcpy(undo, ptr, len);
+ undo[words] = len;
+ undo[words + 1] = (gtm_word) ptr;
+ }
+
+ void commit () { undolog.clear(); }
+ size_t size() const { return undolog.size(); }
+
+ // In local.cc
+ void rollback (size_t until_size = 0);
+};
+
// Contains all thread-specific data required by the entire library.
// This includes all data relevant to a single transaction. Because most
// thread-specific data is about the current transaction, we also refer to
@@ -148,7 +168,7 @@ struct gtm_thread
gtm_jmpbuf jb;
// Data used by local.c for the undo log for both local and shared memory.
- vector<gtm_undolog_entry*> undolog;
+ gtm_undolog undolog;
// Data used by alloc.c for the malloc/free undo log.
aa_tree<uintptr_t, gtm_alloc_action> alloc_actions;
@@ -254,11 +274,6 @@ struct gtm_thread
// In eh_cpp.cc
void revert_cpp_exceptions (gtm_transaction_cp *cp = 0);
- // In local.cc
- void commit_undolog (void);
- void rollback_undolog (size_t until_size = 0);
- void drop_references_undolog (const void *, size_t);
-
// In retry.cc
// Must be called outside of transactions (i.e., after rollback).
void decide_retry_strategy (gtm_restart_reason);