This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [JAVA PATCH] SAVE_EXPR evaluate-once semantics in jcf-write.c
- From: Per Bothner <per at bothner dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 28 Sep 2003 17:42:06 -0700
- Subject: Re: [JAVA PATCH] SAVE_EXPR evaluate-once semantics in jcf-write.c
- References: <Pine.LNX.4.44.0309281708520.18467-100000@www.eyesopen.com>
Roger Sayle wrote:
The following patch implements the required evaluate-once semantics
for SAVE_EXPR when generating java bytecodes. Historically, gcj has
just re-evaluated the saved expression which is less than ideal.
My main concern is that localvar_alloc allocates a new local
variable. When does it get freed? There are two concerns:
(1) It might get freed too early.
(2) It might never get freed (until the end of the method),
in which case we may be wasting locals. This is admittedly
not a major problem, though it is a bit wasteful.
So this ia a work-around, but the real fix is to stop
generating SAVE_EXPRs while constant-folding. What we
should do is use a "let expression":
LET tmp := expression IN f(use tmp, use tmp)
This provides an explicit well-defined scope for the temporary.
--
--Per Bothner
per@bothner.com http://per.bothner.com/