Skip to content

Commit 4372d25

Browse files
committed
[GR-59768] Fix expected barrier for atomic updates
PullRequest: graal/20974
2 parents 73fd090 + 93cfe69 commit 4372d25

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/gc/ZBarrierSet.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,25 @@ public void verifyBarriers(StructuredGraph graph) {
184184
node instanceof LoweredAtomicReadAndWriteNode) {
185185
LIRLowerableAccess read = (LIRLowerableAccess) node;
186186
Stamp stamp = read.getAccessStamp(NodeView.DEFAULT);
187+
BarrierType barrierType = read.getBarrierType();
187188
if (!stamp.isObjectStamp()) {
188-
GraalError.guarantee(read.getBarrierType() == BarrierType.NONE, "no barriers for primitive reads: %s", read);
189+
GraalError.guarantee(barrierType == BarrierType.NONE, "no barriers for primitive reads: %s", read);
189190
continue;
190191
}
191192

192-
BarrierType expectedBarrier = barrierForLocation(read.getBarrierType(), read.getLocationIdentity(), JavaKind.Object);
193+
BarrierType expectedBarrier = barrierForLocation(barrierType, read.getLocationIdentity(), JavaKind.Object);
193194
if (expectedBarrier != null) {
194-
GraalError.guarantee(expectedBarrier == read.getBarrierType(), "expected %s but found %s in %s", expectedBarrier, read.getBarrierType(), read);
195+
GraalError.guarantee(expectedBarrier == barrierType, "expected %s but found %s in %s", expectedBarrier, barrierType, read);
195196
continue;
196197
}
197198

198199
ValueNode base = read.getAddress().getBase();
199200
if (!base.stamp(NodeView.DEFAULT).isObjectStamp()) {
200-
GraalError.guarantee(read.getBarrierType() == BarrierType.NONE, "no barrier for non-heap read: %s", read);
201+
GraalError.guarantee(barrierType == BarrierType.NONE, "no barrier for non-heap read: %s", read);
202+
} else if (node instanceof AbstractCompareAndSwapNode || node instanceof LoweredAtomicReadAndWriteNode) {
203+
GraalError.guarantee(barrierType == BarrierType.FIELD || barrierType == BarrierType.ARRAY, "missing barriers for heap read: %s", read);
201204
} else {
202-
GraalError.guarantee(read.getBarrierType() == BarrierType.READ, "missing barriers for heap read: %s", read);
205+
GraalError.guarantee(barrierType == BarrierType.READ, "missing barriers for heap read: %s", read);
203206
}
204207
} else if (node instanceof AddressableMemoryAccess) {
205208
AddressableMemoryAccess access = (AddressableMemoryAccess) node;

0 commit comments

Comments
 (0)