From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15407 invoked by alias); 9 Aug 2011 07:18:20 -0000 Received: (qmail 15394 invoked by uid 22791); 9 Aug 2011 07:18:19 -0000 X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_GC,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Aug 2011 07:18:03 +0000 Received: by iyn15 with SMTP id 15so11645061iyn.34 for ; Tue, 09 Aug 2011 00:18:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.43.46.193 with SMTP id up1mr6359787icb.352.1312874282395; Tue, 09 Aug 2011 00:18:02 -0700 (PDT) Received: by 10.42.151.7 with HTTP; Tue, 9 Aug 2011 00:18:02 -0700 (PDT) In-Reply-To: References: Date: Tue, 09 Aug 2011 07:18:00 -0000 Message-ID: Subject: Why does a 'new' statement produce so many temporary variables From: Li junsong To: java@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00001.txt.bz2 Hi, I am writing a plugin to add a pass in gcc 4.6.1. the pass will do some optimizations before high gimple lowering, moving some gimple nodes from one place to another. In cc1, the gimple code is quite understandable.=A0 But I'm confused by the gimple that Java front end conve= rts to. I dump the file, here is a piece of code doing "new". #ref#2#4 =3D _Jv_AllocObjectNoFinalizer (&Number.class$$); #ref#3#6 =3D #ref#2#4; #ref#2#4 =3D #ref#3#6; D.459 =3D #slot#1#1; #slot#4#7 =3D D.459; #ref#3#6.1 =3D #ref#3#6; (#ref#3#6.1, #slot#4#7); the corresponding Java source code is =A0=A0=A0=A0=A0=A0=A0 int sum =3D 4; =A0=A0=A0=A0=A0=A0=A0 Number number; =A0=A0=A0=A0=A0=A0=A0 if ( sum < 100 ) =A0 =A0 =A0 =A0=A0=A0=A0=A0 number =3D new Number(sum);=A0=A0 <=3Dhere the Number class is a simple one: class Number { =A0=A0=A0 int i; =A0=A0=A0 Number(int inputi){ =A0=A0=A0=A0=A0=A0=A0 i =3D inputi; =A0=A0=A0 } } Here comes my question: =A01. I am wondering why we don't use 'NEW_EXPR' to represent a "new" state= ment? =A0=A0=A0=A0 The 'NEW_EXPR' has already been defined in the cp-tree.def.( A= s I know, the =A0=A0=A0=A0 "new" statement in cp front end is also represented as that in Java front end, =A0 =A0=A0 which is "gimple_call" in gimple code, "ADDR_EXPR" in tree code, is it? why?) =A02. How can I figure out which pieces of code are corresponding =A0=A0=A0=A0 to 'NEW' statement? ( Can I always first find the "_Jv_AllocObjectNoFinalize" or "_Jv_AllocObject" =A0=A0=A0=A0 gimple_call and then "" gimple_call to locate the code?) =A03. I find that there is no document to describe the implementation of Java front end. =A0=A0=A0=A0 I don't understand why we need so many temporary variables: =A0=A0=A0=A0 #ref#2#4 =3D _Jv_AllocObjectNoFinalizer (&Number.class$$); =A0=A0=A0=A0 #ref#3#6 =3D #ref#2#4; =A0=A0=A0=A0 #ref#2#4 =3D #ref#3#6; =A0=A0=A0=A0 Here, the #ref#3#6 and #ref#2#4 is a kind waste. But each "new= " statement =A0=A0=A0=A0 does the same thing. Please tell me where can I find some resources to solve these question. I have read some paper about generic and gimple, researched the whole gcj mail list, read the gcc internals. These questions must have been too detailed. I did not find anything useful. Is it about alias? I appreciate any explanations and advices. Thanks.