Search in sources :

Example 16 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class StandardGraphBuilderPlugins method registerIntegerLongPlugins.

private static void registerIntegerLongPlugins(InvocationPlugins plugins, JavaKind kind) {
    Class<?> declaringClass = kind.toBoxedJavaClass();
    Class<?> type = kind.toJavaClass();
    Registration r = new Registration(plugins, declaringClass);
    r.register1("reverseBytes", type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(kind, b.append(new ReverseBytesNode(value).canonical(null)));
            return true;
        }
    });
    r.register2("divideUnsigned", type, type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode dividend, ValueNode divisor) {
            b.push(kind, b.append(UnsignedDivNode.create(dividend, divisor, NodeView.DEFAULT)));
            return true;
        }
    });
    r.register2("remainderUnsigned", type, type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode dividend, ValueNode divisor) {
            b.push(kind, b.append(UnsignedRemNode.create(dividend, divisor, NodeView.DEFAULT)));
            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) ReverseBytesNode(org.graalvm.compiler.replacements.nodes.ReverseBytesNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 17 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration 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 18 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class CGlobalDataFeature method registerInvocationPlugins.

@Override
public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, InvocationPlugins invocationPlugins, boolean hosted) {
    Registration r = new Registration(invocationPlugins, CGlobalData.class);
    r.register1("get", Receiver.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            VMError.guarantee(receiver.get().isConstant(), "Accessed CGlobalData is not a compile-time constant: " + b.getMethod().asStackTraceElement(b.bci()));
            CGlobalDataImpl<?> data = (CGlobalDataImpl<?>) SubstrateObjectConstant.asObject(receiver.get().asConstant());
            CGlobalDataInfo info = CGlobalDataFeature.this.map.get(data);
            b.addPush(targetMethod.getSignature().getReturnKind(), new CGlobalDataLoadAddressNode(info));
            return true;
        }
    });
}
Also used : CGlobalDataImpl(com.oracle.svm.core.c.CGlobalDataImpl) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) CGlobalDataInfo(com.oracle.svm.core.graal.code.CGlobalDataInfo) CGlobalDataLoadAddressNode(com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 19 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class ReplacementsParseTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    BytecodeProvider replacementBytecodeProvider = getSystemClassLoaderBytecodeProvider();
    Registration r = new Registration(invocationPlugins, TestObject.class, replacementBytecodeProvider);
    NodeIntrinsicPluginFactory.InjectionProvider injections = new DummyInjectionProvider();
    new PluginFactory_ReplacementsParseTest().registerPlugins(invocationPlugins, injections);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "nextAfter", double.class, double.class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "stringize", Object.class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "stringizeId", Receiver.class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "copyFirst", byte[].class, byte[].class, boolean.class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "copyFirstL2R", byte[].class, byte[].class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "nonVoidIntrinsicWithCall", int.class, int.class);
    r.registerMethodSubstitution(TestObjectSubstitutions.class, "nonVoidIntrinsicWithOptimizedSplit", int.class);
    if (replacementBytecodeProvider.supportsInvokedynamic()) {
        r.registerMethodSubstitution(TestObjectSubstitutions.class, "identity", String.class);
    }
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : NodeIntrinsicPluginFactory(org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider)

Example 20 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class SubstitutionsTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    new PluginFactory_SubstitutionsTest().registerPlugins(invocationPlugins, null);
    ClassfileBytecodeProvider bytecodeProvider = getSystemClassLoaderBytecodeProvider();
    Registration r = new Registration(invocationPlugins, TestMethod.class, bytecodeProvider);
    r.registerMethodSubstitution(TestMethodSubstitution.class, "test");
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)

Aggregations

Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)88 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)66 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)66 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)66 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)52 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)13 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)13 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)7 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)7 JavaKind (jdk.vm.ci.meta.JavaKind)5 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)5 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)5 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)5 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 AnalysisArraysCopyOfNode (com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 BlackholeNode (org.graalvm.compiler.nodes.debug.BlackholeNode)3