Search in sources :

Example 36 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField 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 37 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField 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 38 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField in project graal by oracle.

the class BytecodeParser method genPutStatic.

protected void genPutStatic(JavaField field) {
    ValueNode value = frameState.pop(field.getJavaKind());
    ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, value);
    if (resolvedField == null) {
        return;
    }
    if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
        graph.recordField(resolvedField);
    }
    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.handleStoreStaticField(this, resolvedField, value)) {
            return;
        }
    }
    genStoreField(null, resolvedField, value);
}
Also used : 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) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 39 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField in project graal by oracle.

the class AnalysisUniverse method lookupAllowUnresolved.

@Override
public JavaField lookupAllowUnresolved(JavaField rawField) {
    if (rawField == null) {
        return null;
    }
    if (!(rawField instanceof ResolvedJavaField)) {
        return rawField;
    }
    assert !(rawField instanceof AnalysisField);
    ResolvedJavaField field = (ResolvedJavaField) rawField;
    if (!sealed) {
        /*
             * Lookup the field declaring class eagerly to trigger computation of automatic
             * substitutions. There might be an automatic substitution for the current field and we
             * want to register it before the analysis field is created.
             */
        lookup(field.getDeclaringClass());
    }
    field = substitutions.lookup(field);
    AnalysisField result = fields.get(field);
    if (result == null) {
        result = createField(field);
    }
    return result;
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 40 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField in project graal by oracle.

the class GraalObjectReplacer method apply.

@Override
public Object apply(Object source) {
    if (source == null) {
        return null;
    }
    Object dest = source;
    if (source instanceof RelocatedPointer) {
        return dest;
    }
    if (source instanceof MetaAccessProvider) {
        dest = sMetaAccess;
    } else if (source instanceof GraalRuntime) {
        dest = sGraalRuntime;
    } else if (source instanceof AnalysisConstantReflectionProvider) {
        dest = sConstantReflectionProvider;
    } else if (source instanceof AnalysisConstantFieldProvider) {
        dest = sConstantFieldProvider;
    } else if (source instanceof ForeignCallsProvider) {
        dest = GraalSupport.getRuntimeConfig().getProviders().getForeignCalls();
    } else if (source instanceof HostedSnippetReflectionProvider) {
        dest = GraalSupport.getRuntimeConfig().getSnippetReflection();
    } else if (shouldBeReplaced(source)) {
        /*
             * The hash maps must be synchronized, because replace() may be called from
             * BigBang.finish(), which is multi-threaded.
             */
        synchronized (this) {
            if (source instanceof ResolvedJavaMethod) {
                dest = createMethod((ResolvedJavaMethod) source);
            } else if (source instanceof ResolvedJavaField) {
                dest = createField((ResolvedJavaField) source);
            } else if (source instanceof ResolvedJavaType) {
                dest = createType((ResolvedJavaType) source);
            } else if (source instanceof Signature) {
                dest = createSignature((Signature) source);
            } else if (source instanceof FieldLocationIdentity) {
                dest = fieldLocationIdentities.get(source);
                if (dest == null) {
                    SubstrateField destField = (SubstrateField) apply(((FieldLocationIdentity) source).getField());
                    dest = new SubstrateFieldLocationIdentity(destField);
                    fieldLocationIdentities.put((FieldLocationIdentity) source, (FieldLocationIdentity) dest);
                }
            }
        }
    }
    assert dest != null;
    String className = dest.getClass().getName();
    assert !className.contains(".hotspot.") || className.contains(".svm.jtt.hotspot.") : "HotSpot object in image " + className;
    assert !className.contains(".analysis.meta.") : "Analysis meta object in image " + className;
    assert !className.contains(".hosted.meta.") : "Hosted meta object in image " + className;
    return dest;
}
Also used : ForeignCallsProvider(org.graalvm.compiler.core.common.spi.ForeignCallsProvider) AnalysisConstantReflectionProvider(com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider) AnalysisConstantFieldProvider(com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider) RelocatedPointer(org.graalvm.nativeimage.c.function.RelocatedPointer) SubstrateField(com.oracle.svm.graal.meta.SubstrateField) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) HostedSnippetReflectionProvider(com.oracle.svm.hosted.meta.HostedSnippetReflectionProvider) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) GraalRuntime(org.graalvm.compiler.api.runtime.GraalRuntime) SubstrateGraalRuntime(com.oracle.svm.graal.SubstrateGraalRuntime) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) SubstrateFieldLocationIdentity(com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity) SubstrateFieldLocationIdentity(com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity) Signature(jdk.vm.ci.meta.Signature) SubstrateSignature(com.oracle.svm.graal.meta.SubstrateSignature) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)45 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)10 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 ArrayList (java.util.ArrayList)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)4 Field (java.lang.reflect.Field)4 JavaKind (jdk.vm.ci.meta.JavaKind)4 Invoke (org.graalvm.compiler.nodes.Invoke)4 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)3 NodePlugin (org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin)3 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)3 LocationIdentity (org.graalvm.word.LocationIdentity)3 Delete (com.oracle.svm.core.annotate.Delete)2 Method (java.lang.reflect.Method)2 JavaField (jdk.vm.ci.meta.JavaField)2 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)2