This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: improve vtable emission
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Matt Austern <austern at apple dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 30 Dec 2002 11:58:30 -0800
- Subject: Re: PATCH: improve vtable emission
--On Monday, December 23, 2002 03:59:45 PM -0800 Matt Austern
<austern@apple.com> wrote:
The point of this patch is to reduce the number of dynamic classes
that finish_file has to look at. Especially in projects that use large
precompiled headers, we don't want finish_file to be traipsing all
over memory.
Good.
+ /* Find the key method */
+ if (TYPE_CONTAINS_VPTR_P (t))
+ {
+ CLASSTYPE_KEY_METHOD (t) = key_method (t);
+
+ /* If a polymorphic class has no key method, emit the vtable in
+ every translation unit where the class definition appear. */
+ if (CLASSTYPE_KEY_METHOD (t) == NULL_TREE &&
!processing_template_decl) + {
+ dynamic_classes = tree_cons (NULL_TREE, t, dynamic_classes);
+ }
+ }
That processing_template_decl check is not necessary; we can't be
processing a template at this point.
+ if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl)
+ && DECL_VIRTUAL_P (fndecl)
+ && !processing_template_decl)
+ {
+ tree fnclass = DECL_CLASS_CONTEXT (fndecl);
+ if (fndecl == CLASSTYPE_KEY_METHOD (fnclass))
+ {
+ /* If the function we thought was the key method turns out
+ to be inline, then the class has no key method. */
+ if (DECL_DECLARED_INLINE_P (fndecl))
+ CLASSTYPE_KEY_METHOD (fnclass) = NULL_TREE;
I'm not sure what this is for; the key method does not cease to be the
key method just because it ends up inline.
+ dynamic_classes = tree_cons (NULL_TREE, fnclass, dynamic_classes);
And why do we need to do this again? Oh, I see; dynamic_classes is
misnamed. Please rename it to something else more intuitive.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com