Re: JavaMemoryModel: Thread starting in constructors

From: Cliff Click (
Date: Tue Mar 12 2002 - 13:01:57 EST

Jerry Schwarz wrote:

> On reflection I realize that the proposed optimization might interact
> poorly with reflection in the language (pun intended:-) because it is
> changing the fields of the class. So maybe it isn't allowed for that
> reason.

We can't delete the old S field, but we can insert a hidden S.x cache.
If u.f() is very common we can avoid an extra indirect load that way.

I mentioned inlining, because I was thinking ahead about this.
In addition to x-forming U into U'' with a hidden S.x cache, we
would only use the cache in compiled (not interpreted) code.
U.f() is so small (and must be hot or why bother to do the optimization)
so it gets inlined; i.e. we never compile U.f() directly. Thus this
optimization only usefully applies when inlined into some caller and
is thus easy to disallow inside naughty constructors. I didn't mention
all this before because I didn't want to bore you with the details.
It's my job to make 'The Spec' run fast or scream if it can't be done.


Dr. Cliff Click      Chief Architect, HotSpot Server  Sun Microsystems, Inc.
Cliff.Click@Sun.COM  Senior Staff Engineer            4150 Network Circle
(408) 276-7046       MS USCA14-102                    Santa Clara, CA 95054

------------------------------- JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:38 EDT