Skip to content

Commit 4aaf934

Browse files
committed
add predicate-specific error messages to StrengthenGraphs
1 parent f2558b5 commit 4aaf934

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ private void handleInvoke(Invoke invoke, SimplifierTool tool) {
606606
* trigger. But when only running the reachability analysis, there is no detailed
607607
* list of callees.
608608
*/
609-
unreachableInvoke(invoke, tool);
609+
unreachableInvoke(invoke, tool, () -> "method " + getQualifiedName(graph) + ", node " + invoke +
610+
": target method is not marked as simply implementation invoked");
610611
/* Invoke is unreachable, there is no point in improving any types further. */
611612
return;
612613
}
@@ -616,12 +617,19 @@ private void handleInvoke(Invoke invoke, SimplifierTool tool) {
616617
/* No points-to analysis results. */
617618
return;
618619
}
620+
if (!invokeFlow.isFlowEnabled()) {
621+
unreachableInvoke(invoke, tool, () -> "method " + getQualifiedName(graph) + ", node " + invoke +
622+
": flow is not enabled by its predicate " + invokeFlow.getPredicate());
623+
/* Invoke is unreachable, there is no point in improving any types further. */
624+
return;
625+
}
619626

620627
Collection<AnalysisMethod> callees = invokeFlow.getOriginalCallees();
621628
if (callees.isEmpty()) {
622629
if (isClosedTypeWorld) {
623630
/* Invoke is unreachable, there is no point in improving any types further. */
624-
unreachableInvoke(invoke, tool);
631+
unreachableInvoke(invoke, tool, () -> "method " + getQualifiedName(graph) + ", node " + invoke +
632+
": empty list of callees for call to " + ((AnalysisMethod) invoke.callTarget().targetMethod()).getQualifiedName());
625633
}
626634
/* In open world we cannot make any assumptions about an invoke with 0 callees. */
627635
return;
@@ -833,7 +841,7 @@ protected void invokeWithNullReceiver(Invoke invoke) {
833841
/**
834842
* The invoke has no callee, i.e., it is unreachable.
835843
*/
836-
private void unreachableInvoke(Invoke invoke, SimplifierTool tool) {
844+
private void unreachableInvoke(Invoke invoke, SimplifierTool tool, Supplier<String> messageSupplier) {
837845
if (invoke.getInvokeKind() != CallTargetNode.InvokeKind.Static) {
838846
/*
839847
* Ensure that a null check for the receiver remains in the graph. There should be
@@ -842,8 +850,7 @@ private void unreachableInvoke(Invoke invoke, SimplifierTool tool) {
842850
InliningUtil.nonNullReceiver(invoke);
843851
}
844852

845-
makeUnreachable(invoke.asFixedNode(), tool, () -> "method " + getQualifiedName(graph) + ", node " + invoke +
846-
": empty list of callees for call to " + ((AnalysisMethod) invoke.callTarget().targetMethod()).getQualifiedName());
853+
makeUnreachable(invoke.asFixedNode(), tool, messageSupplier);
847854
}
848855

849856
/**
@@ -962,7 +969,13 @@ private Object strengthenStampFromTypeFlow(ValueNode node, TypeFlow<?> nodeFlow,
962969
*/
963970
boolean hasUsages = node.usages().filter(n -> !(n instanceof FrameState)).isNotEmpty();
964971

965-
TypeState nodeTypeState = nodeFlow.isFlowEnabled() ? methodFlow.foldTypeFlow((PointsToAnalysis) bb, nodeFlow) : TypeState.forEmpty();
972+
if (!nodeFlow.isFlowEnabled()) {
973+
makeUnreachable(anchorPoint.next(), tool,
974+
() -> "method " + getQualifiedName(graph) + ", node " + node + ": flow is not enabled by its predicate " + nodeFlow.getPredicate());
975+
unreachableValues.add(node);
976+
return null;
977+
}
978+
TypeState nodeTypeState = methodFlow.foldTypeFlow((PointsToAnalysis) bb, nodeFlow);
966979

967980
if (hasUsages && allowConstantFolding && !nodeTypeState.canBeNull()) {
968981
JavaConstant constantValue = nodeTypeState.asConstant();

0 commit comments

Comments
 (0)