Search in sources :

Example 1 with CurrentJavaThreadNode

use of org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode 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)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 CurrentJavaThreadNode (org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)1 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)1 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)1