Search in sources :

Example 6 with NodePlugin

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

the class BytecodeParser method genNewObjectArray.

private void genNewObjectArray(int cpi) {
    JavaType type = lookupType(cpi, ANEWARRAY);
    if (!(type instanceof ResolvedJavaType)) {
        ValueNode length = frameState.pop(JavaKind.Int);
        handleUnresolvedNewObjectArray(type, length);
        return;
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) type;
    ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType.getArrayClass())) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedType.getArrayClass(), stateBefore);
    }
    ValueNode length = frameState.pop(JavaKind.Int);
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleNewArray(this, resolvedType, length)) {
            return;
        }
    }
    frameState.push(JavaKind.Object, append(createNewArray(resolvedType, length, true)));
}
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) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 7 with NodePlugin

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

the class BytecodeParser method genPutField.

private void genPutField(JavaField field, ValueNode value) {
    ValueNode receiver = emitExplicitExceptions(frameState.pop(JavaKind.Object));
    if (field instanceof ResolvedJavaField) {
        ResolvedJavaField resolvedField = (ResolvedJavaField) field;
        if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
            graph.recordField(resolvedField);
        }
        for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
            if (plugin.handleStoreField(this, receiver, resolvedField, value)) {
                return;
            }
        }
        if (resolvedField.isFinal() && method.isConstructor()) {
            finalBarrierRequired = true;
        }
        genStoreField(receiver, resolvedField, value);
    } else {
        handleUnresolvedStoreField(field, value, receiver);
    }
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 8 with NodePlugin

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

the class BytecodeParser method genInstanceOf.

private void genInstanceOf() {
    int cpi = getStream().readCPI();
    JavaType type = lookupType(cpi, INSTANCEOF);
    ValueNode object = frameState.pop(JavaKind.Object);
    if (!(type instanceof ResolvedJavaType)) {
        handleUnresolvedInstanceOf(type, object);
        return;
    }
    TypeReference resolvedType = TypeReference.createTrusted(graph.getAssumptions(), (ResolvedJavaType) type);
    JavaTypeProfile profile = getProfileForTypeCheck(resolvedType);
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleInstanceOf(this, object, resolvedType.getType(), profile)) {
            return;
        }
    }
    LogicNode instanceOfNode = null;
    if (profile != null) {
        if (profile.getNullSeen().isFalse()) {
            object = nullCheckedValue(object);
            ResolvedJavaType singleType = profile.asSingleType();
            if (singleType != null) {
                LogicNode typeCheck = append(createInstanceOf(TypeReference.createExactTrusted(singleType), object, profile));
                if (!typeCheck.isTautology()) {
                    append(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
                }
                instanceOfNode = LogicConstantNode.forBoolean(resolvedType.getType().isAssignableFrom(singleType));
            }
        }
    }
    if (instanceOfNode == null) {
        instanceOfNode = createInstanceOf(resolvedType, object, null);
    }
    LogicNode logicNode = genUnique(instanceOfNode);
    int next = getStream().nextBCI();
    int value = getStream().readUByte(next);
    if (next <= currentBlock.endBci && (value == Bytecodes.IFEQ || value == Bytecodes.IFNE)) {
        getStream().next();
        BciBlock firstSucc = currentBlock.getSuccessor(0);
        BciBlock secondSucc = currentBlock.getSuccessor(1);
        if (firstSucc != secondSucc) {
            boolean negate = value != Bytecodes.IFNE;
            if (negate) {
                BciBlock tmp = firstSucc;
                firstSucc = secondSucc;
                secondSucc = tmp;
            }
            genIf(instanceOfNode, firstSucc, secondSucc, getProfileProbability(negate));
        } else {
            appendGoto(firstSucc);
        }
    } else {
        // Most frequent for value is IRETURN, followed by ISTORE.
        frameState.push(JavaKind.Int, append(genConditional(logicNode)));
    }
}
Also used : FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) JavaTypeProfile(jdk.vm.ci.meta.JavaTypeProfile) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) TypeReference(org.graalvm.compiler.core.common.type.TypeReference) BciBlock(org.graalvm.compiler.java.BciBlockMapping.BciBlock) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 9 with NodePlugin

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

the class BytecodeParser method genLoadIndexed.

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

Example 10 with NodePlugin

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

the class BytecodeParser method genGetStatic.

private void genGetStatic(JavaField field) {
    ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, null);
    if (resolvedField == null) {
        return;
    }
    if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
        graph.recordField(resolvedField);
    }
    /*
         * Javac does not allow use of "$assertionsDisabled" for a field name but Eclipse does, in
         * which case a suffix is added to the generated field.
         */
    if ((parsingIntrinsic() || graphBuilderConfig.omitAssertions()) && resolvedField.isSynthetic() && resolvedField.getName().startsWith("$assertionsDisabled")) {
        frameState.push(field.getJavaKind(), ConstantNode.forBoolean(true, graph));
        return;
    }
    ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedField.getDeclaringClass())) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedField.getDeclaringClass(), stateBefore);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleLoadStaticField(this, resolvedField)) {
            return;
        }
    }
    frameState.push(field.getJavaKind(), append(genLoadField(null, resolvedField)));
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

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