Search in sources :

Example 1 with UnsupportedFeatureException

use of com.oracle.graal.pointsto.constraints.UnsupportedFeatureException in project graal by oracle.

the class ObjectScanner method scanMethod.

private void scanMethod(AnalysisMethod method) {
    try {
        StreamSupport.stream(method.getTypeFlow().getGraph().getNodes().spliterator(), false).filter(n -> n instanceof ConstantNode).forEach(n -> {
            ConstantNode cn = (ConstantNode) n;
            JavaConstant c = (JavaConstant) cn.getValue();
            if (c.getJavaKind() == JavaKind.Object) {
                scanConstant(c, method);
            }
        });
    } catch (UnsupportedFeatureException ex) {
        bb.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, ex.getMessage(), null, ex);
    }
}
Also used : IdentityHashMap(java.util.IdentityHashMap) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Deque(java.util.Deque) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) JavaConstant(jdk.vm.ci.meta.JavaConstant) JavaKind(jdk.vm.ci.meta.JavaKind) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) ArrayDeque(java.util.ArrayDeque) Comparator(java.util.Comparator) WordBase(org.graalvm.word.WordBase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 2 with UnsupportedFeatureException

use of com.oracle.graal.pointsto.constraints.UnsupportedFeatureException in project graal by oracle.

the class ObjectScanner method scanField.

/**
 * Scans the value of a field giving a receiver object.
 *
 * @param field the scanned field
 * @param receiver the receiver object
 * @param reason what triggered the scanning
 */
protected final void scanField(AnalysisField field, JavaConstant receiver, Object reason) {
    try {
        JavaConstant fieldValue = bb.getConstantReflectionProvider().readFieldValue(field, receiver);
        if (fieldValue.getJavaKind() == JavaKind.Object && bb.getHostVM().isRelocatedPointer(bb.getSnippetReflectionProvider().asObject(Object.class, fieldValue))) {
            forRelocatedPointerFieldValue(receiver, field, fieldValue);
        } else if (fieldValue.isNull()) {
            forNullFieldValue(receiver, field);
        } else if (fieldValue.getJavaKind() == JavaKind.Object) {
            if (receiver == null) {
                registerRoot(fieldValue, field);
            } else {
                propagateRoot(receiver, fieldValue);
            }
            /* Scan the field value. */
            scanConstant(fieldValue, reason);
            /* Process the field value. */
            forNonNullFieldValue(receiver, field, fieldValue);
        }
    } catch (UnsupportedFeatureException ex) {
        unsupportedFeature(field.format("%H.%n"), ex.getMessage(), reason);
    }
}
Also used : UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 3 with UnsupportedFeatureException

use of com.oracle.graal.pointsto.constraints.UnsupportedFeatureException in project graal by oracle.

the class Inflation method checkType.

private void checkType(AnalysisType type) {
    SVMHost svmHost = (SVMHost) hostVM;
    if (type.getJavaKind() == JavaKind.Object) {
        if (type.isArray() && (type.isInstantiated() || type.isInTypeCheck())) {
            svmHost.dynamicHub(type).getComponentHub().setArrayHub(svmHost.dynamicHub(type));
        }
        try {
            AnalysisType enclosingType = type.getEnclosingType();
            if (enclosingType != null) {
                svmHost.dynamicHub(type).setEnclosingClass(svmHost.dynamicHub(enclosingType));
            }
        } catch (UnsupportedFeatureException ex) {
            getUnsupportedFeatures().addMessage(type.toJavaName(true), null, ex.getMessage(), null, ex);
        }
        fillGenericInfo(type);
        fillInterfaces(type);
        /*
             * Support for Java annotations.
             */
        svmHost.dynamicHub(type).setAnnotationsEncoding(encodeAnnotations(metaAccess, type.getAnnotations(), svmHost.dynamicHub(type).getAnnotationsEncoding()));
        /*
             * Support for Java enumerations.
             */
        if (type.getSuperclass() != null && type.getSuperclass().equals(metaAccess.lookupJavaType(Enum.class)) && svmHost.dynamicHub(type).getEnumConstantsShared() == null) {
            /*
                 * We want to retrieve the enum constant array that is maintained as a private
                 * static field in the enumeration class. We do not want a copy because that would
                 * mean we have the array twice in the native image: as the static field, and in the
                 * enumConstant field of DynamicHub. The only way to get the original value is via a
                 * reflective field access, and we even have to guess the field name.
                 */
            AnalysisField found = null;
            for (AnalysisField f : type.getStaticFields()) {
                if (f.getName().endsWith("$VALUES")) {
                    if (found != null) {
                        throw shouldNotReachHere("Enumeration has more than one static field with enumeration values: " + type);
                    }
                    found = f;
                }
            }
            if (found == null) {
                throw shouldNotReachHere("Enumeration does not have static field with enumeration values: " + type);
            }
            AnalysisField field = found;
            // field.registerAsRead(null);
            Enum<?>[] enumConstants = (Enum[]) SubstrateObjectConstant.asObject(getConstantReflectionProvider().readFieldValue(field, null));
            assert enumConstants != null;
            svmHost.dynamicHub(type).setEnumConstants(enumConstants);
        }
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) SVMHost(com.oracle.svm.hosted.SVMHost) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField)

Example 4 with UnsupportedFeatureException

use of com.oracle.graal.pointsto.constraints.UnsupportedFeatureException in project graal by oracle.

the class AnnotationSubstitutionProcessor method lookup.

@Override
public ResolvedJavaType lookup(ResolvedJavaType type) {
    Delete deleteAnnotation = deleteAnnotations.get(type);
    if (deleteAnnotation != null) {
        throw new UnsupportedFeatureException(deleteErrorMessage(type, deleteAnnotation, true));
    }
    ResolvedJavaType substitution = typeSubstitutions.get(type);
    if (substitution != null) {
        return substitution;
    }
    return type;
}
Also used : Delete(com.oracle.svm.core.annotate.Delete) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 5 with UnsupportedFeatureException

use of com.oracle.graal.pointsto.constraints.UnsupportedFeatureException in project graal by oracle.

the class AnnotationSubstitutionProcessor method lookup.

@Override
public ResolvedJavaField lookup(ResolvedJavaField field) {
    Delete deleteAnnotation = deleteAnnotations.get(field);
    if (deleteAnnotation != null) {
        throw new UnsupportedFeatureException(deleteErrorMessage(field, deleteAnnotation, true));
    }
    ResolvedJavaField substitution = fieldSubstitutions.get(field);
    if (substitution != null) {
        return substitution;
    }
    return field;
}
Also used : Delete(com.oracle.svm.core.annotate.Delete) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Aggregations

UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)10 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 Delete (com.oracle.svm.core.annotate.Delete)3 JavaKind (jdk.vm.ci.meta.JavaKind)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)2 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)2 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 WordTypes (org.graalvm.compiler.word.WordTypes)2 AnalysisPolicy (com.oracle.graal.pointsto.AnalysisPolicy)1 SubstitutionProcessor (com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)1 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 TypeState (com.oracle.graal.pointsto.typestate.TypeState)1 Timer (com.oracle.graal.pointsto.util.Timer)1 StopTimer (com.oracle.graal.pointsto.util.Timer.StopTimer)1