Skip to content

Commit 77e1870

Browse files
committed
[GR-60533] Fix NonSnippetLowerings ClassCastException.
PullRequest: graal/19618
2 parents fc7f20d + 5ab888f commit 77e1870

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/NonSnippetLowerings.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
import jdk.vm.ci.meta.DeoptimizationReason;
113113
import jdk.vm.ci.meta.JavaConstant;
114114
import jdk.vm.ci.meta.JavaKind;
115+
import jdk.vm.ci.meta.JavaMethodProfile;
115116
import jdk.vm.ci.meta.JavaType;
116117
import jdk.vm.ci.meta.ResolvedJavaMethod;
117118

@@ -494,8 +495,8 @@ protected LoweredCallTargetNode createDirectCall(StructuredGraph graph, MethodCa
494495

495496
protected IndirectCallTargetNode createIndirectCall(StructuredGraph graph, MethodCallTargetNode callTarget, NodeInputList<ValueNode> parameters, SharedMethod method, JavaType[] signature,
496497
CallingConvention.Type callType, InvokeKind invokeKind, ValueNode entry) {
497-
return graph.add(new SubstrateIndirectCallTargetNode(entry, parameters.toArray(new ValueNode[parameters.size()]), callTarget.returnStamp(), signature, method, callType, invokeKind,
498-
((SubstrateMethodCallTargetNode) callTarget).getMethodProfile()));
498+
JavaMethodProfile methodProfile = callTarget instanceof SubstrateMethodCallTargetNode substrateCallTarget ? substrateCallTarget.getMethodProfile() : null;
499+
return graph.add(new SubstrateIndirectCallTargetNode(entry, parameters.toArray(ValueNode.EMPTY_ARRAY), callTarget.returnStamp(), signature, method, callType, invokeKind, methodProfile));
499500
}
500501

501502
private static CallTargetNode createUnreachableCallTarget(LoweringTool tool, FixedNode node, NodeInputList<ValueNode> parameters, StampPair returnStamp, JavaType[] signature,

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nodes/SubstrateMethodCallTargetNode.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
import jdk.vm.ci.meta.JavaTypeProfile;
3434
import jdk.vm.ci.meta.ResolvedJavaMethod;
3535

36+
/**
37+
* Extension of {@link MethodCallTargetNode} that adds a {@link JavaMethodProfile} when available.
38+
* Note that the replacement from {@link MethodCallTargetNode} to
39+
* {@link SubstrateMethodCallTargetNode} is not mandatory. SVM code can introduce new
40+
* {@link MethodCallTargetNode}s.
41+
*/
3642
@NodeInfo
3743
public final class SubstrateMethodCallTargetNode extends MethodCallTargetNode {
3844
public static final NodeClass<SubstrateMethodCallTargetNode> TYPE = NodeClass.create(SubstrateMethodCallTargetNode.class);

0 commit comments

Comments
 (0)