Search in sources :

Example 1 with NodePlugin

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

the class BytecodeParser method genGetField.

private void genGetField(ResolvedJavaField resolvedField, ValueNode receiver) {
    if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
        graph.recordField(resolvedField);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleLoadField(this, receiver, resolvedField)) {
            return;
        }
    }
    ValueNode fieldRead = append(genLoadField(receiver, resolvedField));
    if (resolvedField.getDeclaringClass().getName().equals("Ljava/lang/ref/Reference;") && resolvedField.getName().equals("referent")) {
        LocationIdentity referentIdentity = new FieldLocationIdentity(resolvedField);
        append(new MembarNode(0, referentIdentity));
    }
    JavaKind fieldKind = resolvedField.getJavaKind();
    if (resolvedField.isVolatile() && fieldRead instanceof LoadFieldNode) {
        StateSplitProxyNode readProxy = append(genVolatileFieldReadProxy(fieldRead));
        frameState.push(fieldKind, readProxy);
        readProxy.setStateAfter(frameState.create(stream.nextBCI(), readProxy));
    } else {
        frameState.push(fieldKind, fieldRead);
    }
}
Also used : FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) StateSplitProxyNode(org.graalvm.compiler.nodes.extended.StateSplitProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LocationIdentity(org.graalvm.word.LocationIdentity) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 2 with NodePlugin

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

the class BytecodeParser method genNewMultiArray.

private void genNewMultiArray(int cpi) {
    JavaType type = lookupType(cpi, MULTIANEWARRAY);
    int rank = getStream().readUByte(bci() + 3);
    ValueNode[] dims = new ValueNode[rank];
    if (!(type instanceof ResolvedJavaType)) {
        for (int i = rank - 1; i >= 0; i--) {
            dims[i] = frameState.pop(JavaKind.Int);
        }
        handleUnresolvedNewMultiArray(type, dims);
        return;
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) type;
    ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedType, stateBefore);
    }
    for (int i = rank - 1; i >= 0; i--) {
        dims[i] = frameState.pop(JavaKind.Int);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleNewMultiArray(this, resolvedType, dims)) {
            return;
        }
    }
    frameState.push(JavaKind.Object, append(createNewMultiArray(resolvedType, dims)));
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 3 with NodePlugin

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

the class BytecodeParser method genNewInstance.

void genNewInstance(JavaType type) {
    if (!(type instanceof ResolvedJavaType)) {
        handleUnresolvedNewInstance(type);
        return;
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) type;
    ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (!resolvedType.isInitialized() && classInitializationPlugin == null) {
        handleUnresolvedNewInstance(type);
        return;
    }
    ResolvedJavaType[] skippedExceptionTypes = this.graphBuilderConfig.getSkippedExceptionTypes();
    if (skippedExceptionTypes != null) {
        for (ResolvedJavaType exceptionType : skippedExceptionTypes) {
            if (exceptionType.isAssignableFrom(resolvedType)) {
                append(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, RuntimeConstraint));
                return;
            }
        }
    }
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedType, stateBefore);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleNewInstance(this, resolvedType)) {
            return;
        }
    }
    frameState.push(JavaKind.Object, append(createNewInstance(resolvedType, true)));
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 4 with NodePlugin

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

the class BytecodeParser method genStoreIndexed.

private void genStoreIndexed(JavaKind kind) {
    ValueNode value = frameState.pop(kind);
    ValueNode index = frameState.pop(JavaKind.Int);
    ValueNode array = emitExplicitExceptions(frameState.pop(JavaKind.Object), index);
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleStoreIndexed(this, array, index, kind, value)) {
            return;
        }
    }
    genStoreIndexed(array, index, kind, value);
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 5 with NodePlugin

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

the class PEGraphDecoder method canonicalizeFixedNode.

@SuppressWarnings("try")
@Override
protected Node canonicalizeFixedNode(MethodScope s, Node node) {
    PEMethodScope methodScope = (PEMethodScope) s;
    Node replacedNode = node;
    if (nodePlugins != null && nodePlugins.length > 0) {
        if (node instanceof LoadFieldNode) {
            LoadFieldNode loadFieldNode = (LoadFieldNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadFieldNode);
            ResolvedJavaField field = loadFieldNode.field();
            if (loadFieldNode.isStatic()) {
                for (NodePlugin nodePlugin : nodePlugins) {
                    if (nodePlugin.handleLoadStaticField(graphBuilderContext, field)) {
                        replacedNode = graphBuilderContext.pushedNode;
                        break;
                    }
                }
            } else {
                ValueNode object = loadFieldNode.object();
                for (NodePlugin nodePlugin : nodePlugins) {
                    if (nodePlugin.handleLoadField(graphBuilderContext, object, field)) {
                        replacedNode = graphBuilderContext.pushedNode;
                        break;
                    }
                }
            }
        } else if (node instanceof StoreFieldNode) {
            StoreFieldNode storeFieldNode = (StoreFieldNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, storeFieldNode);
            ResolvedJavaField field = storeFieldNode.field();
            if (storeFieldNode.isStatic()) {
                ValueNode value = storeFieldNode.value();
                for (NodePlugin nodePlugin : nodePlugins) {
                    if (nodePlugin.handleStoreStaticField(graphBuilderContext, field, value)) {
                        replacedNode = graphBuilderContext.pushedNode;
                        break;
                    }
                }
            } else {
                ValueNode object = storeFieldNode.object();
                ValueNode value = storeFieldNode.value();
                for (NodePlugin nodePlugin : nodePlugins) {
                    if (nodePlugin.handleStoreField(graphBuilderContext, object, field, value)) {
                        replacedNode = graphBuilderContext.pushedNode;
                        break;
                    }
                }
            }
        } else if (node instanceof LoadIndexedNode) {
            LoadIndexedNode loadIndexedNode = (LoadIndexedNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadIndexedNode);
            ValueNode array = loadIndexedNode.array();
            ValueNode index = loadIndexedNode.index();
            for (NodePlugin nodePlugin : nodePlugins) {
                if (nodePlugin.handleLoadIndexed(graphBuilderContext, array, index, loadIndexedNode.elementKind())) {
                    replacedNode = graphBuilderContext.pushedNode;
                    break;
                }
            }
        } else if (node instanceof StoreIndexedNode) {
            StoreIndexedNode storeIndexedNode = (StoreIndexedNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, storeIndexedNode);
            ValueNode array = storeIndexedNode.array();
            ValueNode index = storeIndexedNode.index();
            ValueNode value = storeIndexedNode.value();
            for (NodePlugin nodePlugin : nodePlugins) {
                if (nodePlugin.handleStoreIndexed(graphBuilderContext, array, index, storeIndexedNode.elementKind(), value)) {
                    replacedNode = graphBuilderContext.pushedNode;
                    break;
                }
            }
        } else if (node instanceof NewInstanceNode) {
            NewInstanceNode newInstanceNode = (NewInstanceNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newInstanceNode);
            ResolvedJavaType type = newInstanceNode.instanceClass();
            for (NodePlugin nodePlugin : nodePlugins) {
                if (nodePlugin.handleNewInstance(graphBuilderContext, type)) {
                    replacedNode = graphBuilderContext.pushedNode;
                    break;
                }
            }
        } else if (node instanceof NewArrayNode) {
            NewArrayNode newArrayNode = (NewArrayNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newArrayNode);
            ResolvedJavaType elementType = newArrayNode.elementType();
            ValueNode length = newArrayNode.length();
            for (NodePlugin nodePlugin : nodePlugins) {
                if (nodePlugin.handleNewArray(graphBuilderContext, elementType, length)) {
                    replacedNode = graphBuilderContext.pushedNode;
                    break;
                }
            }
        } else if (node instanceof NewMultiArrayNode) {
            NewMultiArrayNode newArrayNode = (NewMultiArrayNode) node;
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newArrayNode);
            ResolvedJavaType elementType = newArrayNode.type();
            ValueNode[] dimensions = newArrayNode.dimensions().toArray(new ValueNode[0]);
            for (NodePlugin nodePlugin : nodePlugins) {
                if (nodePlugin.handleNewMultiArray(graphBuilderContext, elementType, dimensions)) {
                    replacedNode = graphBuilderContext.pushedNode;
                    break;
                }
            }
        }
    }
    return super.canonicalizeFixedNode(methodScope, replacedNode);
}
Also used : StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Aggregations

NodePlugin (org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin)13 ValueNode (org.graalvm.compiler.nodes.ValueNode)11 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)7 FrameState (org.graalvm.compiler.nodes.FrameState)5 ClassInitializationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin)5 JavaType (jdk.vm.ci.meta.JavaType)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)4 RuntimeConstraint (jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint)3 JavaTypeProfile (jdk.vm.ci.meta.JavaTypeProfile)2 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)2 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)2 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)2 JavaKind (jdk.vm.ci.meta.JavaKind)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Node (org.graalvm.compiler.graph.Node)1 BciBlock (org.graalvm.compiler.java.BciBlockMapping.BciBlock)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1