[master] RFR: OMWorld: ObjectMonitor:enter
Axel Boldt-Christmas
aboldtch at openjdk.org
Mon Apr 22 12:48:46 UTC 2024
This restructures `ObjectMonitor:enter` to fit better with the `LightweightSynchronizer`. Some parts of this could be upstreamed separately.
This effectively splits up `ObjectMonitor::enter` into three parts. Which LightweightSynchronizer can weave into its `inflate_and_enter`.
```c++
bool ObjectMonitor::enter(JavaThread* current) {
// 1. Spinning without blocking out deflation
if (spin_enter(current)) {
return true;
}
// 2. Try to block deflation
ObjectMonitorContentionMark contention_mark(this);
if (enter_is_async_deflating()) {
return false;
}
// 3. Enter while blocking out deflation
enter_with_contention_mark(current, contention_mark);
return true;
}
It may be worth the effort to document these new methods, and also add better documentation to `inflate_and_enter` which describes the invariants and how `ObjectMonitorContentionMark`, markWord transitions and ObjectMonitor::_owner field (on newly inserted monitors) plays together to guarantee correctness and works.
This commit is currently based on ffc4c2fd5ba1c28432a5d5e84b8ada95fba7eeb8 without a merge. So GHA is not tested with lilliput. As long as this is mergable without conflicts (and no manual merge is performed) it will also be possible to move this commit down below lilliput on-top of OMWorld directly.
-------------
Commit messages:
- Cleanup ObjectMonitor::enter and LightweightSynchronizer::inflate_and_enter
- Cleanup and fix enter / enter_for distinction
Changes: https://git.openjdk.org/lilliput/pull/159/files
Webrev: https://webrevs.openjdk.org/?repo=lilliput&pr=159&range=00
Stats: 246 lines in 6 files changed: 119 ins; 58 del; 69 mod
Patch: https://git.openjdk.org/lilliput/pull/159.diff
Fetch: git fetch https://git.openjdk.org/lilliput.git pull/159/head:pull/159
PR: https://git.openjdk.org/lilliput/pull/159
More information about the lilliput-dev
mailing list