]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr.c (build_jni_stub): Use the computed jni func type for variable meth.
authorAlexandre Oliva <aoliva@redhat.com>
Mon, 26 Nov 2007 06:31:13 +0000 (06:31 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Mon, 26 Nov 2007 06:31:13 +0000 (06:31 +0000)
* expr.c (build_jni_stub): Use the computed jni func type for
variable meth.

From-SVN: r130428

gcc/java/ChangeLog
gcc/java/expr.c

index 477670130a290a314eb836e16438b32ea047fce4..65c4482ac3be524a51c2d679eba15d3bae1dd760 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-26  Alexandre Oliva  <aoliva@redhat.com>
+
+       * expr.c (build_jni_stub): Use the computed jni func type for
+       variable meth.
+
 2007-11-26  Alexandre Oliva  <aoliva@redhat.com>
 
        * class.c (JAVA_TREEHASHHASH_H): Use TYPE_UID.
index 8311fbcdee8a354ac1528f2bf906cc79fca59eba..a482a96923567b69a44a736adbab893d3ce07e79 100644 (file)
@@ -2651,17 +2651,6 @@ build_jni_stub (tree method)
       TREE_CHAIN (env_var) = res_var;
     }
 
-  meth_var = build_decl (VAR_DECL, get_identifier ("meth"), ptr_type_node);
-  TREE_STATIC (meth_var) = 1;
-  TREE_PUBLIC (meth_var) = 0;
-  DECL_EXTERNAL (meth_var) = 0;
-  DECL_CONTEXT (meth_var) = method;
-  DECL_ARTIFICIAL (meth_var) = 1;
-  DECL_INITIAL (meth_var) = null_pointer_node;
-  TREE_USED (meth_var) = 1;
-  chainon (env_var, meth_var);
-  build_result_decl (method);
-
   method_args = DECL_ARGUMENTS (method);
   block = build_block (env_var, NULL_TREE, method_args, NULL_TREE);
   TREE_SIDE_EFFECTS (block) = 1;
@@ -2725,23 +2714,40 @@ build_jni_stub (tree method)
 
   jni_func_type = build_pointer_type (tem);
 
-  jnifunc = build3 (COND_EXPR, ptr_type_node,
+  /* Use the actual function type, rather than a generic pointer type,
+     such that this decl keeps the actual pointer type from being
+     garbage-collected.  If it is, we end up using canonical types
+     with different uids for equivalent function types, and this in
+     turn causes utf8 identifiers and output order to vary.  */
+  meth_var = build_decl (VAR_DECL, get_identifier ("meth"), jni_func_type);
+  TREE_STATIC (meth_var) = 1;
+  TREE_PUBLIC (meth_var) = 0;
+  DECL_EXTERNAL (meth_var) = 0;
+  DECL_CONTEXT (meth_var) = method;
+  DECL_ARTIFICIAL (meth_var) = 1;
+  DECL_INITIAL (meth_var) = null_pointer_node;
+  TREE_USED (meth_var) = 1;
+  chainon (env_var, meth_var);
+  build_result_decl (method);
+
+  jnifunc = build3 (COND_EXPR, jni_func_type,
                    build2 (NE_EXPR, boolean_type_node,
                            meth_var, build_int_cst (TREE_TYPE (meth_var), 0)),
                    meth_var,
-                   build2 (MODIFY_EXPR, ptr_type_node, meth_var,
-                           build_call_nary (ptr_type_node,
-                                            build_address_of
-                                              (soft_lookupjnimethod_node),
-                                            4,
-                                            jniarg0, jniarg1,
-                                            jniarg2, jniarg3)));
+                   build2 (MODIFY_EXPR, jni_func_type, meth_var,
+                           build1
+                           (NOP_EXPR, jni_func_type,
+                            build_call_nary (ptr_type_node,
+                                             build_address_of
+                                             (soft_lookupjnimethod_node),
+                                             4,
+                                             jniarg0, jniarg1,
+                                             jniarg2, jniarg3))));
 
   /* Now we make the actual JNI call via the resulting function
      pointer.    */
   call = build_call_list (TREE_TYPE (TREE_TYPE (method)),
-                         build1 (NOP_EXPR, jni_func_type, jnifunc),
-                         args);
+                         jnifunc, args);
 
   /* If the JNI call returned a result, capture it here.  If we had to
      unwrap JNI object results, we would do that here.  */