Search in sources :

Example 46 with MethodCallTargetNode

use of org.graalvm.compiler.nodes.java.MethodCallTargetNode in project graal by oracle.

the class VerifyDebugUsage method verify.

@Override
protected boolean verify(StructuredGraph graph, PhaseContext context) {
    metaAccess = context.getMetaAccess();
    ResolvedJavaType debugType = metaAccess.lookupJavaType(DebugContext.class);
    ResolvedJavaType nodeType = metaAccess.lookupJavaType(Node.class);
    ResolvedJavaType stringType = metaAccess.lookupJavaType(String.class);
    ResolvedJavaType graalErrorType = metaAccess.lookupJavaType(GraalError.class);
    for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
        ResolvedJavaMethod callee = t.targetMethod();
        String calleeName = callee.getName();
        if (callee.getDeclaringClass().equals(debugType)) {
            boolean isDump = calleeName.equals("dump");
            if (calleeName.equals("log") || calleeName.equals("logAndIndent") || calleeName.equals("verify") || isDump) {
                verifyParameters(t, graph, t.arguments(), stringType, isDump ? 2 : 1);
            }
        }
        if (callee.getDeclaringClass().isAssignableFrom(nodeType)) {
            if (calleeName.equals("assertTrue") || calleeName.equals("assertFalse")) {
                verifyParameters(t, graph, t.arguments(), stringType, 1);
            }
        }
        if (callee.getDeclaringClass().isAssignableFrom(graalErrorType) && !graph.method().getDeclaringClass().isAssignableFrom(graalErrorType)) {
            if (calleeName.equals("guarantee")) {
                verifyParameters(t, graph, t.arguments(), stringType, 0);
            }
            if (calleeName.equals("<init>") && callee.getSignature().getParameterCount(false) == 2) {
                verifyParameters(t, graph, t.arguments(), stringType, 1);
            }
        }
    }
    return true;
}
Also used : MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)46 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)17 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)15 ValueNode (org.graalvm.compiler.nodes.ValueNode)15 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)11 Invoke (org.graalvm.compiler.nodes.Invoke)10 Node (org.graalvm.compiler.graph.Node)9 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)9 ArrayList (java.util.ArrayList)7 StampPair (org.graalvm.compiler.core.common.type.StampPair)7 PiNode (org.graalvm.compiler.nodes.PiNode)7 DebugContext (org.graalvm.compiler.debug.DebugContext)6 CallTargetNode (org.graalvm.compiler.nodes.CallTargetNode)6 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)5 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)5 FrameState (org.graalvm.compiler.nodes.FrameState)5 JavaType (jdk.vm.ci.meta.JavaType)4 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)4 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)4 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)4