"Jeff" == Jeff Sturm <jsturm@one-point.com> writes:
Jeff> If all static members can be addressed at constant offsets from
Jeff> the class pointer, that takes care of the class initialization
Jeff> test we do now.
Could you explain this to me? It seems to me that we'll still need a
test, because the class will be dynamically created. So at an active
use site we'll have to see if it has been created, presumably by
making a synchronized method call. Hopefully I'm missing something.
There will have to be checks at active use sites but no syncronization
is required, unless of course if the class actually needs to be initialized.Hmm, right now we seem to do "double checked locking" when checking
the class initialization status. At least that's what it looks like:
cmpb $12, _ZN4java4lang6System6class$E+74
setge %al
movb %al, -1(%ebp)
cmpb $0, -1(%ebp)
jne .L3
movl $_ZN4java4lang6System6class$E, (%esp)
call _Jv_InitClass
Isn't that a no-no?
I believe "double check locking" is/was considsered unsafe in Java
because the Java spec didn't specify well enough how "synchronized"
works with respect to coherent memory. There was a proposed memory model
extension to make the Java spec specify how synchronized and volatile
work in more detail.