From: Mikhail Maltsev <maltsevm@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Bernd Schmidt <bschmidt@redhat.com>,
gcc-patches mailing list <gcc-patches@gcc.gnu.org>,
Jeff Law <law@redhat.com>
Subject: Re: [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators
Date: Mon, 26 Oct 2015 02:07:00 -0000 [thread overview]
Message-ID: <562D7F69.9030903@gmail.com> (raw)
In-Reply-To: <CAFiYyc2LefXW0Cohvkft3mkbF--qD4Xc8ubeM-EVE9ooV2OBrw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
On 10/21/2015 01:57 PM, Richard Biener wrote:
> Ugh (stupid templates).
>
> @@ -387,10 +389,10 @@ base_pool_allocator <TBlockAllocator>::allocate ()
> block = m_virgin_free_list;
> header = (allocation_pool_list*) allocation_object::get_data (block);
> header->next = NULL;
> -#ifdef ENABLE_CHECKING
> +
> /* Mark the element to be free. */
> - ((allocation_object*) block)->id = 0;
> -#endif
> + if (flag_checking)
> + ((allocation_object*) block)->id = 0;
>
> just set id to zero unconditionally. That'll be faster than checking
> flag_checking.
I fixed this and other issues, and committed the attached patch.
--
Regards,
Mikhail Maltsev
[-- Attachment #2: alloc_checking2.patch --]
[-- Type: text/x-patch, Size: 3347 bytes --]
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 81d0e1c..d8a22c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26 Mikhail Maltsev <maltsevm@gmail.com>
+
+ * alloc-pool.h (base_pool_allocator::initialize, ::allocate): Remove
+ conditional compilation.
+ (base_pool_allocator::remove): Use flag_checking.
+
2015-10-25 John David Anglin <danglin@gcc.gnu.org>
* config/pa/som.h (EH_FRAME_THROUGH_COLLECT2): Define.
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 70105ba..404b558 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see
#define ALLOC_POOL_H
#include "memory-block.h"
+#include "options.h" // for flag_checking
extern void dump_alloc_pool_statistics (void);
@@ -275,7 +276,6 @@ base_pool_allocator <TBlockAllocator>::initialize ()
m_elts_per_block = (TBlockAllocator::block_size - header_size) / size;
gcc_checking_assert (m_elts_per_block != 0);
-#ifdef ENABLE_CHECKING
/* Increase the last used ID and use it for this pool.
ID == 0 is used for free elements of pool so skip it. */
last_id++;
@@ -283,7 +283,6 @@ base_pool_allocator <TBlockAllocator>::initialize ()
last_id++;
m_id = last_id;
-#endif
}
/* Free all memory allocated for the given memory pool. */
@@ -387,10 +386,9 @@ base_pool_allocator <TBlockAllocator>::allocate ()
block = m_virgin_free_list;
header = (allocation_pool_list*) allocation_object::get_data (block);
header->next = NULL;
-#ifdef ENABLE_CHECKING
+
/* Mark the element to be free. */
((allocation_object*) block)->id = 0;
-#endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
m_returned_free_list = header;
m_virgin_free_list += m_elt_size;
@@ -404,10 +402,8 @@ base_pool_allocator <TBlockAllocator>::allocate ()
m_returned_free_list = header->next;
m_elts_free--;
-#ifdef ENABLE_CHECKING
/* Set the ID for element. */
allocation_object::get_instance (header)->id = m_id;
-#endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
return (void *)(header);
@@ -418,26 +414,23 @@ template <typename TBlockAllocator>
inline void
base_pool_allocator <TBlockAllocator>::remove (void *object)
{
- gcc_checking_assert (m_initialized);
-
- allocation_pool_list *header;
- int size ATTRIBUTE_UNUSED;
- size = m_elt_size - offsetof (allocation_object, u.data);
-
-#ifdef ENABLE_CHECKING
- gcc_assert (object
+ if (flag_checking)
+ {
+ gcc_assert (m_initialized);
+ gcc_assert (object
/* Check if we free more than we allocated, which is Bad (TM). */
&& m_elts_free < m_elts_allocated
/* Check whether the PTR was allocated from POOL. */
&& m_id == allocation_object::get_instance (object)->id);
- memset (object, 0xaf, size);
+ int size = m_elt_size - offsetof (allocation_object, u.data);
+ memset (object, 0xaf, size);
+ }
/* Mark the element to be free. */
allocation_object::get_instance (object)->id = 0;
-#endif
- header = (allocation_pool_list*) object;
+ allocation_pool_list *header = (allocation_pool_list*) object;
header->next = m_returned_free_list;
m_returned_free_list = header;
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (object, size));
next prev parent reply other threads:[~2015-10-26 1:18 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-05 23:27 [PATCH 1/9] ENABLE_CHECKING refactoring Mikhail Maltsev
2015-10-05 23:29 ` [PATCH 2/9] ENABLE_CHECKING refactoring: libcpp Mikhail Maltsev
2015-10-06 12:40 ` Bernd Schmidt
2015-10-12 20:57 ` Jeff Law
2015-10-19 1:18 ` Mikhail Maltsev
2015-10-21 22:29 ` Jeff Law
2015-10-21 21:19 ` Jeff Law
2015-10-05 23:30 ` [PATCH 3/9] ENABLE_CHECKING refactoring: Java and Ada Mikhail Maltsev
2015-10-22 19:25 ` Jeff Law
2015-10-05 23:31 ` [PATCH 4/9] ENABLE_CHECKING refactoring: Fortran Mikhail Maltsev
2015-10-23 22:38 ` Jeff Law
2015-10-05 23:32 ` [PATCH 5/9] ENABLE_CHECKING refactoring: pool allocators Mikhail Maltsev
2015-10-06 12:41 ` Bernd Schmidt
2015-10-06 12:45 ` Richard Biener
2015-10-19 0:47 ` Mikhail Maltsev
2015-10-21 11:02 ` Richard Biener
2015-10-26 2:07 ` Mikhail Maltsev [this message]
2015-10-26 9:48 ` Richard Biener
2015-10-26 10:57 ` Mikhail Maltsev
2015-10-05 23:34 ` [PATCH 6/9] ENABLE_CHECKING refactoring: generators Mikhail Maltsev
2015-10-06 12:57 ` Richard Biener
2015-10-19 0:09 ` Mikhail Maltsev
2015-10-21 10:57 ` Richard Biener
2015-10-28 16:32 ` Jeff Law
2015-10-29 16:31 ` Jeff Law
2015-10-05 23:39 ` [PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE Mikhail Maltsev
2015-10-06 12:46 ` Bernd Schmidt
2015-10-06 12:59 ` Richard Biener
2015-10-19 0:56 ` Mikhail Maltsev
2015-10-19 12:19 ` Bernd Schmidt
2015-10-26 17:04 ` Jeff Law
2015-10-26 17:15 ` Bernd Schmidt
2015-10-26 19:05 ` Jeff Law
2015-10-28 1:17 ` Jeff Law
2015-10-28 2:12 ` Trevor Saunders
2015-10-06 12:59 ` Richard Biener
2015-10-05 23:40 ` [PATCH 8/9] ENABLE_CHECKING refactoring: target-specific parts Mikhail Maltsev
2015-10-06 12:48 ` Bernd Schmidt
2015-10-29 19:43 ` Jeff Law
2015-10-29 21:23 ` Jeff Law
2015-10-30 4:13 ` Jeff Law
2015-10-30 4:20 ` Jeff Law
2015-10-06 12:53 ` [PATCH 1/9] ENABLE_CHECKING refactoring Richard Biener
2015-10-12 20:48 ` Jeff Law
2015-10-13 21:33 ` Jeff Law
2015-10-18 8:25 ` Mikhail Maltsev
2015-10-19 11:14 ` Bernd Schmidt
2015-10-19 13:54 ` Mikhail Maltsev
2015-10-21 15:59 ` Jeff Law
2015-10-21 16:06 ` Bernd Schmidt
2015-10-21 16:18 ` Richard Biener
2015-10-21 16:28 ` Jeff Law
2015-11-07 22:42 ` Gerald Pfeifer
2015-10-21 16:19 ` Jeff Law
2015-10-21 16:22 ` Bernd Schmidt
2015-10-21 16:44 ` Jakub Jelinek
2015-10-22 7:58 ` Richard Biener
2015-10-21 20:06 ` Jeff Law
2015-10-20 16:14 ` Jeff Law
2015-10-21 21:17 ` Jeff Law
2015-11-01 14:58 ` [PATCH 9/9] ENABLE_CHECKING refactoring: C family front ends Mikhail Maltsev
2015-11-02 23:34 ` Jeff Law
2015-11-04 14:41 ` Mikhail Maltsev
2015-11-01 20:19 ` [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences Mikhail Maltsev
2015-11-02 23:35 ` Jeff Law
2015-11-04 15:03 ` Mikhail Maltsev
2016-02-23 15:21 ` Richard Biener
2016-02-24 14:17 ` Martin Liška
2016-02-24 14:27 ` Michael Matz
2016-02-24 14:53 ` Martin Liška
2016-02-24 15:43 ` Pierre-Marie de Rodat
2016-02-25 9:24 ` Richard Biener
2016-02-25 10:14 ` Pierre-Marie de Rodat
2016-02-25 10:15 ` Martin Liška
2016-02-25 10:16 ` Pierre-Marie de Rodat
2016-02-25 9:24 ` Richard Biener
[not found] ` <C5BB0125-FB5F-46C6-B16D-74C3D0F07C10@gmail.com>
2015-11-08 15:37 ` Mikhail Maltsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=562D7F69.9030903@gmail.com \
--to=maltsevm@gmail.com \
--cc=bschmidt@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).