Search in sources :

Example 6 with FieldLocationIdentity

use of org.graalvm.compiler.nodes.FieldLocationIdentity 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

FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)6 LocationIdentity (org.graalvm.word.LocationIdentity)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 SubstrateFieldLocationIdentity (com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity)2 SubstrateField (com.oracle.svm.graal.meta.SubstrateField)2 SubstrateSignature (com.oracle.svm.graal.meta.SubstrateSignature)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)2 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)2 SubstrateGraalRuntime (com.oracle.svm.graal.SubstrateGraalRuntime)1 SubstrateMethod (com.oracle.svm.graal.meta.SubstrateMethod)1 SubstrateType (com.oracle.svm.graal.meta.SubstrateType)1 AnalysisConstantFieldProvider (com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider)1 AnalysisConstantReflectionProvider (com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider)1 HostedSnippetReflectionProvider (com.oracle.svm.hosted.meta.HostedSnippetReflectionProvider)1 List (java.util.List)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1