Re: Why does a 'new' statement produce so many temporary variables

Andrew Pinski <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <CA+=Sn1mm-K-CyMH_Je2DFZgALBp-GvqzaL5pthgRSg65RSEhwg@mail.gmail.com>
On Tue, Aug 9, 2011 at 12:18 AM, Li junsong <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.