public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: optimize EH phase 2
@ 2023-06-01  3:12 Jason Merrill
  2023-06-01  9:09 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2023-06-01  3:12 UTC (permalink / raw)
  To: gcc-patches, libstdc++

Tested x86_64-pc-linux-gnu, OK for trunk?

-- 8< --

In the ABI's two-phase EH model, first we walk the stack looking for a
handler, then we walk the stack running cleanups until we reach that
handler.  In the cleanup phase, we shouldn't redundantly check the handlers
along the way, e.g. when walking through g():

  void f() { throw 42; }
  void g() { try { f(); } catch (void *) { } }
  int main() { try { g(); } catch (int) { } }

libstdc++-v3/ChangeLog:

	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Don't check
	handlers in the cleanup phase.
---
 libstdc++-v3/libsupc++/eh_personality.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libstdc++-v3/libsupc++/eh_personality.cc b/libstdc++-v3/libsupc++/eh_personality.cc
index 12391e563d6..cc6bc048892 100644
--- a/libstdc++-v3/libsupc++/eh_personality.cc
+++ b/libstdc++-v3/libsupc++/eh_personality.cc
@@ -592,6 +592,10 @@ PERSONALITY_FUNCTION (int version,
 	      // Zero filter values are cleanups.
 	      saw_cleanup = true;
 	    }
+	  else if (actions == _UA_CLEANUP_PHASE)
+	    // We checked the handlers in the search phase; if one of them
+	    // matched, actions would also have _UA_HANDLER_FRAME set.
+	    ;
 	  else if (ar_filter > 0)
 	    {
 	      // Positive filter values are handlers.

base-commit: 68816ba245afc6d0e1482bde2d15b35b925b4195
-- 
2.31.1


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

* Re: [PATCH] libstdc++: optimize EH phase 2
  2023-06-01  3:12 [PATCH] libstdc++: optimize EH phase 2 Jason Merrill
@ 2023-06-01  9:09 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-06-01  9:09 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches, libstdc++

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

On Thu, 1 Jun 2023 at 04:13, Jason Merrill via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

> Tested x86_64-pc-linux-gnu, OK for trunk?
>

OK, thanks.


>
> -- 8< --
>
> In the ABI's two-phase EH model, first we walk the stack looking for a
> handler, then we walk the stack running cleanups until we reach that
> handler.  In the cleanup phase, we shouldn't redundantly check the handlers
> along the way, e.g. when walking through g():
>
>   void f() { throw 42; }
>   void g() { try { f(); } catch (void *) { } }
>   int main() { try { g(); } catch (int) { } }
>
> libstdc++-v3/ChangeLog:
>
>         * libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Don't check
>         handlers in the cleanup phase.
> ---
>  libstdc++-v3/libsupc++/eh_personality.cc | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libstdc++-v3/libsupc++/eh_personality.cc
> b/libstdc++-v3/libsupc++/eh_personality.cc
> index 12391e563d6..cc6bc048892 100644
> --- a/libstdc++-v3/libsupc++/eh_personality.cc
> +++ b/libstdc++-v3/libsupc++/eh_personality.cc
> @@ -592,6 +592,10 @@ PERSONALITY_FUNCTION (int version,
>               // Zero filter values are cleanups.
>               saw_cleanup = true;
>             }
> +         else if (actions == _UA_CLEANUP_PHASE)
> +           // We checked the handlers in the search phase; if one of them
> +           // matched, actions would also have _UA_HANDLER_FRAME set.
> +           ;
>           else if (ar_filter > 0)
>             {
>               // Positive filter values are handlers.
>
> base-commit: 68816ba245afc6d0e1482bde2d15b35b925b4195
> --
> 2.31.1
>
>

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

end of thread, other threads:[~2023-06-01  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01  3:12 [PATCH] libstdc++: optimize EH phase 2 Jason Merrill
2023-06-01  9:09 ` 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).