Search in sources :

Example 1 with ClassInitializationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin 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 2 with ClassInitializationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin 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 3 with ClassInitializationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin 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 4 with ClassInitializationPlugin

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

Example 5 with ClassInitializationPlugin

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

the class BytecodeParser method genInvokeStatic.

void genInvokeStatic(JavaMethod target) {
    if (callTargetIsResolved(target)) {
        ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target;
        ResolvedJavaType holder = resolvedTarget.getDeclaringClass();
        if (!holder.isInitialized() && ResolveClassBeforeStaticInvoke.getValue(options)) {
            handleUnresolvedInvoke(target, InvokeKind.Static);
        } else {
            ValueNode classInit = null;
            ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
            if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedTarget.getDeclaringClass())) {
                FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
                classInit = classInitializationPlugin.apply(this, resolvedTarget.getDeclaringClass(), stateBefore);
            }
            ValueNode[] args = frameState.popArguments(resolvedTarget.getSignature().getParameterCount(false));
            Invoke invoke = appendInvoke(InvokeKind.Static, resolvedTarget, args);
            if (invoke != null) {
                invoke.setClassInit(classInit);
            }
        }
    } else {
        handleUnresolvedInvoke(target, InvokeKind.Static);
    }
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolveClassBeforeStaticInvoke(org.graalvm.compiler.core.common.GraalOptions.ResolveClassBeforeStaticInvoke) Invoke(org.graalvm.compiler.nodes.Invoke)

Aggregations

FrameState (org.graalvm.compiler.nodes.FrameState)6 ClassInitializationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin)6 NodePlugin (org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin)5 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)4 JavaType (jdk.vm.ci.meta.JavaType)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 RuntimeConstraint (jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolveClassBeforeStaticInvoke (org.graalvm.compiler.core.common.GraalOptions.ResolveClassBeforeStaticInvoke)1 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)1 Invoke (org.graalvm.compiler.nodes.Invoke)1