Search in sources :

Example 1 with SubstrateFieldLocationIdentity

use of com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity 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

SubstrateFieldLocationIdentity (com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity)1 SubstrateGraalRuntime (com.oracle.svm.graal.SubstrateGraalRuntime)1 SubstrateField (com.oracle.svm.graal.meta.SubstrateField)1 SubstrateSignature (com.oracle.svm.graal.meta.SubstrateSignature)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 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Signature (jdk.vm.ci.meta.Signature)1 GraalRuntime (org.graalvm.compiler.api.runtime.GraalRuntime)1 ForeignCallsProvider (org.graalvm.compiler.core.common.spi.ForeignCallsProvider)1 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)1 RelocatedPointer (org.graalvm.nativeimage.c.function.RelocatedPointer)1