Skip to content

Commit dc2ac46

Browse files
committed
tighten up code related to TrackedUnsafeAccess
1 parent bc31dd9 commit dc2ac46

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/StructuredGraph.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,14 @@ public boolean hasUnsafeAccess() {
11201120
}
11211121

11221122
/**
1123-
* HotSpot requires compilations with unsafe accesses to set a flag and uses that information to
1124-
* modify the behavior of its signal handling. In Graal we label nodes which require this flag
1125-
* with the marker interface {@link TrackedUnsafeAccess}.
1123+
* Records that this graph encodes a memory access via the {@code Unsafe} class.
11261124
*
1127-
* @param nodeClass The class from which a node is created that requires unsafe access to be
1128-
* set.
1125+
* HotSpot requires this information to modify the behavior of its signal handling for compiled
1126+
* code that contains an unsafe memory access.
1127+
*
1128+
* @param nodeClass the type of the node encoding the unsafe access
11291129
*/
1130-
public void markUnsafeAccess(Class<?> nodeClass) {
1131-
assert TrackedUnsafeAccess.class.isAssignableFrom(nodeClass) : Assertions.errorMessage("%s does not implement MarkedUnsafeAccess", nodeClass);
1130+
public void markUnsafeAccess(Class<? extends TrackedUnsafeAccess> nodeClass) {
11321131
markUnsafeAccess();
11331132
}
11341133

@@ -1195,6 +1194,7 @@ protected void afterRegister(Node node) {
11951194
if (inliningLog != null && node instanceof Invokable) {
11961195
((Invokable) node).updateInliningLogAfterRegister(this);
11971196
}
1197+
assert !(node instanceof TrackedUnsafeAccess) || hasUnsafeAccess() : "must call markUnsafeAccess before adding " + node;
11981198
}
11991199

12001200
public OptimizationLog getOptimizationLog() {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/spi/TrackedUnsafeAccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import jdk.graal.compiler.nodes.StructuredGraph;
2828

2929
/**
30-
* Marker interface to denote a node requires {@link StructuredGraph#markUnsafeAccess(Class)} to be
31-
* set.
30+
* Marker interface for a node that requires {@link StructuredGraph#markUnsafeAccess(Class)} to be
31+
* called prior to being added to a graph.
3232
*/
3333
public interface TrackedUnsafeAccess {
3434
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.Objects;
5050
import java.util.function.BiFunction;
5151

52+
import jdk.graal.compiler.nodes.spi.TrackedUnsafeAccess;
5253
import org.graalvm.word.LocationIdentity;
5354

5455
import jdk.graal.compiler.api.directives.GraalDirectives;
@@ -1445,7 +1446,7 @@ private void setAccessNodeResult(FixedWithNextNode node, GraphBuilderContext b)
14451446
}
14461447
}
14471448

1448-
protected final void createUnsafeAccess(ValueNode value, GraphBuilderContext b, UnsafeNodeConstructor nodeConstructor, Class<?> constructorClass) {
1449+
protected final void createUnsafeAccess(ValueNode value, GraphBuilderContext b, UnsafeNodeConstructor nodeConstructor, Class<? extends TrackedUnsafeAccess> constructorClass) {
14491450
StructuredGraph graph = b.getGraph();
14501451
graph.markUnsafeAccess(constructorClass);
14511452
/* For unsafe access object pointers can only be stored in the heap */

0 commit comments

Comments
 (0)