Re: Placement of vtables, inlines and such
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Placement of vtables, inlines and such
- To: cxx-abi@xxxxxxxxxxxx
- Subject: Re: Placement of vtables, inlines and such
- From: Daveed Vandevoorde <daveed@xxxxxxx>
- Date: Thu, 24 Jun 1999 23:04:38 -0700
Jason Merrill wrote:
[...]
> No. gc works by sweeping from main, finding all the referenced symbols;
> any sections that haven't provided any symbols are discarded. If we use
> weak symbols for vtables and put them in separate sections, gc will keep at
> most one copy, as needed. There is no notion of a special symbol.
How does this work in shared libraries? Is GC done at load time?
> gc is a more general solution, as it also can discard normal code that
> isn't actually needed. It also allows us to discard all copies in cases
> where that is appropriate, such as when we can get the vtable from one of
> our shared libs.
I guess that means the answer to the above is "yes"?
[...]
> This does bring up another issue; handling initialization. g++ handles
> initialization of a weak/COMDAT object by emitting a sentry along with it,
> which gets set when the object has been initialized.
Do you thread-protect it? (just curious)
[...]
> Aha. I guess there's no point in trying to avoid dealing with local
> statics then.
I'm afraid so. An idiom to protect against initialization order
dependencies is:
inline X& x() {
static X lx;
return lx;
}
(and use x() instead of a global x everywhere.)
I've seen increased usage of this and it would be nice if it could be
inlined.
Daveed