binary compatibility ABI
Bryce McKinlay
bryce@mckinlay.net.nz
Thu Sep 11 02:39:00 GMT 2003
On Thursday, Sep 11, 2003, at 02:16 Pacific/Auckland, Andrew Haley
wrote:
> Jeff Sturm writes:
>>> I think that keeping the initialization check/call at the call (or
>>> field access) site gives us more opportunity to optimize it out at
>>> compile time. eg: hoisting it out of loops, eliminating it if class
>>> is
>>> already known to be initialized in the current method, keeping a
>>> local
>>> cache, etc.
>>
>> Very good point. Libgcj hides a lot of class inits now, in 'new' or
>> 'instanceof' calls for example. The more these can be exposed the
>> easier
>> they are to eliminate.
Yeah - although actually 'instanceof' (and checkcast) do not cause
initialization.
> Well, kinda sorta. The first time a class is accessed it has to be
> initialized, but as long as we have to go through an indirection to
> invoke a method we might as well rewrite that indirection once the
> class is initialized.
The problem I see with having mutable method tables is the memory
ordering problem - it seems that on an MP architecture we would have to
put a read barrier before each call or else the method table could be
seen as updated before class initialization is seen as complete.
>> (As an aside, I know there's been discussions before about static
>> vs. local boolean flags to track class initializations. What
>> about using TLS on platforms that support it (i.e. x86/linux)?
Interesting idea. I was thinking an initial implementation would just
use a small cache in the stack for whatever classes are
used/initialized by the current method. But if thread-local storage can
be used efficiently, then obviously that is even better.
>> Each thread would check a thread-local boolean variable before
>> calling _Jv_InitClass, so it would have to attempt class
>> initialization at most once per class. I can't think of a reason
>> that would violate Java's memory model.)
>
> But TLS is slow.
The current implementations may be slow, but the point of TLS is that
its supposed to be fast - ie it avoids locks and having to worry about
memory ordering, etc.
Regards
Bryce.
More information about the Java
mailing list