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: Non-synchronized StringBuffer


>>>>> "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


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