[jdk11u-dev] RFR: 8213137: Remove static initialization of monitor/mutex instances
Volker Simonis
simonis at openjdk.java.net
Thu Jun 17 09:53:20 UTC 2021
On Wed, 9 Jun 2021 19:48:52 GMT, Evgeny Astigeevich <github.com+42899633+eastig at openjdk.org> wrote:
> We are backporting JDK-8210832: Remove sneaky locking in class Monitor. It has a few dependencies. JDK-8213137: Remove static initialization of monitor/mutex instances is one of them.
>
> The original patch from JDK-8213137 causes conflicts. The conflicts are because a patched file does not exist in jdk11u and git struggled to position changes. The original changes are not changed after resolution of the conflicts.
>
> Testing: Amazon Linux 2, aarch64, tier1 and tier2. Amazon Linux 2, x86_64, tier1 and tier2.
Just to be clear - I haven't proposed to *remove* `CodeCacheUnloadingTask::_lock` (and by the way `G1CodeCacheUnloadingTask::_lock` - good catch!). I just proposed to remove their static initializer and let them instead be initilized by moving them to the global set of mutexes/monitors managed by MutexLocker (as this change does with the other Mutexes/Monitors).
[JDK-8213137](https://bugs.openjdk.java.net/browse/JDK-8213137) states the following:
> Proposed changes to mutex/monitor code (i.e. [JDK-8210832](https://bugs.openjdk.java.net/browse/JDK-8210832)) requires non-trivial initialization at the OS level, which means we need to remove the static initialization of these mutex/monitor instances.
I've browsed the code and I've currently only found such dependencies for Solaris where after [JDK-8210832](https://bugs.openjdk.java.net/browse/JDK-8210832) a Monitor can't be initialized statically any more because `os::PlatformMonitor::PlatformMonitor()` depends on initializations done in `os::Solaris::synchronization_init()` which is called from `os::init_2()`. There might be other dependencies on other platforms which I haven't seen.
Anyway, [JDK-8213723](https://bugs.openjdk.java.net/browse/JDK-8213723), which is another dependency for [JDK-8210832](https://bugs.openjdk.java.net/browse/JDK-8210832), adds assertions to protect against Monitors being initialized before `os::init_2()`. So we'll have to convert the initialization of `CodeCacheUnloadingTask::_lock`/`G1CodeCacheUnloadingTask::_lock` anyway, at the latest when downporting [JDK-8213723](https://bugs.openjdk.java.net/browse/JDK-8213723).
I'm fine to leave these changes for the [JDK-8213723](https://bugs.openjdk.java.net/browse/JDK-8213723) downport, if others agree.
-------------
PR: https://git.openjdk.java.net/jdk11u-dev/pull/21
More information about the jdk-updates-dev
mailing list