Search in sources :

Example 41 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerCompilerAssertsPlugins.

public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
    final ResolvedJavaType compilerAssertsType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerAsserts");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerAssertsType));
    r.register(new PEConstantPlugin(canDelayIntrinsification, Object.class));
    r.register(new PEConstantPlugin(canDelayIntrinsification, int.class));
    r.register(new PEConstantPlugin(canDelayIntrinsification, long.class));
    r.register(new PEConstantPlugin(canDelayIntrinsification, float.class));
    r.register(new PEConstantPlugin(canDelayIntrinsification, double.class));
    r.register(new PEConstantPlugin(canDelayIntrinsification, boolean.class));
    r.register(new RequiredInvocationPlugin("neverPartOfCompilation") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new NeverPartOfCompilationNode("CompilerAsserts.neverPartOfCompilation()"));
            return true;
        }
    });
    r.register(new RequiredInvocationPlugin("neverPartOfCompilation", String.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
            if (message.isConstant()) {
                String messageString = message.asConstant().toValueString();
                b.add(new NeverPartOfCompilationNode(messageString));
                return true;
            } else {
                throw b.bailout("message for never part of compilation is non-constant");
            }
        }
    });
}
Also used : RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 42 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class JNIRegistrationSupport method registerLoadLibraryPlugin.

public void registerLoadLibraryPlugin(Plugins plugins, Class<?> clazz) {
    Registration r = new Registration(plugins.getInvocationPlugins(), clazz);
    r.register(new RequiredInvocationPlugin("loadLibrary", String.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode libnameNode) {
            /*
                 * Support for automatic discovery of standard JDK libraries. This works because all
                 * of the JDK uses System.loadLibrary or jdk.internal.loader.BootLoader with literal
                 * String arguments.
                 */
            if (libnameNode.isConstant()) {
                registerLibrary((String) SubstrateObjectConstant.asObject(libnameNode.asConstant()));
            }
            /* We never want to do any actual intrinsification, process the original invoke. */
            return false;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 43 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class HotSpotTruffleGraphBuilderPlugins method registerCompilationFinalReferencePlugins.

static void registerCompilationFinalReferencePlugins(InvocationPlugins plugins, boolean canDelayIntrinsification, HotSpotKnownTruffleTypes types) {
    InvocationPlugins.Registration r = new InvocationPlugins.Registration(plugins, Reference.class);
    r.register(new RequiredInvocationPlugin("get", InvocationPlugin.Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (!canDelayIntrinsification && receiver.isConstant()) {
                JavaConstant constant = (JavaConstant) receiver.get().asConstant();
                if (constant.isNonNull()) {
                    if (types.classWeakReference.isInstance(constant) || types.classSoftReference.isInstance(constant)) {
                        JavaConstant referent = b.getConstantReflection().readFieldValue(types.referenceReferent, constant);
                        b.addPush(JavaKind.Object, ConstantNode.forConstant(referent, b.getMetaAccess()));
                        return true;
                    }
                }
            }
            return false;
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 44 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class HotSpotTruffleGraphBuilderPlugins method registerHotspotThreadLocalStubPlugins.

/**
 * These HotSpot thread local plugins are intended for the interpreter access stubs.
 */
static void registerHotspotThreadLocalStubPlugins(InvocationPlugins plugins, WordTypes wordTypes, int jvmciReservedReference0Offset) {
    GraalError.guarantee(jvmciReservedReference0Offset != -1, "jvmciReservedReference0Offset is not available but used.");
    InvocationPlugins.Registration tl = new InvocationPlugins.Registration(plugins, "org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal");
    tl.register(new RequiredInvocationPlugin("getJVMCIReservedReference") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Object, new HotSpotLoadReservedReferenceNode(b.getMetaAccess(), wordTypes, jvmciReservedReference0Offset));
            return true;
        }
    });
    tl.register(new RequiredInvocationPlugin("setJVMCIReservedReference", Object[].class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.add(new HotSpotStoreReservedReferenceNode(wordTypes, value, jvmciReservedReference0Offset));
            return true;
        }
    });
}
Also used : HotSpotLoadReservedReferenceNode(org.graalvm.compiler.hotspot.nodes.HotSpotLoadReservedReferenceNode) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) HotSpotStoreReservedReferenceNode(org.graalvm.compiler.hotspot.nodes.HotSpotStoreReservedReferenceNode)

Example 45 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class CEntryPointSupport method registerCurrentIsolatePlugins.

private static void registerCurrentIsolatePlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, CurrentIsolate.class);
    r.register(new RequiredInvocationPlugin("getCurrentThread") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (SubstrateOptions.MultiThreaded.getValue()) {
                b.addPush(JavaKind.Object, ReadReservedRegister.createReadIsolateThreadNode(b.getGraph()));
            } else if (SubstrateOptions.SpawnIsolates.getValue()) {
                ValueNode heapBase = b.add(ReadReservedRegister.createReadHeapBaseNode(b.getGraph()));
                ConstantNode addend = b.add(ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND));
                b.addPush(JavaKind.Object, new AddNode(heapBase, addend));
            } else {
                b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_THREAD_SENTINEL.rawValue()));
            }
            return true;
        }
    });
    r.register(new RequiredInvocationPlugin("getIsolate") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (SubstrateOptions.SpawnIsolates.getValue()) {
                b.addPush(JavaKind.Object, ReadReservedRegister.createReadHeapBaseNode(b.getGraph()));
            } else {
                b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_SENTINEL.rawValue()));
            }
            return true;
        }
    });
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)47 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)47 RequiredInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin)47 ValueNode (org.graalvm.compiler.nodes.ValueNode)38 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)37 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)34 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)14 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)9 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)8 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)5 LogicNode (org.graalvm.compiler.nodes.LogicNode)5 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)5 IsolateThread (org.graalvm.nativeimage.IsolateThread)4 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)3 TruffleCompilerRuntime (org.graalvm.compiler.truffle.common.TruffleCompilerRuntime)3 AllowMaterializeNode (org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode)3 NewFrameNode (org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode)3 VirtualFrameGetNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameGetNode)3 VirtualFrameSetNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSetNode)3