Search in sources :

Example 1 with SubstrateType

use of com.oracle.svm.graal.meta.SubstrateType in project graal by oracle.

the class GraalObjectReplacer method registerImmutableObjects.

public void registerImmutableObjects(CompilationAccess access) {
    for (SubstrateMethod method : methods.values()) {
        access.registerAsImmutable(method);
        access.registerAsImmutable(method.getRawImplementations());
        access.registerAsImmutable(method.getEncodedLineNumberTable());
    }
    for (SubstrateField field : fields.values()) {
        access.registerAsImmutable(field);
    }
    for (FieldLocationIdentity fieldLocationIdentity : fieldLocationIdentities.values()) {
        access.registerAsImmutable(fieldLocationIdentity);
    }
    for (SubstrateType type : types.values()) {
        access.registerAsImmutable(type);
        access.registerAsImmutable(type.getRawInstanceFields());
    }
    for (SubstrateSignature signature : signatures.values()) {
        access.registerAsImmutable(signature);
        access.registerAsImmutable(signature.getRawParameterTypes());
    }
}
Also used : SubstrateMethod(com.oracle.svm.graal.meta.SubstrateMethod) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) SubstrateFieldLocationIdentity(com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity) SubstrateField(com.oracle.svm.graal.meta.SubstrateField) SubstrateType(com.oracle.svm.graal.meta.SubstrateType) SubstrateSignature(com.oracle.svm.graal.meta.SubstrateSignature)

Example 2 with SubstrateType

use of com.oracle.svm.graal.meta.SubstrateType in project graal by oracle.

the class GraalObjectReplacer method updateSubstrateDataAfterCompilation.

/**
 * Updates all relevant data from universe building. Object replacement is done during analysis.
 * Therefore all substrate VM related data has to be updated after building the substrate
 * universe.
 */
@SuppressWarnings("try")
public void updateSubstrateDataAfterCompilation(HostedUniverse hUniverse) {
    for (Map.Entry<AnalysisType, SubstrateType> entry : types.entrySet()) {
        AnalysisType aType = entry.getKey();
        SubstrateType sType = entry.getValue();
        if (!hUniverse.contains(aType)) {
            continue;
        }
        HostedType hType = hUniverse.lookup(aType);
        DynamicHub uniqueImplementation = null;
        if (hType.getUniqueConcreteImplementation() != null) {
            uniqueImplementation = hType.getUniqueConcreteImplementation().getHub();
        }
        sType.setTypeCheckData(hType.getInstanceOfFromTypeID(), hType.getInstanceOfNumTypeIDs(), uniqueImplementation);
        SubstrateField[] originalFields = sType.getInstanceFields(false);
        if (originalFields != null) {
            /*
                 * What we do here is just a reordering of the instance fields array. The fields
                 * array already contains all the fields, but in the order of the AnalysisType. As
                 * the UniverseBuilder reorders the fields, we re-construct the fields array in the
                 * order of the HostedType. The correct order is essential for materialization
                 * during deoptimization.
                 */
            SubstrateField[] newFields = createFields(hType);
            sType.setInstanceFields(newFields);
        }
    }
    for (Map.Entry<AnalysisField, SubstrateField> entry : fields.entrySet()) {
        AnalysisField aField = entry.getKey();
        SubstrateField sField = entry.getValue();
        HostedField hField = hUniverse.lookup(aField);
        sField.setSubstrateData(hField.getLocation(), hField.isAccessed(), hField.isWritten(), hField.getConstantValue());
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) HostedType(com.oracle.svm.hosted.meta.HostedType) HostedField(com.oracle.svm.hosted.meta.HostedField) DynamicHub(com.oracle.svm.core.hub.DynamicHub) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) SubstrateField(com.oracle.svm.graal.meta.SubstrateField) HashMap(java.util.HashMap) Map(java.util.Map) SubstrateType(com.oracle.svm.graal.meta.SubstrateType)

Example 3 with SubstrateType

use of com.oracle.svm.graal.meta.SubstrateType in project graal by oracle.

the class GraalObjectReplacer method createType.

public SubstrateType createType(JavaType original) {
    if (original == null) {
        return null;
    }
    AnalysisType aType;
    if (original instanceof AnalysisType) {
        aType = (AnalysisType) original;
    } else {
        aType = ((HostedType) original).getWrapped();
    }
    SubstrateType sType = types.get(aType);
    if (sType == null) {
        assert !(original instanceof HostedType) : "too late to create new type";
        DynamicHub hub = ((SVMHost) aUniverse.hostVM()).dynamicHub(aType);
        sType = new SubstrateType(aType.getJavaKind(), hub);
        types.put(aType, sType);
        hub.setMetaType(sType);
        sType.setInstanceFields(createFields(aType));
        createType(aType.getSuperclass());
        createType(aType.getComponentType());
        for (AnalysisType aInterface : aType.getInterfaces()) {
            createType(aInterface);
        }
    }
    return sType;
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) HostedType(com.oracle.svm.hosted.meta.HostedType) SVMHost(com.oracle.svm.hosted.SVMHost) DynamicHub(com.oracle.svm.core.hub.DynamicHub) SubstrateType(com.oracle.svm.graal.meta.SubstrateType)

Example 4 with SubstrateType

use of com.oracle.svm.graal.meta.SubstrateType in project graal by oracle.

the class GraalObjectReplacer method createSignature.

private SubstrateSignature createSignature(Signature original) {
    SubstrateSignature sSignature = signatures.get(original);
    if (sSignature == null) {
        sSignature = new SubstrateSignature();
        signatures.put(original, sSignature);
        SubstrateType[] parameterTypes = new SubstrateType[original.getParameterCount(false)];
        for (int index = 0; index < original.getParameterCount(false); index++) {
            parameterTypes[index] = createType(original.getParameterType(index, null));
        }
        /*
             * The links to other meta objects must be set after adding to the signatures to avoid
             * infinite recursion.
             */
        sSignature.setTypes(parameterTypes, createType(original.getReturnType(null)));
    }
    return sSignature;
}
Also used : SubstrateSignature(com.oracle.svm.graal.meta.SubstrateSignature) SubstrateType(com.oracle.svm.graal.meta.SubstrateType)

Aggregations

SubstrateType (com.oracle.svm.graal.meta.SubstrateType)4 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)2 DynamicHub (com.oracle.svm.core.hub.DynamicHub)2 SubstrateField (com.oracle.svm.graal.meta.SubstrateField)2 SubstrateSignature (com.oracle.svm.graal.meta.SubstrateSignature)2 HostedType (com.oracle.svm.hosted.meta.HostedType)2 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)1 SubstrateFieldLocationIdentity (com.oracle.svm.core.graal.nodes.SubstrateFieldLocationIdentity)1 SubstrateMethod (com.oracle.svm.graal.meta.SubstrateMethod)1 SVMHost (com.oracle.svm.hosted.SVMHost)1 HostedField (com.oracle.svm.hosted.meta.HostedField)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)1