Search in sources :

Example 1 with SnippetResolvedJavaMethod

use of org.graalvm.compiler.hotspot.SnippetResolvedJavaMethod 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 SnippetResolvedJavaMethod || source instanceof SnippetResolvedJavaType) {
        return source;
    }
    if (source instanceof MetaAccessProvider) {
        dest = providerReplacements.getMetaAccessProvider();
    } else if (source instanceof HotSpotJVMCIRuntime) {
        throw new UnsupportedFeatureException("HotSpotJVMCIRuntime should not appear in the image: " + source);
    } else if (source instanceof GraalHotSpotVMConfig) {
        throw new UnsupportedFeatureException("GraalHotSpotVMConfig should not appear in the image: " + source);
    } else if (source instanceof HotSpotBackendFactory) {
        HotSpotBackendFactory factory = (HotSpotBackendFactory) source;
        Architecture hostArch = HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getTarget().arch;
        if (!factory.getArchitecture().equals(hostArch.getClass())) {
            throw new UnsupportedFeatureException("Non-host archtecture HotSpotBackendFactory should not appear in the image: " + source);
        }
    } else if (source instanceof GraalRuntime) {
        dest = sGraalRuntime;
    } else if (source instanceof AnalysisConstantReflectionProvider) {
        dest = providerReplacements.getConstantReflectionProvider();
    } else if (source instanceof AnalysisConstantFieldProvider) {
        dest = providerReplacements.getConstantFieldProvider();
    } else if (source instanceof ForeignCallsProvider) {
        dest = providerReplacements.getForeignCallsProvider();
    } else if (source instanceof SnippetReflectionProvider) {
        dest = providerReplacements.getSnippetReflectionProvider();
    } else if (source instanceof MetricKey) {
        /* Ensure lazily initialized name fields are computed. */
        ((MetricKey) source).getName();
    } else if (source instanceof NodeClass) {
        /* Ensure lazily initialized shortName field is computed. */
        ((NodeClass<?>) source).shortName();
    } else if (source instanceof HotSpotResolvedJavaMethod) {
        throw new UnsupportedFeatureException(source.toString());
    } else if (source instanceof HotSpotResolvedJavaField) {
        throw new UnsupportedFeatureException(source.toString());
    } else if (source instanceof HotSpotResolvedJavaType) {
        throw new UnsupportedFeatureException(source.toString());
    } else if (source instanceof HotSpotSignature) {
        throw new UnsupportedFeatureException(source.toString());
    } else if (source instanceof HotSpotObjectConstant) {
        throw new UnsupportedFeatureException(source.toString());
    } else if (source instanceof ResolvedJavaMethod && !(source instanceof SubstrateMethod)) {
        dest = createMethod((ResolvedJavaMethod) source);
    } else if (source instanceof ResolvedJavaField && !(source instanceof SubstrateField)) {
        dest = createField((ResolvedJavaField) source);
    } else if (source instanceof ResolvedJavaType && !(source instanceof SubstrateType)) {
        dest = createType((ResolvedJavaType) source);
    } else if (source instanceof FieldLocationIdentity && !(source instanceof SubstrateFieldLocationIdentity)) {
        dest = createFieldLocationIdentity((FieldLocationIdentity) source);
    }
    assert dest != null;
    String className = dest.getClass().getName();
    assert SubstrateUtil.isBuildingLibgraal() || !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;
    assert !SubstrateUtil.isBuildingLibgraal() || !className.contains(".svm.hosted.snippets.") : "Hosted snippet object in image " + className;
    return dest;
}
Also used : HotSpotBackendFactory(org.graalvm.compiler.hotspot.HotSpotBackendFactory) ForeignCallsProvider(org.graalvm.compiler.core.common.spi.ForeignCallsProvider) AnalysisConstantReflectionProvider(com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider) HotSpotJVMCIRuntime(jdk.vm.ci.hotspot.HotSpotJVMCIRuntime) RelocatedPointer(org.graalvm.nativeimage.c.function.RelocatedPointer) SubstrateField(com.oracle.svm.graal.meta.SubstrateField) HotSpotObjectConstant(jdk.vm.ci.hotspot.HotSpotObjectConstant) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) SnippetResolvedJavaType(org.graalvm.compiler.hotspot.SnippetResolvedJavaType) HotSpotResolvedJavaType(jdk.vm.ci.hotspot.HotSpotResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) HotSpotResolvedJavaField(jdk.vm.ci.hotspot.HotSpotResolvedJavaField) SnippetResolvedJavaType(org.graalvm.compiler.hotspot.SnippetResolvedJavaType) NodeClass(org.graalvm.compiler.graph.NodeClass) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) MetricKey(org.graalvm.compiler.debug.MetricKey) SnippetResolvedJavaMethod(org.graalvm.compiler.hotspot.SnippetResolvedJavaMethod) HotSpotSignature(jdk.vm.ci.hotspot.HotSpotSignature) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) SubstrateType(com.oracle.svm.graal.meta.SubstrateType) SubstrateMethod(com.oracle.svm.graal.meta.SubstrateMethod) AnalysisConstantFieldProvider(com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) Architecture(jdk.vm.ci.code.Architecture) HotSpotResolvedJavaField(jdk.vm.ci.hotspot.HotSpotResolvedJavaField) 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) HotSpotResolvedJavaType(jdk.vm.ci.hotspot.HotSpotResolvedJavaType) SubstrateFieldLocationIdentity(com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) SnippetResolvedJavaMethod(org.graalvm.compiler.hotspot.SnippetResolvedJavaMethod) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 SubstrateFieldLocationIdentity (com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity)1 SubstrateGraalRuntime (com.oracle.svm.graal.SubstrateGraalRuntime)1 SubstrateField (com.oracle.svm.graal.meta.SubstrateField)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 Architecture (jdk.vm.ci.code.Architecture)1 HotSpotJVMCIRuntime (jdk.vm.ci.hotspot.HotSpotJVMCIRuntime)1 HotSpotObjectConstant (jdk.vm.ci.hotspot.HotSpotObjectConstant)1 HotSpotResolvedJavaField (jdk.vm.ci.hotspot.HotSpotResolvedJavaField)1 HotSpotResolvedJavaMethod (jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod)1 HotSpotResolvedJavaType (jdk.vm.ci.hotspot.HotSpotResolvedJavaType)1 HotSpotSignature (jdk.vm.ci.hotspot.HotSpotSignature)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 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)1