This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: __register_frame_info and unwinding shared libraries
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 Mar 2005 10:15:29 -0500
- Subject: Re: __register_frame_info and unwinding shared libraries
- References: <16914.12531.871015.381228@cuddles.cambridge.redhat.com> <20050215174122.GA12355@redhat.com> <16914.14655.110333.989891@cuddles.cambridge.redhat.com> <20050215182230.GR4777@sunsite.mff.cuni.cz> <16916.54735.948231.398474@cuddles.cambridge.redhat.com> <16933.54728.52579.63151@cuddles.cambridge.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Mar 02, 2005 at 03:03:36PM +0000, Andrew Haley wrote:
> This implements a cache of header info.
...
> As this is to some extent a fix for a performance regression, I'd like
> it to be considered for 4.0.
Thanks a lot, looks good to me (though I can't approve it), I'd even vote
for it being considered for 3.4 as well.
I just wonder if the data->check_cache = 0; shouldn't be moved.
> @@ -135,6 +155,82 @@ _Unwind_IteratePhdrCallback (struct dl_p
> p_eh_frame_hdr = NULL;
> p_dynamic = NULL;
>
> + struct frame_hdr_cache_element *prev_cache_entry = NULL,
> + *last_cache_entry = NULL;
> +
> + if (data->check_cache && size >= sizeof (struct ext_dl_phdr_info))
> + {
> + static unsigned long long adds = -1ULL, subs;
> + struct ext_dl_phdr_info *einfo = (struct ext_dl_phdr_info *) info;
> +
Here...
> + /* We use a least recently used cache replacement policy. Also,
> + the most recently used cache entries are placed at the head
> + of the search chain. */
> +
> + if (einfo->dlpi_adds == adds && einfo->dlpi_subs == subs)
> + {
> + /* Find data->pc in shared library cache.
> + Set load_base, p_eh_frame_hdr and p_dynamic
> + plus match from the cache and goto
> + "Read .eh_frame_hdr header." below. */
...
> + /* Initialize the cache. Create a chain of cache entries,
> + with the final one terminated by a NULL link. */
> + int i;
> + for (i = 0; i < FRAME_HDR_CACHE_SIZE; i++)
> + {
> + frame_hdr_cache[i].pc_low = 0;
> + frame_hdr_cache[i].pc_high = 0;
> + frame_hdr_cache[i].link = &frame_hdr_cache[i+1];
> + }
> + frame_hdr_cache[i-1].link = NULL;
> + frame_hdr_cache_head = &frame_hdr_cache[0];
> + data->check_cache = 0;
... from here.
Otherwise, I'm afraid if no new libraries have been dlopened and no libs
dlclosed since last _Unwind_Find_FDE call and you don't hit the cache,
you'll search the cache for every library searched rather than only
the first one.
Jakub