From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7466 invoked by alias); 26 Nov 2007 06:32:52 -0000 Received: (qmail 7451 invoked by uid 22791); 26 Nov 2007 06:32:39 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 26 Nov 2007 06:32:33 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lAQ6WVUH006974; Mon, 26 Nov 2007 01:32:31 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lAQ6WUV8010251; Mon, 26 Nov 2007 01:32:31 -0500 Received: from livre.oliva.athome.lsd.ic.unicamp.br (vpn-14-104.rdu.redhat.com [10.11.14.104]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lAQ6WTF4013842; Mon, 26 Nov 2007 01:32:30 -0500 Received: from livre.oliva.athome.lsd.ic.unicamp.br (localhost.localdomain [127.0.0.1]) by livre.oliva.athome.lsd.ic.unicamp.br (8.14.2/8.13.8) with ESMTP id lAQ6WSeB027083; Mon, 26 Nov 2007 04:32:28 -0200 Received: (from aoliva@localhost) by livre.oliva.athome.lsd.ic.unicamp.br (8.14.2/8.13.5/Submit) id lAQ6WQYH027082; Mon, 26 Nov 2007 04:32:26 -0200 To: Andrew Haley Cc: gcc-patches@gcc.gnu.org Subject: Re: [vta/trunk] stabilize Java JNI function types References: <18232.42294.832970.814067@zebedee.pink> From: Alexandre Oliva Errors-To: aoliva@oliva.athome.lsd.ic.unicamp.br Date: Mon, 26 Nov 2007 09:27:00 -0000 In-Reply-To: <18232.42294.832970.814067@zebedee.pink> (Andrew Haley's message of "Mon\, 12 Nov 2007 19\:10\:46 +0000") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: 2007-11/txt/msg01353.txt.bz2 --=-=-= Content-length: 256 On Nov 12, 2007, Andrew Haley wrote: >> * expr.c (build_jni_stub): Use the computed jni func type for >> variable meth. > Ok, if you include a comment in the source explaining why you do this. Here's what I've checked in. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=gcc-stabilize-java-jnitypes-gc.patch Content-length: 2925 for gcc/java/ChangeLog from Alexandre Oliva * expr.c (build_jni_stub): Use the computed jni func type for variable meth. Index: gcc/java/expr.c =================================================================== --- gcc/java/expr.c.orig 2007-11-25 02:54:58.000000000 -0200 +++ gcc/java/expr.c 2007-11-25 03:09:27.000000000 -0200 @@ -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. */ --=-=-= Content-length: 249 -- Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/ FSF Latin America Board Member http://www.fsfla.org/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} --=-=-=--