public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] don't use build_function_type in the Java FE
@ 2011-05-10 13:20 Nathan Froyd
  2011-05-10 13:23 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Froyd @ 2011-05-10 13:20 UTC (permalink / raw)
  To: gcc-patches, java-patches

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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] don't use build_function_type in the Java FE
  2011-05-10 13:20 [PATCH] don't use build_function_type in the Java FE Nathan Froyd
@ 2011-05-10 13:23 ` Andrew Haley
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Haley @ 2011-05-10 13:23 UTC (permalink / raw)
  To: java-patches

On 05/10/2011 02:20 PM, Nathan Froyd wrote:
> 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.
> 

Yes, thanks.

Andrew.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-10 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-10 13:20 [PATCH] don't use build_function_type in the Java FE Nathan Froyd
2011-05-10 13:23 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).