This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Non-synchronized StringBuffer
- From: Tom Tromey <tromey at redhat dot com>
- To: Adam Megacz <gcj at lists dot megacz dot com>
- Cc: Java Discuss List <java at gcc dot gnu dot org>
- Date: 25 Nov 2001 13:36:21 -0700
- Subject: Re: Non-synchronized StringBuffer
- References: <87itc0dehz.fsf@creche.redhat.com> <m3wv0epptr.fsf@megacz.com>
- Reply-to: tromey at redhat dot com
>>>>> "Adam" == Adam Megacz <gcj@lists.megacz.com> writes:
Adam> I'm curious -- will gcj stack-allocate an object whose lifetime
Adam> is obviously no longer than that of the function allocating it?
Adam> (ie no references to the object are passed to other functions,
Adam> nor are any returned)?
This is called "escape analysis", at least in one paper I read. gcj
doesn't currently do it.
It isn't as easy as it sounds. For one thing, a reference is passed
to any methods invoked on it, and these methods might save `this' (for
that matter, a constructor might save `this' somewhere).
In general I think you need to do whole-program analysis to get good
escape analysis. I haven't done much reading in this area. I'd be
interested in finding out about situations where we can do escape
analysis without reading the whole program (or by perhaps annotating
class files in the library and elsewhere with analysis we do
incrementally?).
Tom