Lazy statics (was: Feedback / query on jextract for Windows 10)
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Feb 3 23:16:08 UTC 2021
----- Mail original -----
> De: "John Rose" <john.r.rose at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Brian Goetz" <brian.goetz at oracle.com>, "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>, "duncan gittins"
> <duncan.gittins at gmail.com>, "panama-dev at openjdk.java.net'" <panama-dev at openjdk.java.net>, "Claes Redestad"
> <claes.redestad at oracle.com>
> Envoyé: Mercredi 3 Février 2021 23:19:27
> Objet: Re: Lazy statics (was: Feedback / query on jextract for Windows 10)
> On Feb 3, 2021, at 1:58 PM, forax at univ-mlv.fr wrote:
>>
>> For the runtime exceptions, they should be wrapped into an
>> ExceptionInInitializerError (which is a LinkageError), so we have the same
>> behavior if the constant is initialized in the static bloc or using the lazy
>> constant mechanism.
>
> (Agreed; that’s what I meant by LinkageError in my previous.)
>
>> The initialization semantics is both harder and simpler, we currently have the
>> VM semantics inherited from ldc + condy, the initializer (the bootstrap method)
>> can be called by multiple threads, the first thread to write into the constant
>> pool win and all others threads return the winning value.
>> We can not do better without tweaking the VM, so either we decide another
>> semantics and it means adding a new mechanism into the VM or we are
>> piggybacking on what already exists in the VM and just copy the VM semantics
>> into the JLS.
>
> If the user model demands something different, it can be composed
> from the VM-provided primitives (condy first-write-wins plus
> synchronized blocks plus ju.concurrent) in a translation strategy.
I don't think it can work, but correct me if i'm wrong.
If the BSM is something like
Object bsm(Lookup lookup, String name, Class<?> type) {
synchronized(lock) {
...
return result;
}
}
You still can have a thread t1 that is de-scheduled in between the MONITOR_EXIT and the CAS to the constant pool so another thread t2 can enter the bsm and return the result so using a synchronized block/ ReentrantLock doesn't help.
Rémi
More information about the panama-dev
mailing list