Skip to content

Commit 0dac456

Browse files
committed
Prevent canonicalization of guarded unsafe loads to unguarded raw loads.
1 parent b69d618 commit 0dac456

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/GuardedUnsafeLoadNode.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
2626

2727
import static org.graalvm.compiler.nodeinfo.InputType.Guard;
2828

29+
import org.graalvm.compiler.core.common.memory.MemoryOrderMode;
2930
import org.graalvm.compiler.graph.NodeClass;
3031
import org.graalvm.compiler.nodeinfo.NodeInfo;
3132
import org.graalvm.compiler.nodes.ValueNode;
@@ -44,6 +45,11 @@ public GuardedUnsafeLoadNode(ValueNode object, ValueNode offset, JavaKind access
4445
this.guard = (GuardingNode) guard;
4546
}
4647

48+
public GuardedUnsafeLoadNode(ValueNode object, ValueNode offset, JavaKind accessKind, LocationIdentity locationIdentity, ValueNode guard, boolean forceLocation, MemoryOrderMode memoryOrder) {
49+
super(TYPE, object, offset, accessKind, locationIdentity, forceLocation, memoryOrder);
50+
this.guard = (GuardingNode) guard;
51+
}
52+
4753
public GuardedUnsafeLoadNode(ValueNode object, ValueNode offset, JavaKind accessKind, LocationIdentity locationIdentity, ValueNode guard) {
4854
this(object, offset, accessKind, locationIdentity, guard, false);
4955
}
@@ -59,6 +65,14 @@ public void setGuard(GuardingNode guard) {
5965
this.guard = guard;
6066
}
6167

68+
@Override
69+
protected ValueNode cloneAsArrayAccess(ValueNode location, LocationIdentity identity, MemoryOrderMode memOrder) {
70+
// Only improve the location identity; do not attempt to canonicalize to a RawLoadNode
71+
// since doing so would lose the guard and prevent floating the read after lowering.
72+
assert !getLocationIdentity().equals(identity);
73+
return new GuardedUnsafeLoadNode(object(), offset(), accessKind(), identity, (ValueNode) getGuard(), isLocationForced(), memOrder);
74+
}
75+
6276
@NodeIntrinsic
6377
public static native Object guardedLoad(Object object, long offset, @ConstantNodeParameter JavaKind kind, @ConstantNodeParameter LocationIdentity locationIdentity, GuardingNode guard);
6478
}

0 commit comments

Comments
 (0)