This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Why does a 'new' statement produce so many temporary variables
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Li junsong <ljs dot darkfish at gmail dot com>
- Cc: java at gcc dot gnu dot org
- Date: Tue, 9 Aug 2011 09:22:09 -0700
- Subject: Re: Why does a 'new' statement produce so many temporary variables
- References: <CA+kGxtPef8Xojf-+amOehmUsY_5MQreWUPdnODZUoX-tqX1RTg@mail.gmail.com> <CA+kGxtNcCNWxYUs_Bz9a+9ULfy4MHP=JghUVz0_HL7ztL+Pjmw@mail.gmail.com>
On Tue, Aug 9, 2011 at 12:18 AM, Li junsong <ljs.darkfish@gmail.com> wrote:
> Â3. I find that there is no document to describe the implementation of
> Java front end.
> ÂÂÂÂ I don't understand why we need so many temporary variables:
>
> ÂÂÂÂ #ref#2#4 = _Jv_AllocObjectNoFinalizer (&Number.class$$);
> ÂÂÂÂ #ref#3#6 = #ref#2#4;
> ÂÂÂÂ #ref#2#4 = #ref#3#6;
>
> ÂÂÂÂ Here, the #ref#3#6 and #ref#2#4 is a kind waste. But each "new" statement
> ÂÂÂÂ does the same thing.
The reason is because this is an exact translation of the java
byte-code. Most source to java byte-code compilers don't do any
optimizations which is why we get a lot of temporary variables here
(this includes the one included with Eclipse which is what GCJ uses as
the source compiler).
Thanks,
Andrew Pinski