Search in sources :

Example 56 with ResolvedJavaMethod

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

the class PointstoGraphBuilderPlugins method registerObjectPlugins.

public static void registerObjectPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Object.class);
    r.register1("clone", Receiver.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode object = receiver.get();
            b.addPush(JavaKind.Object, new AnalysisObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), object));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) AnalysisObjectCloneNode(com.oracle.graal.pointsto.nodes.AnalysisObjectCloneNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 57 with ResolvedJavaMethod

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

the class NativeImageGenerator method checkInvocationPluginMethods.

private static boolean checkInvocationPluginMethods(SubstrateReplacements replacements) {
    for (ResolvedJavaMethod method : replacements.getDelayedInvocationPluginMethods()) {
        ResolvedJavaMethod unwrapped = method;
        while (unwrapped instanceof WrappedJavaMethod) {
            unwrapped = ((WrappedJavaMethod) unwrapped).getWrapped();
        }
        if (method != unwrapped) {
            String runtimeDescriptor = method.getSignature().toMethodDescriptor();
            String hostedDescriptor = unwrapped.getSignature().toMethodDescriptor();
            if (!runtimeDescriptor.equals(hostedDescriptor)) {
                String name = method.format("%H.%n");
                throw new AssertionError(String.format("Cannot have invocation plugin for a method whose runtime signature is different from its hosted signature:%n" + "            method: %s%n" + "  hosted signature: %s%n" + " runtime signature: %s", name, runtimeDescriptor, hostedDescriptor));
            }
        }
        assert method == unwrapped || method.getSignature().toMethodDescriptor().equals(unwrapped.getSignature().toMethodDescriptor());
    }
    return true;
}
Also used : WrappedJavaMethod(com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 58 with ResolvedJavaMethod

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

the class SizeAndSignednessVerifier method visitEnumValueInfo.

@Override
protected void visitEnumValueInfo(EnumValueInfo valueInfo) {
    ResolvedJavaMethod method = (ResolvedJavaMethod) valueInfo.getAnnotatedElement();
    ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
    EnumInfo enumInfo = (EnumInfo) valueInfo.getParent();
    for (ElementInfo info : enumInfo.getChildren()) {
        if (info instanceof EnumConstantInfo) {
            EnumConstantInfo constantInfo = (EnumConstantInfo) info;
            checkSizeAndSignedness(constantInfo, returnType, method, true);
        }
    }
}
Also used : EnumConstantInfo(com.oracle.svm.hosted.c.info.EnumConstantInfo) ElementInfo(com.oracle.svm.hosted.c.info.ElementInfo) EnumInfo(com.oracle.svm.hosted.c.info.EnumInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 59 with ResolvedJavaMethod

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

the class CEntryPointCallStubMethod method lookupMethodInUniverse.

private ResolvedJavaMethod lookupMethodInUniverse(UniverseMetaAccess metaAccess, ResolvedJavaMethod method) {
    ResolvedJavaMethod universeMethod = method;
    MetaAccessProvider wrappedMetaAccess = metaAccess.getWrapped();
    if (wrappedMetaAccess instanceof UniverseMetaAccess) {
        universeMethod = lookupMethodInUniverse((UniverseMetaAccess) wrappedMetaAccess, universeMethod);
    }
    return metaAccess.getUniverse().lookup(universeMethod);
}
Also used : UniverseMetaAccess(com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider)

Example 60 with ResolvedJavaMethod

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

the class CEntryPointCallStubMethod method generatePrologue.

private InvokeNode generatePrologue(HostedProviders providers, SubstrateGraphKit kit, JavaType[] parameterTypes, ValueNode[] args) {
    Class<?> prologueClass = entryPointData.getPrologue();
    if (prologueClass == NoPrologue.class) {
        UserError.guarantee(targetMethod.getAnnotation(Uninterruptible.class) != null, CEntryPointOptions.class.getSimpleName() + "." + NoPrologue.class.getSimpleName() + " is allowed only for methods annotated with @" + Uninterruptible.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
        return null;
    }
    if (prologueClass == CEntryPointOptions.AutomaticPrologue.class) {
        ResolvedJavaType isolateType = providers.getMetaAccess().lookupJavaType(Isolate.class);
        ResolvedJavaType threadType = providers.getMetaAccess().lookupJavaType(IsolateThread.class);
        ResolvedJavaType matchType = null;
        int matchesCount = 0;
        for (JavaType parameterType : parameterTypes) {
            ResolvedJavaType type = (ResolvedJavaType) parameterType;
            if (threadType.isAssignableFrom(type) || isolateType.isAssignableFrom(type)) {
                matchType = type;
                matchesCount++;
            }
        }
        if (matchesCount == 1) {
            if (threadType.isAssignableFrom(matchType)) {
                prologueClass = CEntryPointSetup.EnterPrologue.class;
            } else {
                prologueClass = CEntryPointSetup.EnterIsolatePrologue.class;
            }
        } else {
            throw UserError.abort("@" + CEntryPoint.class.getSimpleName() + " requires exactly one parameter of type " + IsolateThread.class.getSimpleName() + " or " + Isolate.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
        }
    }
    ResolvedJavaType prologue = providers.getMetaAccess().lookupJavaType(prologueClass);
    ResolvedJavaMethod[] prologueMethods = prologue.getDeclaredMethods();
    UserError.guarantee(prologueMethods.length == 1 && prologueMethods[0].isStatic(), "Prologue class must declare exactly one static method: " + targetMethod.format("%H.%n(%p)") + " -> " + prologue.toJavaName());
    ValueNode[] prologueArgs = matchPrologueParameters(providers, parameterTypes, args, prologueMethods[0]);
    return kit.createInvoke(prologueMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci(), prologueArgs);
}
Also used : CEntryPointSetup(com.oracle.svm.core.c.function.CEntryPointSetup) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)331 ValueNode (org.graalvm.compiler.nodes.ValueNode)104 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)92 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)89 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)67 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)66 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)66 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)57 Test (org.junit.Test)54 DebugContext (org.graalvm.compiler.debug.DebugContext)35 OptionValues (org.graalvm.compiler.options.OptionValues)32 InstalledCode (jdk.vm.ci.code.InstalledCode)24 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)23 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)22 JavaKind (jdk.vm.ci.meta.JavaKind)21 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)20 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)19 JavaConstant (jdk.vm.ci.meta.JavaConstant)17 LogicNode (org.graalvm.compiler.nodes.LogicNode)17 ArrayList (java.util.ArrayList)16