Non-synchronized StringBuffer
Tom Tromey
tromey@redhat.com
Fri Nov 9 08:46:00 GMT 2001
>>>>> "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
More information about the Java
mailing list