From patchwork Wed Oct 6 19:23:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 66963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D0C7CB70DC for ; Thu, 7 Oct 2010 06:24:08 +1100 (EST) Received: (qmail 8442 invoked by alias); 6 Oct 2010 19:24:05 -0000 Received: (qmail 8119 invoked by uid 22791); 6 Oct 2010 19:24:04 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_BJ X-Spam-Check-By: sourceware.org Received: from c2bthomr13.btconnect.com (HELO mail.btconnect.com) (213.123.20.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Oct 2010 19:23:57 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2bthomr13.btconnect.com with ESMTP id AEA24285; Wed, 06 Oct 2010 20:23:54 +0100 (BST) Message-Id: <0C9A52AA-1165-494E-8635-CF3B823ADA8F@sandoe-acoustics.co.uk> From: IainS To: GCC Patches Mime-Version: 1.0 (Apple Message framework v936) Subject: [Patch ObjC*] Vec-ify build_objc_method_call() Date: Wed, 6 Oct 2010 20:23:53 +0100 Cc: Mike Stump , Nicola Pero X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0302.4CACCCC9.0142, actions=tag X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0204.4CACCCCA.0290, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, while working on method attributes and @property I had occasion to spend a bit of time around build_objc_method_call(). I noticed that build_objc_method_call () constructs lists and passes them to build_function_call() - which promptly turns them into VECs. The patch cuts out the middle-man ;-) OK for trunk? Iain gcc/objc: * objc-act.c (build_objc_method_call): Replace calls to build_function_call with the VEC equivalent. Construct parameter lists as Vecs. Index: gcc/objc/objc-act.c =================================================================== --- gcc/objc/objc-act.c (revision 165023) +++ gcc/objc/objc-act.c (working copy) @@ -6686,6 +6690,8 @@ build_objc_method_call (location_t loc, int super_ : umsg_decl) : umsg_nonnil_decl)); tree rcv_p = (super_flag ? objc_super_type : objc_object_type); + VEC(tree, gc) *parms = NULL; + unsigned nparm = (method_params ? list_length (method_params) : 0); /* If a prototype for the method to be called exists, then cast the sender's return type and arguments to match that of the method. @@ -6707,6 +6713,9 @@ build_objc_method_call (location_t loc, int super_ /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object); + /* Param list + 2 slots for object and selector. */ + parms = VEC_alloc (tree, gc, nparm + 2); + if (flag_next_runtime) { /* If we are returning a struct in memory, and the address @@ -6721,38 +6730,40 @@ build_objc_method_call (location_t loc, int super_ sender = (super_flag ? umsg_super_stret_decl : flag_nil_receivers ? umsg_stret_decl : umsg_nonnil_stret_decl); - method_params = tree_cons (NULL_TREE, lookup_object, - tree_cons (NULL_TREE, selector, - method_params)); method = build_fold_addr_expr_loc (input_location, sender); + /* Pass the object to the method. */ + VEC_quick_push (tree, parms, lookup_object); } else { /* This is the portable (GNU) way. */ - tree object; - /* First, call the lookup function to get a pointer to the method, then cast the pointer, then call it with the method arguments. */ + VEC(tree, gc) *tv = VEC_alloc (tree, gc, 2); + VEC_quick_push (tree, tv, lookup_object); + VEC_quick_push (tree, tv, selector); + method = build_function_call_vec (loc, sender, tv, NULL); + VEC_free (tree, gc, tv); - object = (super_flag ? self_decl : lookup_object); + /* Pass the appropriate object to the method. */ + VEC_quick_push (tree, parms, (super_flag ? self_decl : lookup_object)); + } - t = tree_cons (NULL_TREE, selector, NULL_TREE); - t = tree_cons (NULL_TREE, lookup_object, t); - method = build_function_call (loc, sender, t); + /* Pass the selector to the method. */ + VEC_quick_push (tree, parms, selector); + /* Now append the remainder of the parms. */ + if (nparm) + for (; method_params; method_params = TREE_CHAIN (method_params)) + VEC_quick_push (tree, parms, TREE_VALUE (method_params)); - /* Pass the object to the method. */ - method_params = tree_cons (NULL_TREE, object, - tree_cons (NULL_TREE, selector, - method_params)); - } + /* Build an obj_type_ref, with the correct cast for the method call. */ + t = build3 (OBJ_TYPE_REF, sender_cast, method, + lookup_object, size_zero_node); + t = build_function_call_vec (loc, t, parms, NULL);\ + VEC_free (tree, gc, parms); + return t; +} - /* ??? Selector is not at this point something we can use inside - the compiler itself. Set it to garbage for the nonce. */ - t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node); - return build_function_call (loc, - t, method_params); -} - static void build_protocol_reference (tree p) {