package com.oracle.svm.hosted.nodes;
import java.util.Map;
import org.graalvm.compiler.core.common.type.StampPair;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodeinfo.NodeInfo;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
import com.oracle.graal.pointsto.results.StaticAnalysisResults;
import jdk.vm.ci.meta.JavaMethodProfile;
import jdk.vm.ci.meta.JavaTypeProfile;
import jdk.vm.ci.meta.ResolvedJavaMethod;
@NodeInfo
public final class SubstrateMethodCallTargetNode extends MethodCallTargetNode {
public static final NodeClass<SubstrateMethodCallTargetNode> TYPE = NodeClass.create(SubstrateMethodCallTargetNode.class);
protected final StaticAnalysisResults staticAnalysisResults;
protected final int bci;
public SubstrateMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, StampPair returnStamp, StaticAnalysisResults staticAnalysisResults, int bci) {
super(TYPE, invokeKind, targetMethod, arguments, returnStamp, staticAnalysisResults.getTypeProfile(bci));
this.staticAnalysisResults = staticAnalysisResults;
this.bci = bci;
}
public StaticAnalysisResults getStaticAnalysisResults() {
return staticAnalysisResults;
}
public int getBci() {
return bci;
}
public JavaTypeProfile getTypeProfile() {
return getProfile();
}
public JavaMethodProfile getMethodProfile() {
return staticAnalysisResults.getMethodProfile(bci);
}
public JavaTypeProfile getInvokeResultTypeProfile() {
return staticAnalysisResults.getInvokeResultTypeProfile(bci);
}
@Override
public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
map.put("typeProfile", getTypeProfile());
map.put("methodProfile", getMethodProfile());
map.put("resultTypeProfile", getInvokeResultTypeProfile());
return super.getDebugProperties(map);
}
}