Search in sources :

Example 11 with JavaType

use of jdk.vm.ci.meta.JavaType in project graal by oracle.

the class GraphKit method startInvokeWithException.

public InvokeWithExceptionNode startInvokeWithException(ResolvedJavaMethod method, InvokeKind invokeKind, FrameStateBuilder frameStateBuilder, int invokeBci, int exceptionEdgeBci, ValueNode... args) {
    assert method.isStatic() == (invokeKind == InvokeKind.Static);
    Signature signature = method.getSignature();
    JavaType returnType = signature.getReturnType(null);
    assert checkArgs(method, args);
    StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false);
    if (returnStamp == null) {
        returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
    }
    ExceptionObjectNode exceptionObject = add(new ExceptionObjectNode(getMetaAccess()));
    if (frameStateBuilder != null) {
        FrameStateBuilder exceptionState = frameStateBuilder.copy();
        exceptionState.clearStack();
        exceptionState.push(JavaKind.Object, exceptionObject);
        exceptionState.setRethrowException(false);
        exceptionObject.setStateAfter(exceptionState.create(exceptionEdgeBci, exceptionObject));
    }
    MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, invokeBci));
    InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionObject, invokeBci));
    AbstractBeginNode noExceptionEdge = graph.add(KillingBeginNode.create(LocationIdentity.any()));
    invoke.setNext(noExceptionEdge);
    if (frameStateBuilder != null) {
        if (invoke.getStackKind() != JavaKind.Void) {
            frameStateBuilder.push(invoke.getStackKind(), invoke);
        }
        invoke.setStateAfter(frameStateBuilder.create(invokeBci, invoke));
        if (invoke.getStackKind() != JavaKind.Void) {
            frameStateBuilder.pop(invoke.getStackKind());
        }
    }
    lastFixedNode = null;
    InvokeWithExceptionStructure s = new InvokeWithExceptionStructure();
    s.state = InvokeWithExceptionStructure.State.INVOKE;
    s.noExceptionEdge = noExceptionEdge;
    s.exceptionEdge = exceptionObject;
    s.exceptionObject = exceptionObject;
    pushStructure(s);
    return invoke;
}
Also used : JavaType(jdk.vm.ci.meta.JavaType) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) Signature(jdk.vm.ci.meta.Signature) StampPair(org.graalvm.compiler.core.common.type.StampPair) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) FrameStateBuilder(org.graalvm.compiler.java.FrameStateBuilder) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 12 with JavaType

use of jdk.vm.ci.meta.JavaType in project graal by oracle.

the class SystemArrayCopyTest method parse.

@Override
protected StructuredGraph parse(StructuredGraph.Builder builder, PhaseSuite<HighTierContext> graphBuilderSuite) {
    StructuredGraph graph = super.parse(builder, graphBuilderSuite);
    if (argsToBind != null) {
        ResolvedJavaMethod m = graph.method();
        Object receiver = isStatic(m.getModifiers()) ? null : this;
        Object[] args = argsWithReceiver(receiver, argsToBind);
        JavaType[] parameterTypes = m.toParameterTypes();
        assert parameterTypes.length == args.length;
        for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
            int index = param.index();
            if (args[index] != null) {
                JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[index].getJavaKind(), args[index]);
                ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
                param.replaceAtUsages(replacement);
            }
        }
    }
    return graph;
}
Also used : JavaType(jdk.vm.ci.meta.JavaType) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 13 with JavaType

use of jdk.vm.ci.meta.JavaType in project graal by oracle.

the class JNIFieldAccessorMethod method createSignature.

private JNISignature createSignature(MetaAccessProvider metaAccess) {
    Class<?> valueClass = fieldKind.toJavaClass();
    if (fieldKind.isObject()) {
        valueClass = JNIObjectHandle.class;
    }
    ResolvedJavaType objectHandle = metaAccess.lookupJavaType(JNIObjectHandle.class);
    List<JavaType> args = new ArrayList<>();
    args.add(metaAccess.lookupJavaType(JNIEnvironment.class));
    // this (instance field) or class (static field)
    args.add(objectHandle);
    args.add(metaAccess.lookupJavaType(JNIFieldId.class));
    if (isSetter) {
        args.add(metaAccess.lookupJavaType(valueClass));
    }
    ResolvedJavaType returnType;
    if (isSetter) {
        returnType = metaAccess.lookupJavaType(Void.TYPE);
    } else {
        returnType = metaAccess.lookupJavaType(valueClass);
    }
    return new JNISignature(args, returnType);
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) JNIEnvironment(com.oracle.svm.jni.nativeapi.JNIEnvironment) ArrayList(java.util.ArrayList) JNIFieldId(com.oracle.svm.jni.nativeapi.JNIFieldId) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 14 with JavaType

use of jdk.vm.ci.meta.JavaType in project graal by oracle.

the class InstalledCodeExecuteHelperTest method parse.

@Override
protected StructuredGraph parse(Builder builder, PhaseSuite<HighTierContext> graphBuilderSuite) {
    StructuredGraph graph = super.parse(builder, graphBuilderSuite);
    if (argsToBind != null) {
        ResolvedJavaMethod m = graph.method();
        Object receiver = isStatic(m.getModifiers()) ? null : this;
        Object[] args = argsWithReceiver(receiver, argsToBind);
        JavaType[] parameterTypes = m.toParameterTypes();
        assert parameterTypes.length == args.length;
        for (int i = 0; i < argsToBind.length; i++) {
            ParameterNode param = graph.getParameter(i);
            JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[i].getJavaKind(), argsToBind[i]);
            ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
            param.replaceAtUsages(replacement);
        }
    }
    return graph;
}
Also used : JavaType(jdk.vm.ci.meta.JavaType) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 15 with JavaType

use of jdk.vm.ci.meta.JavaType in project graal by oracle.

the class SPARCHotSpotNodeLIRBuilder method visitBreakpointNode.

@Override
public void visitBreakpointNode(BreakpointNode node) {
    JavaType[] sig = new JavaType[node.arguments().size()];
    for (int i = 0; i < sig.length; i++) {
        sig[i] = node.arguments().get(i).stamp(NodeView.DEFAULT).javaType(gen.getMetaAccess());
    }
    Value[] parameters = visitInvokeArguments(gen.getRegisterConfig().getCallingConvention(HotSpotCallingConventionType.JavaCall, null, sig, gen), node.arguments());
    append(new SPARCBreakpointOp(parameters));
}
Also used : JavaType(jdk.vm.ci.meta.JavaType) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCBreakpointOp(org.graalvm.compiler.lir.sparc.SPARCBreakpointOp)

Aggregations

JavaType (jdk.vm.ci.meta.JavaType)45 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)35 ValueNode (org.graalvm.compiler.nodes.ValueNode)22 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)15 JavaKind (jdk.vm.ci.meta.JavaKind)14 Signature (jdk.vm.ci.meta.Signature)11 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)8 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)8 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)8 InvokeKind (org.graalvm.compiler.nodes.CallTargetNode.InvokeKind)7 EnumInfo (com.oracle.svm.hosted.c.info.EnumInfo)6 ArrayList (java.util.ArrayList)6 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)6 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)6 NativeLibraries (com.oracle.svm.hosted.c.NativeLibraries)5 StampPair (org.graalvm.compiler.core.common.type.StampPair)5 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)4 ElementInfo (com.oracle.svm.hosted.c.info.ElementInfo)4 HostedGraphKit (com.oracle.svm.hosted.phases.HostedGraphKit)4 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)4