-
Enhancement
-
Resolution: Fixed
-
P5
-
22
-
b21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8319214 | 21.0.2 | Aleksey Shipilev | P5 | Resolved | Fixed | b05 |
JVMS has a very specific meaning to structured locking:
https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-2.html#jvms-2.11.10
It reads as, "anywhere in the method, do not unlock the monitors the method have not locked, and do not leave locked monitors that method does not unlock". (Arguably, a better name that is sometimes mentioned in OpenJDK is "block-structured locking": https://github.com/openjdk/jdk/blob/9cf334fb6488188ea4236e5d156b11245bace88f/src/hotspot/cpu/x86/interp_masm_x86.cpp#L1070-L1072)
It does not actually say anything about the case where two monitors are locked and unlocked in non-stack fashion within the method, which is what test simulates. Compiler code calls this situation "(un) balanced monitors":
https://github.com/openjdk/jdk/blob/9cf334fb6488188ea4236e5d156b11245bace88f/src/hotspot/share/ci/ciMethod.cpp#L284-L288
I would not bother about this normally, but I have just spent half an hour discussing this test, structured locking, and balanced monitors with someone who was confused about the whole thing. The test name was the starting point of that confusion. I think it would be clean to name the test appropriately to avoid further confusion.
https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-2.html#jvms-2.11.10
It reads as, "anywhere in the method, do not unlock the monitors the method have not locked, and do not leave locked monitors that method does not unlock". (Arguably, a better name that is sometimes mentioned in OpenJDK is "block-structured locking": https://github.com/openjdk/jdk/blob/9cf334fb6488188ea4236e5d156b11245bace88f/src/hotspot/cpu/x86/interp_masm_x86.cpp#L1070-L1072)
It does not actually say anything about the case where two monitors are locked and unlocked in non-stack fashion within the method, which is what test simulates. Compiler code calls this situation "(un) balanced monitors":
https://github.com/openjdk/jdk/blob/9cf334fb6488188ea4236e5d156b11245bace88f/src/hotspot/share/ci/ciMethod.cpp#L284-L288
I would not bother about this normally, but I have just spent half an hour discussing this test, structured locking, and balanced monitors with someone who was confused about the whole thing. The test name was the starting point of that confusion. I think it would be clean to name the test appropriately to avoid further confusion.
- backported by
-
JDK-8319214 Rename TestUnstructuredLocking test
- Resolved
- relates to
-
JDK-8316958 Add test for unstructured locking
- Resolved
- links to
-
Commit openjdk/jdk21u/9405b0c4
-
Commit openjdk/jdk/3f446c51
-
Review openjdk/jdk21u/288
-
Review openjdk/jdk/16273
(1 links to)