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/containers.h | |
parent | e478624f6c8d5ff2d43e5159d4435cbd75e4d5a7 (diff) | |
download | gcc-11f30bb0e4bf666229b6b236cd3e4ed1de13283a.tar.gz |
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/containers.h')
-rw-r--r-- | libitm/containers.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libitm/containers.h b/libitm/containers.h index e8aa94bb4f4..394b6f2508e 100644 --- a/libitm/containers.h +++ b/libitm/containers.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Free Software Foundation, Inc. +/* Copyright (C) 2011, 2012 Free Software Foundation, Inc. Contributed by Torvald Riegel <triegel@redhat.com>. This file is part of the GNU Transactional Memory Library (libitm). @@ -70,17 +70,24 @@ class vector } ~vector<T, alloc_separate_cl>() { if (m_capacity) free(entries); } - void resize() + void resize(size_t additional_capacity) { - if (m_capacity >= default_resize_max) - m_capacity = m_capacity + default_resize_max; + size_t target = m_capacity + additional_capacity; + if (target > default_resize_max) + m_capacity = ((target - 1 + default_resize_max) / default_resize_max) + * default_resize_max; else - m_capacity = m_capacity * 2; + while (m_capacity < target) + m_capacity = m_capacity * 2; if (m_capacity < default_resize_min) m_capacity = default_resize_min; entries = (T*) xrealloc(entries, sizeof(T) * m_capacity, alloc_separate_cl); } - void resize_noinline() __attribute__((noinline)) { resize(); } + void resize_noinline() __attribute__((noinline)) { resize(1); } + void resize_noinline(size_t elements) __attribute__((noinline)) + { + resize(elements); + } size_t size() const { return m_size; } size_t capacity() const { return this->capacity; } @@ -93,6 +100,15 @@ class vector return &entries[m_size++]; } + iterator push(size_t elements) + { + // We don't want inlining here since push() is often on the fast path. + if (unlikely(m_size + elements > m_capacity)) resize_noinline(elements); + iterator it = &entries[m_size]; + m_size += elements; + return it; + } + iterator pop() { if (likely(m_size > 0)) { |