Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab

Simon Marchi
2018-07-18T03:34:05Z

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> In order to move psymtabs off of the objfile obstack, there must be no
> backlinks from the psymtab (or associated objects) to anything
> allocated on the objfile obstack.
>
> This patch removes the readin and compunit_symtab fields from psymtab
> to help achieve this goal, replacing them with per-objfile maps
> indicating which psymtabs have been read in. This split will allow
> for psymtab reuse across objfiles in the future.

This LGTM, but I have two question. In the future, is the intent to also
make symtabs (compunit_symtab) independent from program spaces, and
shareable across objfiles, or would that not be possible? If it is
possible, would the compunit_symtab pointer in psymtab re-appear, since
there would now again be a single compunit_symtab for each psymtab?

As Pedro pointed out a few times, unordered_map is an hash map with open
hashing. So we change what was previously a single pointer dereference
to a lookup in a hash table, followed with a linear search in a linked
list. If this map is looked up very frequently, maybe we should consider
using an htab_t instead? Some profiling data would help, but it seems
like psymtab_read_in_p is called quite a bit when looking up symbols...

Simon