Skip to content

Commit 4d2e935

Browse files
committed
address reviewer feedback
1 parent 1edb29d commit 4d2e935

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/runtimecompilation/RuntimeCompilationFeature.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,14 @@ private void recordFailed(AnalysisMethod method) {
697697
public boolean validateGraph(PointsToAnalysis bb, StructuredGraph graph) {
698698
PointsToAnalysisMethod aMethod = (PointsToAnalysisMethod) graph.method();
699699
MultiMethod.MultiMethodKey multiMethodKey = aMethod.getMultiMethodKey();
700-
Supplier<Boolean> graphInvalidator = DeoptimizationUtils.createGraphInvalidator(graph, multiMethodKey == RUNTIME_COMPILED_METHOD);
700+
Supplier<Boolean> graphChecker = DeoptimizationUtils.createGraphChecker(graph,
701+
multiMethodKey == RUNTIME_COMPILED_METHOD ? DeoptimizationUtils.RUNTIME_COMPILATION_INVALID_NODES : DeoptimizationUtils.AOT_COMPILATION_INVALID_NODES);
701702
if (multiMethodKey != ORIGINAL_METHOD) {
702-
if (graphInvalidator.get()) {
703+
if (!graphChecker.get()) {
703704
recordFailed(aMethod);
704705
return false;
705706
}
706-
} else if (DeoptimizationUtils.canDeoptForTesting(aMethod, false, graphInvalidator)) {
707+
} else if (DeoptimizationUtils.canDeoptForTesting(aMethod, false, graphChecker)) {
707708
DeoptimizationUtils.registerDeoptEntriesForDeoptTesting(bb, graph, aMethod);
708709
return true;
709710
}
@@ -882,7 +883,7 @@ protected AbstractPolicyScope openCalleeScope(AbstractPolicyScope outer, Analysi
882883
* Once the accumulative policy is activated, we cannot return to the trivial
883884
* policy.
884885
*/
885-
return inliningUtils.createAccumulativeInlineScope(accOuter, method, DeoptimizationUtils.runtimeCompilationInvalidNodes);
886+
return inliningUtils.createAccumulativeInlineScope(accOuter, method, DeoptimizationUtils.RUNTIME_COMPILATION_INVALID_NODES);
886887
}
887888

888889
assert outer == null || outer instanceof RuntimeCompilationAlwaysInlineScope : "unexpected outer scope: " + outer;
@@ -902,7 +903,7 @@ protected AbstractPolicyScope openCalleeScope(AbstractPolicyScope outer, Analysi
902903
return new RuntimeCompilationAlwaysInlineScope(inliningDepth);
903904
} else {
904905
// start with a new accumulative inline scope
905-
return inliningUtils.createAccumulativeInlineScope(null, method, DeoptimizationUtils.runtimeCompilationInvalidNodes);
906+
return inliningUtils.createAccumulativeInlineScope(null, method, DeoptimizationUtils.RUNTIME_COMPILATION_INVALID_NODES);
906907
}
907908
}
908909
}
@@ -1147,7 +1148,7 @@ public boolean processNode(AnalysisMetaAccess metaAccess, AnalysisMethod method,
11471148
/*
11481149
* Inline as long as an invalid node has not been seen.
11491150
*/
1150-
return !DeoptimizationUtils.runtimeCompilationInvalidNodes.test(node);
1151+
return !DeoptimizationUtils.RUNTIME_COMPILATION_INVALID_NODES.test(node);
11511152
}
11521153

11531154
@Override
@@ -1158,6 +1159,6 @@ public boolean processNonInlinedInvoke(CoreProviders providers, CallTargetNode n
11581159

11591160
@Override
11601161
public String toString() {
1161-
return "AlwaysInlineScope";
1162+
return "RuntimeCompilationAlwaysInlineScope";
11621163
}
11631164
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/DeoptimizationUtils.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void insertDeoptTests(HostedMethod method, StructuredGraph graph) {
127127
*
128128
* Note this should only be called within CompileQueue#parseAheadOfTimeCompiledMethods
129129
*/
130-
public static boolean canDeoptForTesting(AnalysisMethod method, boolean deoptimizeAll, Supplier<Boolean> graphInvalidator) {
130+
public static boolean canDeoptForTesting(AnalysisMethod method, boolean deoptimizeAll, Supplier<Boolean> graphChecker) {
131131
if (SubstrateCompilationDirectives.singleton().isRegisteredForDeoptTesting(method)) {
132132
return true;
133133
}
@@ -146,7 +146,7 @@ public static boolean canDeoptForTesting(AnalysisMethod method, boolean deoptimi
146146
return false;
147147
}
148148

149-
if (graphInvalidator.get()) {
149+
if (!graphChecker.get()) {
150150
return false;
151151
}
152152

@@ -291,7 +291,7 @@ static boolean verifyDeoptTarget(HostedMethod method, StructuredGraph graph, Com
291291
/*
292292
* No deopt targets can have a StackValueNode in the graph.
293293
*/
294-
assert !createGraphInvalidator(graph, false).get() : "Invalid nodes in deopt target: " + graph;
294+
assert createGraphChecker(graph, AOT_COMPILATION_INVALID_NODES).get() : "Invalid nodes in deopt target: " + graph;
295295

296296
for (Infopoint infopoint : result.getInfopoints()) {
297297
if (infopoint.debugInfo != null) {
@@ -500,29 +500,28 @@ public static Collection<ResolvedJavaMethod> registerDeoptEntries(StructuredGrap
500500
* We also do not allow class initialization at run time to ensure the partial evaluator does
501501
* not constant fold uninitialized fields.
502502
*/
503-
public static final NodePredicate runtimeCompilationInvalidNodes = n -> NodePredicates.isA(StackValueNode.class).or(NodePredicates.isA(EnsureClassInitializedNode.class)).test(n);
503+
public static final NodePredicate RUNTIME_COMPILATION_INVALID_NODES = n -> NodePredicates.isA(StackValueNode.class).or(NodePredicates.isA(EnsureClassInitializedNode.class)).test(n);
504504

505-
private static final NodePredicate stackOnly = n -> NodePredicates.isA(StackValueNode.class).test(n);
505+
public static final NodePredicate AOT_COMPILATION_INVALID_NODES = n -> NodePredicates.isA(StackValueNode.class).test(n);
506506

507507
/**
508-
* @return Supplier which returns true if the graph contains invalid nodes.
508+
* @return Supplier which returns true if the graph does not violate the checks.
509509
*/
510-
public static Supplier<Boolean> createGraphInvalidator(StructuredGraph graph, boolean isRuntimeCompiledMethod) {
510+
public static Supplier<Boolean> createGraphChecker(StructuredGraph graph, NodePredicate invalidNodes) {
511511
return () -> {
512512
if (!graph.method().getDeclaringClass().isInitialized()) {
513513
/*
514514
* All types which are used at run time should build-time initialized. This ensures
515515
* the partial evaluator does not constant fold uninitialized fields.
516516
*/
517-
return true;
517+
return false;
518518
}
519519

520-
NodePredicate predicate = isRuntimeCompiledMethod ? runtimeCompilationInvalidNodes : stackOnly;
521-
if (graph.getNodes().filter(predicate).isNotEmpty()) {
522-
return true;
520+
if (graph.getNodes().filter(invalidNodes).isNotEmpty()) {
521+
return false;
523522
}
524523

525-
return false;
524+
return true;
526525
};
527526
}
528527
}

0 commit comments

Comments
 (0)