Skip to content

[0.54] Detect any monitorenter before point of dynamic loop transfers - #22317

Merged
vijaysun-omr merged 1 commit into
eclipse-openj9:v0.54.0-releasefrom
hzongaro:guard-against-live-monitors-for-dlt-0.54
Jul 28, 2025
Merged

[0.54] Detect any monitorenter before point of dynamic loop transfers#22317
vijaysun-omr merged 1 commit into
eclipse-openj9:v0.54.0-releasefrom
hzongaro:guard-against-live-monitors-for-dlt-0.54

Conversation

@hzongaro

Copy link
Copy Markdown
Member

Dynamic loop transfer can transfer control from the interpreter into a JIT-compiled method after the point at which monitorenter bytecode instructions have been executed. With Java 24 and later, the JVM uses the JIT's live monitor metadata to locate monitors that might need to be detached from carrier threads when the owning virtual thread is unmounted.

If the JIT is unable to determine that no monitorenters will be executed prior to the entry point for dynamic loop transfer, it must fail the compilation.

Fixes: #22266

Port of pull request #22291 to v0.54.0-release branch

Dynamic loop transfer can transfer control from the interpreter into a
JIT-compiled method after the point at which monitorenter bytecode
instructions have been executed.  With Java 24 and later, the JVM uses
the JIT's live monitor metadata to locate monitors that might need to be
detached from carrier threads when the owning virtual thread is
unmounted.  This is enabled if the
J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION flag is set in
extendedRuntimeFlags3, which can be turned off by specifying the option
-XX:-YieldPinnedVirtualThreads.

If the JIT is unable to determine that no monitorenters will be executed
prior to the entry point for dynamic loop transfer, it must fail the
compilation.  This change follows predecessor paths in the CFG from the
blocks identified as potential DLT entry points to see whether a
monitorenter could have been encountered before the DLT occurred.  If
that might be possible, the compilation fails.

Also, if the JVM requires correct live monitor maps, force the
disableLiveMonitorMetadata JIT option off.

Finally, the disableInlineMonEnt and disableInlineMonExit options can be
set in a fashion that's specific to a particular method compilation.
Whether they should be forced off needs to be considered earlier in
J9::Options::feLatePostProcess.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
@hzongaro
hzongaro requested a review from dsouzai as a code owner July 28, 2025 13:36
@hzongaro
hzongaro requested review from 0xdaryl and vijaysun-omr and removed request for 0xdaryl July 28, 2025 13:36
@hzongaro

Copy link
Copy Markdown
Member Author

@vijaysun-omr, may I ask you to merge this change to the 0.54.0-release branch?

@hzongaro hzongaro added the jdk24 label Jul 28, 2025
@vijaysun-omr
vijaysun-omr merged commit dc62d23 into eclipse-openj9:v0.54.0-release Jul 28, 2025
2 checks passed
@hzongaro
hzongaro deleted the guard-against-live-monitors-for-dlt-0.54 branch September 8, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants