From: Jonathan Wakely <jwakely@redhat.com>
To: Alexey Lapshin <alexey.lapshin@espressif.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
Ivan Grokhotkov <ivan@espressif.com>,
Alexey Gerenkov <alexey.gerenkov@espressif.com>,
Anton Maklakov <anton.maklakov@espressif.com>
Subject: Re: [PATCH] libstdc++: Configurable exception emergency pool size
Date: Wed, 12 Oct 2022 21:48:10 +0100 [thread overview]
Message-ID: <CACb0b4ngEKEKGV1bN7jDonSCRO7ECCer78DHDS9wzeW7OU2B_A@mail.gmail.com> (raw)
In-Reply-To: <019f1d36fd8e730634ae4a764b2c56b6eb59b673.camel@espressif.com>
On Wed, 12 Oct 2022 at 20:30, Alexey Lapshin via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> From 8b27091310d2857880d8733a05813ca92a5a3e6f Mon Sep 17 00:00:00 2001
> From: Alexey Gerenkov <alexey@espressif.com>
> Date: Thu, 16 Nov 2017 15:06:35 +0300
> Subject: [PATCH] libstdc++: Configurable exception emergency pool size
This patch won't apply to trunk because of
https://gcc.gnu.org/g:637e3668fdc17c4e226538fb14f9fab225433d01
Please take a look at that (and the follow up in
23c3cbaed36f6d2f3a7a64f6ebda69329723514b) and decide if you still want
to change anything.
In any case, I think some targets don't support __attribute((weak)) so
any change like that would have to make it conditional (possibly on
__GXX_WEAK__ but I'm not sure if that's the right check).
> ---
> libstdc++-v3/libsupc++/eh_alloc.cc | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-
> v3/libsupc++/eh_alloc.cc
> index 68f319869f9..6503041c20a 100644
> --- a/libstdc++-v3/libsupc++/eh_alloc.cc
> +++ b/libstdc++-v3/libsupc++/eh_alloc.cc
> @@ -50,12 +50,13 @@ extern "C" void *memset (void *, int, std::size_t);
>
> using namespace __cxxabiv1;
>
> -// ??? How to control these parameters.
> -
> // Guess from the size of basic types how large a buffer is
> reasonable.
> // Note that the basic c++ exception header has 13 pointers and 2
> ints,
> // so on a system with PSImode pointers we're talking about 56 bytes
> // just for overhead.
> +// To fix this:
> +// Implement C function __cxx_eh_arena_size_get() in your codebase
> which
> +// returns size (size_t) for buffer to allocate.
>
> #if INT_MAX == 32767
> # define EMERGENCY_OBJ_SIZE 128
> @@ -73,6 +74,12 @@ using namespace __cxxabiv1;
> # define EMERGENCY_OBJ_COUNT 4
> #endif
>
> +extern "C" __attribute__((weak)) size_t __cxx_eh_arena_size_get(void)
> +{
> + return EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
> + + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception);
> +}
> +
> namespace __gnu_cxx
> {
> void __freeres();
> @@ -116,11 +123,8 @@ namespace
>
> pool::pool()
> {
> - // Allocate the arena - we could add a GLIBCXX_EH_ARENA_SIZE
> environment
> - // to make this tunable.
> - arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
> - + EMERGENCY_OBJ_COUNT * sizeof
> (__cxa_dependent_exception));
> - arena = (char *)malloc (arena_size);
> + arena_size = __cxx_eh_arena_size_get();
> + arena = arena_size ? (char *)malloc (arena_size) : NULL;
> if (!arena)
> {
> // If the allocation failed go without an emergency pool.
> --
> 2.34.1
>
prev parent reply other threads:[~2022-10-12 20:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 19:29 Alexey Lapshin
2022-10-12 20:48 ` Jonathan Wakely [this message]
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=CACb0b4ngEKEKGV1bN7jDonSCRO7ECCer78DHDS9wzeW7OU2B_A@mail.gmail.com \
--to=jwakely@redhat.com \
--cc=alexey.gerenkov@espressif.com \
--cc=alexey.lapshin@espressif.com \
--cc=anton.maklakov@espressif.com \
--cc=ivan@espressif.com \
--cc=libstdc++@gcc.gnu.org \
/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).