From patchwork Tue May 10 13:20:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 95009 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 A80F61007D5 for ; Wed, 11 May 2011 03:24:55 +1000 (EST) Received: (qmail 28950 invoked by alias); 10 May 2011 13:20:50 -0000 Received: (qmail 28939 invoked by uid 22791); 10 May 2011 13:20:49 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 13:20:36 +0000 Received: (qmail 20297 invoked from network); 10 May 2011 13:20:35 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 13:20:35 -0000 Date: Tue, 10 May 2011 06:20:35 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org, java-patches@gcc.gnu.org Subject: [PATCH] don't use build_function_type in the Java FE Message-ID: <20110510132035.GV23480@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) 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 As $SUBJECT suggests. Nothing much to see here. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan gcc/java/ * expr.c (build_jni_stub): Don't call build_function_type; call build_function_type_vec instead. * typeck.c (parse_signature_string): Likewise. diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 3be1cff..5d9811a 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -2616,7 +2616,7 @@ expand_invoke (int opcode, int method_ref_index, int nargs ATTRIBUTE_UNUSED) tree build_jni_stub (tree method) { - tree jnifunc, call, body, method_sig, arg_types; + tree jnifunc, call, body, method_sig, arg_type; tree jniarg0, jniarg1, jniarg2, jniarg3; tree jni_func_type, tem; tree env_var, res_var = NULL_TREE, block; @@ -2624,7 +2624,9 @@ build_jni_stub (tree method) tree meth_var; tree bind; VEC(tree,gc) *args = NULL; + VEC(tree,gc) *arg_types = NULL; int args_size = 0; + function_args_iterator iter; tree klass = DECL_CONTEXT (method); klass = build_class_ref (klass); @@ -2684,13 +2686,17 @@ build_jni_stub (tree method) VEC_safe_push (tree, gc, args, tem); } - arg_types = TYPE_ARG_TYPES (TREE_TYPE (method)); - /* Argument types for static methods and the JNIEnv structure. - FIXME: Write and use build_function_type_vec to avoid this. */ + /* Argument types for static methods and the JNIEnv structure. */ + VEC_safe_push (tree, gc, arg_types, ptr_type_node); if (METHOD_STATIC (method)) - arg_types = tree_cons (NULL_TREE, object_ptr_type_node, arg_types); - arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types); + VEC_safe_push (tree, gc, arg_types, object_ptr_type_node); + FOREACH_FUNCTION_ARGS (TREE_TYPE (method), arg_type, iter) + { + if (arg_type == void_type_node) + break; + VEC_safe_push (tree, gc, arg_types, arg_type); + } /* We call _Jv_LookupJNIMethod to find the actual underlying function pointer. _Jv_LookupJNIMethod will throw the appropriate @@ -2703,7 +2709,7 @@ build_jni_stub (tree method) IDENTIFIER_LENGTH (method_sig))); jniarg3 = build_int_cst (NULL_TREE, args_size); - tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types); + tem = build_function_type_vec (TREE_TYPE (TREE_TYPE (method)), arg_types); #ifdef MODIFY_JNI_METHOD_CALL tem = MODIFY_JNI_METHOD_CALL (tem); diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 6755217..247fd64 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -407,18 +407,17 @@ parse_signature_string (const unsigned char *sig_string, int sig_length) if (str < limit && str[0] == '(') { - tree argtype_list = NULL_TREE; + VEC(tree,gc) *argtypes = NULL; str++; while (str < limit && str[0] != ')') { tree argtype = parse_signature_type (&str, limit); - argtype_list = tree_cons (NULL_TREE, argtype, argtype_list); + VEC_safe_push (tree, gc, argtypes, argtype); } if (str++, str >= limit) abort (); result_type = parse_signature_type (&str, limit); - argtype_list = chainon (nreverse (argtype_list), end_params_node); - result_type = build_function_type (result_type, argtype_list); + result_type = build_function_type_vec (result_type, argtypes); } else result_type = parse_signature_type (&str, limit);