[JAVA PATCH] SAVE_EXPR evaluate-once semantics in jcf-write.c

Per Bothner per@bothner.com
Mon Sep 29 01:57:00 GMT 2003


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/




More information about the Java-patches mailing list