|
114 | 114 | import jdk.graal.compiler.core.common.type.ObjectStamp; |
115 | 115 | import jdk.graal.compiler.core.common.type.StampFactory; |
116 | 116 | import jdk.graal.compiler.core.common.type.StampPair; |
| 117 | +import jdk.graal.compiler.debug.Assertions; |
117 | 118 | import jdk.graal.compiler.debug.GraalError; |
118 | 119 | import jdk.graal.compiler.graph.Node.ConstantNodeParameter; |
119 | 120 | import jdk.graal.compiler.graph.Node.NodeIntrinsic; |
|
144 | 145 | import jdk.graal.compiler.nodes.java.MethodCallTargetNode; |
145 | 146 | import jdk.graal.compiler.nodes.java.MonitorEnterNode; |
146 | 147 | import jdk.graal.compiler.nodes.java.MonitorExitNode; |
| 148 | +import jdk.graal.compiler.nodes.java.MonitorIdNode; |
147 | 149 | import jdk.graal.compiler.nodes.spi.LoweringTool; |
148 | 150 | import jdk.graal.compiler.nodes.type.StampTool; |
| 151 | +import jdk.graal.compiler.nodes.virtual.EscapeObjectState; |
| 152 | +import jdk.graal.compiler.nodes.virtual.VirtualObjectNode; |
| 153 | +import jdk.graal.compiler.nodes.virtual.VirtualObjectState; |
149 | 154 | import jdk.graal.compiler.options.OptionValues; |
150 | 155 | import jdk.graal.compiler.phases.common.inlining.InliningUtil; |
151 | 156 | import jdk.graal.compiler.replacements.SnippetCounter; |
@@ -919,13 +924,36 @@ public void lower(CheckFastPathMonitorEnterNode checkFastPathMonitorEnterNode, H |
919 | 924 | template(tool, checkFastPathMonitorEnterNode, args).instantiate(tool.getMetaAccess(), checkFastPathMonitorEnterNode, DEFAULT_REPLACER, args); |
920 | 925 | } |
921 | 926 |
|
| 927 | + private static boolean isVirtualLock(FrameState frameState, int lockIdx) { |
| 928 | + MonitorIdNode monitorIdNode = frameState.monitorIdAt(lockIdx); |
| 929 | + if (monitorIdNode.isEliminated()) { |
| 930 | + return true; |
| 931 | + } |
| 932 | + |
| 933 | + ValueNode lock = frameState.lockAt(lockIdx); |
| 934 | + if (lock instanceof VirtualObjectNode virtualObject) { |
| 935 | + FrameState current = frameState; |
| 936 | + do { |
| 937 | + if (current.virtualObjectMappingCount() > 0) { |
| 938 | + for (EscapeObjectState state : current.virtualObjectMappings()) { |
| 939 | + if (state instanceof VirtualObjectState && virtualObject == state.object()) { |
| 940 | + return true; |
| 941 | + } |
| 942 | + } |
| 943 | + } |
| 944 | + current = current.outerFrameState(); |
| 945 | + } while (current != null); |
| 946 | + } |
| 947 | + return false; |
| 948 | + } |
| 949 | + |
922 | 950 | private boolean verifyLockOrder(MonitorEnterNode monitorenterNode) { |
923 | | - if (requiresStrictLockOrder) { |
| 951 | + if (Assertions.assertionsEnabled() && requiresStrictLockOrder) { |
924 | 952 | FrameState state = monitorenterNode.stateAfter(); |
925 | 953 | boolean subsequentLocksMustBeEliminated = false; |
926 | 954 | for (int lockIdx = 0; lockIdx < state.locksSize(); lockIdx++) { |
927 | 955 | if (subsequentLocksMustBeEliminated) { |
928 | | - if (!state.monitorIdAt(lockIdx).isEliminated()) { |
| 956 | + if (!isVirtualLock(state, lockIdx)) { |
929 | 957 | return false; |
930 | 958 | } |
931 | 959 | } |
|
0 commit comments