Skip to content

Commit 4de543b

Browse files
committed
[GR-54787] Fix documentation of unstructured locking in BytecodeParser.
PullRequest: graal/18069
2 parents 30cf3c9 + 4ec0850 commit 4de543b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/java/BytecodeParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,8 +3037,12 @@ protected void genMonitorExit(ValueNode x, ValueNode escapedValue, int bci, bool
30373037
*/
30383038
protected int minLockDepthAtMonitorExit(boolean inEpilogue) {
30393039
/**
3040-
* Synchronized methods: Enforce that the method synchronized object is not unlocked outside
3041-
* the synchronized epilogue. Such a pattern could still be structured locking:
3040+
* Synchronized methods: Enforce that the method synchronized object is not unlocked before
3041+
* the synchronized epilogue.
3042+
*
3043+
* The
3044+
* {@code javasoft.sqe.tests.vm.instr.monitorexit.monitorexit009.monitorexit00901m1.monitorexit00901m1}
3045+
* test implies that unlocking the method synchronized object can be structured locking:
30423046
*
30433047
* <pre>
30443048
* synchronized void foo() {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,23 @@ protected void genReturn(ValueNode returnVal, JavaKind returnKind) {
653653

654654
@Override
655655
protected int minLockDepthAtMonitorExit(boolean inEpilogue) {
656+
/**
657+
* The
658+
* {@code javasoft.sqe.tests.vm.instr.monitorexit.monitorexit009.monitorexit00901m1.monitorexit00901m1}
659+
* test implies that unlocking the method synchronized object can be structured locking:
660+
*
661+
* <pre>
662+
* synchronized void foo() {
663+
* monitorexit this // valid unlock of method synchronize object
664+
* // do something
665+
* monitorenter this
666+
* return
667+
* }
668+
* </pre>
669+
*
670+
* To be JCK compliant, it is only required to always have at least one locked object
671+
* before performing a monitorexit.
672+
*/
656673
return 1;
657674
}
658675

0 commit comments

Comments
 (0)