public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* I need a new configure toggle to completely remove emergency heap
@ 2022-10-11 23:48 unlvsur unlvsur
  2022-10-12  8:32 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: unlvsur unlvsur @ 2022-10-11 23:48 UTC (permalink / raw)
  To: unlvsur unlvsur via Libstdc++

[-- Attachment #1: Type: text/plain, Size: 132 bytes --]

If eh fails to allocate, just let is crash please.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: I need a new configure toggle to completely remove emergency heap
  2022-10-11 23:48 I need a new configure toggle to completely remove emergency heap unlvsur unlvsur
@ 2022-10-12  8:32 ` Jonathan Wakely
  2022-10-12 14:45   ` unlvsur unlvsur
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2022-10-12  8:32 UTC (permalink / raw)
  To: unlvsur unlvsur; +Cc: unlvsur unlvsur via Libstdc++

On Wed, 12 Oct 2022 at 00:49, unlvsur unlvsur via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> If eh fails to allocate, just let is crash please.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.alloc
"Setting obj-count to zero will disable the pool, so that no emergency
buffer is present."


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: I need a new configure toggle to completely remove emergency heap
  2022-10-12  8:32 ` Jonathan Wakely
@ 2022-10-12 14:45   ` unlvsur unlvsur
  2022-10-12 22:13     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: unlvsur unlvsur @ 2022-10-12 14:45 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: unlvsur unlvsur via Libstdc++

[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

But the code is still there. tbh i have patched them myself to remove emergency heap and all its related logic completely for a very long time and i never see any abi issues around it.

The toggle i need should just disable all code around it


Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Jonathan Wakely <jwakely@redhat.com>
Sent: Wednesday, October 12, 2022 4:32:01 AM
To: unlvsur unlvsur <unlvsur@live.com>
Cc: unlvsur unlvsur via Libstdc++ <libstdc++@gcc.gnu.org>
Subject: Re: I need a new configure toggle to completely remove emergency heap

On Wed, 12 Oct 2022 at 00:49, unlvsur unlvsur via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> If eh fails to allocate, just let is crash please.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.alloc
"Setting obj-count to zero will disable the pool, so that no emergency
buffer is present."


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: I need a new configure toggle to completely remove emergency heap
  2022-10-12 14:45   ` unlvsur unlvsur
@ 2022-10-12 22:13     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2022-10-12 22:13 UTC (permalink / raw)
  To: unlvsur unlvsur; +Cc: unlvsur unlvsur via Libstdc++

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

On Wed, 12 Oct 2022 at 15:45, unlvsur unlvsur <unlvsur@live.com> wrote:
>
> But the code is still there. tbh i have patched them myself to remove emergency heap and all its related logic completely for a very long time and i never see any abi issues around it.
>
> The toggle i need should just disable all code around it

So like this untested patch.

We should probably also make __cxa_free_dependent_exception an alias
of __cxa_free_exception to save a few more bytes.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2866 bytes --]

commit 5c4a63e883efe0e3910a8bb391d3091cb8558d54
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 12 23:04:53 2022

    libstdc++: Disable all emergency EH pool code if obj-count == 0
    
    For a zero-sized static pool we can completely elide all code for the EH
    pool.
    
    libstdc++-v3/ChangeLog:
    
            * libsupc++/eh_alloc.cc [EMERGENCY_OBJ_COUNT==0]
            [!USE_POOL] (__gnu_cxx::__freeres, pool): Do not define.
            (__cxxabiv1::__cxa_allocate_exception) [!USE_POOL]: Do not use
            pool.
            (__cxxabiv1::__cxa_free_exception) [!USE_POOL]: Likewise.
            (__cxxabiv1::__cxa_allocate_dependent_exception) [!USE_POOL]:
            Likewise.
            (__cxxabiv1::__cxa_free_dependent_exception) [!USE_POOL]:
            Likewise.

diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc
index 81b8a1548c6..adf027a3b64 100644
--- a/libstdc++-v3/libsupc++/eh_alloc.cc
+++ b/libstdc++-v3/libsupc++/eh_alloc.cc
@@ -101,12 +101,15 @@ using namespace __cxxabiv1;
 #ifdef _GLIBCXX_EH_POOL_NOBJS
 # if _GLIBCXX_EH_POOL_NOBJS > MAX_OBJ_COUNT
 #  warning "_GLIBCXX_EH_POOL_NOBJS value is too large; ignoring it"
+# elif _GLIBCXX_EH_POOL_NOBJS < 0
+#  warning "_GLIBCXX_EH_POOL_NOBJS value is negative; ignoring it"
 # else
 #  undef EMERGENCY_OBJ_COUNT
 #  define EMERGENCY_OBJ_COUNT _GLIBCXX_EH_POOL_NOBJS
 # endif
 #endif
 
+#if EMERGENCY_OBJ_COUNT > 0
 namespace __gnu_cxx
 {
   void __freeres() noexcept;
@@ -374,6 +377,7 @@ namespace __gnu_cxx
 #endif
   }
 }
+#endif // EMERGENCY_OBJ_COUNT > 0
 
 extern "C" void *
 __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept
@@ -382,8 +386,10 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept
 
   void *ret = malloc (thrown_size);
 
+#if EMERGENCY_OBJ_COUNT > 0
   if (!ret)
     ret = emergency_pool.allocate (thrown_size);
+#endif
 
   if (!ret)
     std::terminate ();
@@ -398,9 +404,11 @@ extern "C" void
 __cxxabiv1::__cxa_free_exception(void *vptr) noexcept
 {
   char *ptr = (char *) vptr - sizeof (__cxa_refcounted_exception);
+#if EMERGENCY_OBJ_COUNT > 0
   if (emergency_pool.in_pool (ptr)) [[__unlikely__]]
     emergency_pool.free (ptr);
   else
+#endif
     free (ptr);
 }
 
@@ -410,8 +418,10 @@ __cxxabiv1::__cxa_allocate_dependent_exception() noexcept
 {
   void *ret = malloc (sizeof (__cxa_dependent_exception));
 
+#if EMERGENCY_OBJ_COUNT > 0
   if (!ret)
     ret = emergency_pool.allocate (sizeof (__cxa_dependent_exception));
+#endif
 
   if (!ret)
     std::terminate ();
@@ -426,8 +436,10 @@ extern "C" void
 __cxxabiv1::__cxa_free_dependent_exception
   (__cxa_dependent_exception *vptr) noexcept
 {
+#if EMERGENCY_OBJ_COUNT > 0
   if (emergency_pool.in_pool (vptr)) [[__unlikely__]]
     emergency_pool.free (vptr);
   else
+#endif
     free (vptr);
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-12 22:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 23:48 I need a new configure toggle to completely remove emergency heap unlvsur unlvsur
2022-10-12  8:32 ` Jonathan Wakely
2022-10-12 14:45   ` unlvsur unlvsur
2022-10-12 22:13     ` Jonathan Wakely

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).