From: Jonathan Wakely <jwakely@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH RFA] libstdc++: small dynamic_cast optimization
Date: Wed, 7 Sep 2022 09:20:36 +0100 [thread overview]
Message-ID: <CACb0b4nVhgZSG+NzBGof7Ycq8rgCAR5y3D=5054Oe+Nb3pOziw@mail.gmail.com> (raw)
In-Reply-To: <20220907014444.1469136-1-jason@redhat.com>
On Wed, 7 Sept 2022 at 02:45, Jason Merrill via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> An email discussion of optimizing EH led me to wonder why we weren't doing
> this already. Not that this change affects EH at all.
>
> Tested x86_64-pc-linux-gnu. Does this seem worthwhile?
Yes, I think so. If there's a fast path, we should take it.
>
> libstdc++-v3/ChangeLog:
>
> * libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function
> call in simple success case.
> ---
> libstdc++-v3/libsupc++/dyncast.cc | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/libstdc++-v3/libsupc++/dyncast.cc b/libstdc++-v3/libsupc++/dyncast.cc
> index 853c911a4cf..616e4c05766 100644
> --- a/libstdc++-v3/libsupc++/dyncast.cc
> +++ b/libstdc++-v3/libsupc++/dyncast.cc
> @@ -71,6 +71,12 @@ __dynamic_cast (const void *src_ptr, // object started from
> if (whole_prefix->whole_type != whole_type)
> return NULL;
>
> + // Avoid virtual function call in the simple success case.
> + if (src2dst >= 0
> + && src2dst == -prefix->whole_object
> + && *whole_type == *dst_type)
> + return const_cast <void *> (whole_ptr);
> +
> whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public,
> dst_type, whole_ptr, src_type, src_ptr, result);
> if (!result.dst_ptr)
>
> base-commit: 0a2fba3697411c07a8330abfe7460ce62bce5e7f
> --
> 2.31.1
>
prev parent reply other threads:[~2022-09-07 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 1:44 Jason Merrill
2022-09-07 8:20 ` 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='CACb0b4nVhgZSG+NzBGof7Ycq8rgCAR5y3D=5054Oe+Nb3pOziw@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.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).