This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PCH, and more generally C++ parser performance


Zack Weinberg <zack@wolery.cumb.org> writes:

> Look over at the conversation I've been having with Mark Mitchell.  He
> thinks we can't get away with lazy parsing of anything in C++, and has
> some solid arguments for it.

That's why my preferred scheme uses lazy _loading_, keyed by
identifier names.

I claim (and I'd be interested to know if anyone has a counterexample)
that if an identifier is never used other than to be declared or
defined, then program behaviour is the same as if those declarations
were never made.

So, for instance, if we have something like

#include <everything.h>
int foo (int bar)
{
  bar = f(g(i<3>));
}

then during parsing, everything relating to "foo", "bar", "f", "g",
"i" gets loaded from a pre-compiled header file, as are their types
and so on.

There are some other things I think I can claim:

- For a method, it is unnecessary to load it in if the name of its class
  is never referenced.

- For any procedure, it is unnecessary to load in the types of one of
  its parameters if they are not otherwise referenced.  It's not
  necessary to load in the type of the return value if any of its
  parameters have types that are not loaded in.  Of course we do need to
  have the procedure declaration itself loaded in.

- It's unnecessary to load in the definition of any procedure unless
  we would actually output it.

I think at this level it should be doable to implement this.  If I'm
lucky, we can go farther, so that if there are dozens of classes all
defining a 'f' method we don't have to load all them in (I'm thinking
here particularly of methods named things like 'clone()'); probably
for methods we don't need to load them in if the name of their class
is never referenced.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]