From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14197 invoked by alias); 13 Apr 2011 20:52:14 -0000 Received: (qmail 14188 invoked by uid 22791); 13 Apr 2011 20:52:12 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,SARE_SUB_ENC_UTF8,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Apr 2011 20:52:04 +0000 Received: from eggs.gnu.org ([140.186.70.92]:54930) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QA72h-0004Pv-JF for gcc-patches@gnu.org; Wed, 13 Apr 2011 16:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QA72g-0007ft-5i for gcc-patches@gnu.org; Wed, 13 Apr 2011 16:52:03 -0400 Received: from smtp141.iad.emailsrvr.com ([207.97.245.141]:33246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QA72f-0007fo-Vk for gcc-patches@gnu.org; Wed, 13 Apr 2011 16:52:02 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp54.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 5E2BE2B0B13 for ; Wed, 13 Apr 2011 16:52:01 -0400 (EDT) Received: from dynamic2.wm-web.iad.mlsrvr.com (dynamic2.wm-web.iad1a.rsapps.net [192.168.2.151]) by smtp54.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 48ABB2B03F7 for ; Wed, 13 Apr 2011 16:52:01 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic2.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 19F5828E8066 for ; Wed, 13 Apr 2011 16:52:01 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Wed, 13 Apr 2011 22:52:01 +0200 (CEST) Date: Wed, 13 Apr 2011 20:52:00 -0000 Subject: =?UTF-8?Q?ObjC:=20remove=20temporary=20tree=20list=20used=20when=20calli?= =?UTF-8?Q?ng=20objc=5Fdeclare=5Fclass()?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 Content-Type: text/plain;charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Type: plain Message-ID: <1302727921.10478072@192.168.4.58> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 207.97.245.141 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01028.txt.bz2 This patch removes another case of temporary tree chains from the ObjC compiler. When the parser finds a @class NSArray; declaration, it would call objc_declare_class() passing as argument=20 a temporary tree list containing the identifier. This tree list is created, used for the function call, then discarded. Btw, this made some sense when you have a list with multiple identifiers, as in @class NSArray, NSString; as they are all passed in the same linked list. it is still cleaner and more efficient to call objc_declare_class() for each identifier, as opposed to creating a temporary tree list, populating it with the identifiers, then calling objc_declare_class() which then iterates over the temporary tree list to read the identifiers, and then the list gets thrown away. The patch speeds things up but the effect is very small; the GNUstep system headers do contain about 800 @class declarations or so, so the patch typica= lly saves something like 1k allocations or so when compiling a file. That is probably a 0.05% speedup (order of magnitude). But we get rid of a the tre= e list. :-) The ObjC++ parser needed a bit of changes, but while changing it I also made the ObjC++ parsing code almost identical to the ObjC one, which simpli= fies maintenance. Ok to commit ? Thanks Index: c-family/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- c-family/ChangeLog (revision 172360) +++ c-family/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2011-04-13 Nicola Pero + + * stub-objc.c (objc_declare_class): Updated argument name. + 2011-04-12 Nathan Froyd =20 * c-common.h (c_common_init_ts): Declare. Index: c-family/stub-objc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- c-family/stub-objc.c (revision 172360) +++ c-family/stub-objc.c (working copy) @@ -110,7 +110,7 @@ objc_declare_alias (tree ARG_UNUSED (alias), tree } =20 void -objc_declare_class (tree ARG_UNUSED (list)) +objc_declare_class (tree ARG_UNUSED (identifier)) { } =20 Index: objc/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- objc/ChangeLog (revision 172360) +++ objc/ChangeLog (working copy) @@ -1,5 +1,12 @@ 2011-04-13 Nicola Pero =20 + * objc-act.c (objc_declare_class): Changed to take a single + identifier as argument instead of a tree list. This means callers + don't have to build temporary tree lists to call this function. + (synth_module_prologue): Updated calls to objc_declare_class. +=20=20=20=20=20=20=20 +2011-04-13 Nicola Pero + * objc-act.c (build_keyword_selector): Use get_identifier_with_leng= th instead of get_identifier. =20 Index: objc/objc-act.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- objc/objc-act.c (revision 172360) +++ objc/objc-act.c (working copy) @@ -2953,7 +2953,7 @@ synth_module_prologue (void) =20 /* Forward-declare '@interface Protocol'. */ type =3D get_identifier (PROTOCOL_OBJECT_CLASS_NAME); - objc_declare_class (tree_cons (NULL_TREE, type, NULL_TREE)); + objc_declare_class (type); objc_protocol_type =3D build_pointer_type (xref_tag (RECORD_TYPE, type)); =20 /* Declare receiver type used for dispatching messages to 'super'. */ @@ -2985,7 +2985,7 @@ synth_module_prologue (void) if (!constant_string_class_name) constant_string_class_name =3D runtime.default_constant_string_class_n= ame; constant_string_id =3D get_identifier (constant_string_class_name); - objc_declare_class (tree_cons (NULL_TREE, constant_string_id, NULL_TREE)= ); + objc_declare_class (constant_string_id); =20 /* Pre-build the following entities - for speed/convenience. */ self_id =3D get_identifier ("self"); @@ -3360,48 +3360,42 @@ objc_declare_alias (tree alias_ident, tree class_i } =20 void -objc_declare_class (tree ident_list) +objc_declare_class (tree identifier) { - tree list; #ifdef OBJCPLUS if (current_namespace !=3D global_namespace) { error ("Objective-C declarations may only appear in global scope"); } #endif /* OBJCPLUS */ =20 - for (list =3D ident_list; list; list =3D TREE_CHAIN (list)) + if (! objc_is_class_name (ident)) { - tree ident =3D TREE_VALUE (list); - - if (! objc_is_class_name (ident)) + tree record =3D lookup_name (ident), type =3D record; +=20=20=20=20=20=20 + if (record) { - tree record =3D lookup_name (ident), type =3D record; - - if (record) + if (TREE_CODE (record) =3D=3D TYPE_DECL) + type =3D DECL_ORIGINAL_TYPE (record) + ? DECL_ORIGINAL_TYPE (record) + : TREE_TYPE (record); +=20=20=20=20=20=20=20=20=20 + if (!TYPE_HAS_OBJC_INFO (type) + || !TYPE_OBJC_INTERFACE (type)) { - if (TREE_CODE (record) =3D=3D TYPE_DECL) - type =3D DECL_ORIGINAL_TYPE (record) - ? DECL_ORIGINAL_TYPE (record) - : TREE_TYPE (record); - - if (!TYPE_HAS_OBJC_INFO (type) - || !TYPE_OBJC_INTERFACE (type)) - { - error ("%qE redeclared as different kind of symbol", - ident); - error ("previous declaration of %q+D", - record); - } + error ("%qE redeclared as different kind of symbol", + ident); + error ("previous declaration of %q+D", + record); } - - record =3D xref_tag (RECORD_TYPE, ident); - INIT_TYPE_OBJC_INFO (record); - /* In the case of a @class declaration, we store the ident - in the TYPE_OBJC_INTERFACE. If later an @interface is - found, we'll replace the ident with the interface. */ - TYPE_OBJC_INTERFACE (record) =3D ident; - hash_class_name_enter (cls_name_hash_list, ident, NULL_TREE); } +=20=20=20=20=20=20 + record =3D xref_tag (RECORD_TYPE, ident); + INIT_TYPE_OBJC_INFO (record); + /* In the case of a @class declaration, we store the ident in + the TYPE_OBJC_INTERFACE. If later an @interface is found, + we'll replace the ident with the interface. */ + TYPE_OBJC_INTERFACE (record) =3D ident; + hash_class_name_enter (cls_name_hash_list, ident, NULL_TREE); } } =20 Index: ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ChangeLog (revision 172360) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-04-13 Nicola Pero + + * c-parser.c (c_parser_objc_class_declaration): Updated call to + objc_declare_class. + 2011-04-12 Nathan Froyd =20 * c-decl.c (union lang_tree_node): Check for TS_COMMON before Index: cp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- cp/ChangeLog (revision 172360) +++ cp/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-04-13 Nicola Pero + + * parser.c (cp_parser_objc_class_declaration): Updated for change + in objc_declare_class(). + 2011-04-12 Nathan Froyd =20 * cp-lang.c (cp_init_ts): Call cp_common_init_ts. Move Index: cp/parser.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- cp/parser.c (revision 172360) +++ cp/parser.c (working copy) @@ -21615,7 +21615,21 @@ static void cp_parser_objc_class_declaration (cp_parser* parser) { cp_lexer_consume_token (parser->lexer); /* Eat '@class'. */ - objc_declare_class (cp_parser_objc_identifier_list (parser)); + while (true) + { + tree id; +=20=20=20=20=20=20 + id =3D cp_parser_identifier (parser); + if (id =3D=3D error_mark_node) + break; +=20=20=20=20=20=20 + objc_declare_class (id); + + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) + cp_lexer_consume_token (parser->lexer); + else + break; + } cp_parser_consume_semicolon_at_end_of_statement (parser); } =20 Index: c-parser.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- c-parser.c (revision 172360) +++ c-parser.c (working copy) @@ -6994,7 +6994,6 @@ c_parser_objc_class_instance_variables (c_parser * static void c_parser_objc_class_declaration (c_parser *parser) { - tree list =3D NULL_TREE; gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_CLASS)); c_parser_consume_token (parser); /* Any identifiers, including those declared as type names, are OK @@ -7010,7 +7009,7 @@ c_parser_objc_class_declaration (c_parser *parser) return; } id =3D c_parser_peek_token (parser)->value; - list =3D chainon (list, build_tree_list (NULL_TREE, id)); + objc_declare_class (id); c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_COMMA)) c_parser_consume_token (parser); @@ -7018,7 +7017,6 @@ c_parser_objc_class_declaration (c_parser *parser) break; } c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); - objc_declare_class (list); } =20 /* Parse an objc-alias-declaration.