This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]