RFR: 8242440: use separate, destroyable JavaVM instances per libgraal compiler thread
Doug Simon
dnsimon at openjdk.java.net
Tue Apr 19 09:10:37 UTC 2022
On Mon, 18 Apr 2022 20:55:40 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> It is declared volatile for correct double checked locking in the code prior to this PR:
>>
>> JNIEnv* JVMCIRuntime::init_shared_library_javavm() {
>> JavaVM* javaVM = (JavaVM*) _shared_library_javavm;
>> if (javaVM == NULL) {
>> MutexLocker locker(JVMCI_lock);
>> // Check again under JVMCI_lock
>> javaVM = (JavaVM*) _shared_library_javavm;
>> if (javaVM != NULL) {
>> return NULL;
>> }
>>
>> However, now that `JVMCIRuntime::_lock` is acquired at the entry to `JVMCIRuntime::init_shared_library_javavm` there is indeed no longer a need for it to be volatile.
>
> The declaration was wrong for that usage - it should have been "volatile pointer to X" (`JavaVM* volatile`) but was declared "pointer to volatile X" (`volatile JavaVM*`). That also wasn't a correct implementation of DCLP. Good thing you are changing this. So yes, the volatile should be nuked and this cast and the similar one in destroy_shared_library_javavm can be removed.
Thanks for the correction. I have removed `volatile` altogether now. It's also a good reminder of the subtleties in C++ that do not exist in Java.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8262
More information about the hotspot-dev
mailing list