Search in sources :

Example 6 with Receiver

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

the class HotSpotGraphBuilderPlugins method registerThreadPlugins.

private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
    Registration r = new Registration(plugins, Thread.class, bytecodeProvider);
    r.register0("currentThread", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind()));
            ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset));
            AddressNode address = b.add(new OffsetAddressNode(thread, offset));
            // JavaThread::_threadObj is never compressed
            ObjectStamp stamp = StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), metaAccess.lookupJavaType(Thread.class)));
            b.addPush(JavaKind.Object, new ReadNode(address, JAVA_THREAD_THREAD_OBJECT_LOCATION, stamp, BarrierType.NONE));
            return true;
        }
    });
    r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class);
}
Also used : ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) CurrentJavaThreadNode(org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode) 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) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 7 with Receiver

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

the class StandardGraphBuilderPlugins method registerClassPlugins.

private static void registerClassPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Class.class);
    r.register2("isInstance", Receiver.class, Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode object) {
            LogicNode condition = b.append(InstanceOfDynamicNode.create(b.getAssumptions(), b.getConstantReflection(), type.get(), object, false));
            b.push(JavaKind.Boolean, b.append(new ConditionalNode(condition).canonical(null)));
            return true;
        }
    });
    r.register2("isAssignableFrom", Receiver.class, Class.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode otherType) {
            ClassIsAssignableFromNode condition = b.append(new ClassIsAssignableFromNode(type.get(), otherType));
            b.push(JavaKind.Boolean, b.append(new ConditionalNode(condition).canonical(null)));
            return true;
        }
    });
}
Also used : ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) 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) LogicNode(org.graalvm.compiler.nodes.LogicNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 8 with Receiver

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

the class StandardGraphBuilderPlugins method registerCharacterPlugins.

private static void registerCharacterPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Character.class);
    r.register1("reverseBytes", char.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            // return (char) (Integer.reverse(i) >> 16);
            ReverseBytesNode reverse = b.add(new ReverseBytesNode(value));
            RightShiftNode rightShift = b.add(new RightShiftNode(reverse, b.add(ConstantNode.forInt(16))));
            ZeroExtendNode charCast = b.add(new ZeroExtendNode(b.add(new NarrowNode(rightShift, 16)), 32));
            b.push(JavaKind.Char, b.append(charCast.canonical(null)));
            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) RightShiftNode(org.graalvm.compiler.nodes.calc.RightShiftNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ReverseBytesNode(org.graalvm.compiler.replacements.nodes.ReverseBytesNode) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 9 with Receiver

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

the class StandardGraphBuilderPlugins method registerDoublePlugins.

private static void registerDoublePlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Double.class);
    r.register1("doubleToRawLongBits", double.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Long, b.append(ReinterpretNode.create(JavaKind.Long, value, NodeView.DEFAULT)));
            return true;
        }
    });
    r.register1("longBitsToDouble", long.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Double, b.append(ReinterpretNode.create(JavaKind.Double, value, 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) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 10 with Receiver

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

the class StandardGraphBuilderPlugins method registerFloatPlugins.

private static void registerFloatPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Float.class);
    r.register1("floatToRawIntBits", float.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Int, b.append(ReinterpretNode.create(JavaKind.Int, value, NodeView.DEFAULT)));
            return true;
        }
    });
    r.register1("intBitsToFloat", int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Float, b.append(ReinterpretNode.create(JavaKind.Float, value, 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) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

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