Search in sources :

Example 81 with Registration

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

the class AMD64GraphBuilderPlugins method registerArraysEqualsPlugins.

private static void registerArraysEqualsPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
    Registration r = new Registration(plugins, Arrays.class, bytecodeProvider);
    r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", float[].class, float[].class);
    r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", double[].class, double[].class);
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)

Example 82 with Registration

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

the class AMD64GraphBuilderPlugins method registerStringPlugins.

private static void registerStringPlugins(InvocationPlugins plugins, AMD64 arch, BytecodeProvider replacementsBytecodeProvider) {
    if (Java8OrEarlier) {
        Registration r;
        r = new Registration(plugins, String.class, replacementsBytecodeProvider);
        r.setAllowOverwrite(true);
        if (arch.getFeatures().contains(CPUFeature.SSE4_2)) {
            r.registerMethodSubstitution(AMD64StringSubstitutions.class, "indexOf", char[].class, int.class, int.class, char[].class, int.class, int.class, int.class);
        }
        r.registerMethodSubstitution(AMD64StringSubstitutions.class, "compareTo", Receiver.class, String.class);
    }
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)

Example 83 with Registration

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

the class AMD64GraphBuilderPlugins method registerUnsafePlugins.

private static void registerUnsafePlugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) {
    Registration r;
    if (Java8OrEarlier) {
        r = new Registration(plugins, Unsafe.class);
    } else {
        r = new Registration(plugins, "jdk.internal.misc.Unsafe", replacementsBytecodeProvider);
    }
    for (JavaKind kind : new JavaKind[] { JavaKind.Int, JavaKind.Long, JavaKind.Object }) {
        Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass();
        r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) {
                // Emits a null-check for the otherwise unused receiver
                unsafe.get();
                b.addPush(kind, new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any()));
                b.getGraph().markUnsafeAccess();
                return true;
            }
        });
        if (kind != JavaKind.Object) {
            r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {

                @Override
                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) {
                    // Emits a null-check for the otherwise unused receiver
                    unsafe.get();
                    AddressNode address = b.add(new OffsetAddressNode(object, offset));
                    b.addPush(kind, new AtomicReadAndAddNode(address, delta, LocationIdentity.any()));
                    b.getGraph().markUnsafeAccess();
                    return true;
                }
            });
        }
    }
    for (JavaKind kind : new JavaKind[] { JavaKind.Char, JavaKind.Short, JavaKind.Int, JavaKind.Long }) {
        Class<?> javaClass = kind.toJavaClass();
        r.registerOptional3("get" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, false));
        r.registerOptional4("put" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, false));
    }
}
Also used : Unsafe(sun.misc.Unsafe) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) UnsafePutPlugin(org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.UnsafePutPlugin) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) 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) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) AtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) JavaKind(jdk.vm.ci.meta.JavaKind) AtomicReadAndAddNode(org.graalvm.compiler.nodes.java.AtomicReadAndAddNode) UnsafeGetPlugin(org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.UnsafeGetPlugin)

Example 84 with Registration

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

the class AMD64GraphBuilderPlugins method registerStringLatin1Plugins.

private static void registerStringLatin1Plugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) {
    if (JAVA_SPECIFICATION_VERSION >= 9) {
        Registration r = new Registration(plugins, "java.lang.StringLatin1", replacementsBytecodeProvider);
        r.setAllowOverwrite(true);
        r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "compareTo", byte[].class, byte[].class);
        r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "compareToUTF16", byte[].class, byte[].class);
    }
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)

Example 85 with Registration

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

the class RedefineIntrinsicTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    BytecodeProvider replacementBytecodeProvider = getSystemClassLoaderBytecodeProvider();
    Registration r = new Registration(invocationPlugins, Original.class, replacementBytecodeProvider);
    r.registerMethodSubstitution(Intrinsic.class, "getValue");
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider)

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