Search in sources :

Example 1 with FieldTypeStore

use of com.oracle.graal.pointsto.typestore.FieldTypeStore in project graal by oracle.

the class AnalysisObject method getInstanceFieldTypeStore.

protected final FieldTypeStore getInstanceFieldTypeStore(BigBang bb, AnalysisField field) {
    assert !Modifier.isStatic(field.getModifiers());
    assert bb != null && !bb.getUniverse().sealed();
    if (instanceFieldsTypeStore == null) {
        AnalysisField[] fields = type.getInstanceFields(true);
        INSTANCE_FIELD_TYPE_STORE_UPDATER.compareAndSet(this, null, new AtomicReferenceArray<>(fields.length));
    }
    FieldTypeStore fieldStore = instanceFieldsTypeStore.get(field.getPosition());
    if (fieldStore == null) {
        fieldStore = bb.analysisPolicy().createFieldTypeStore(this, field, bb.getUniverse());
        boolean result = instanceFieldsTypeStore.compareAndSet(field.getPosition(), null, fieldStore);
        if (result) {
            fieldStore.init(bb);
            // link the initial instance field flow to the field write flow
            field.getInitialInstanceFieldFlow().addUse(bb, fieldStore.writeFlow());
            // link the field read flow to the context insensitive instance field flow
            fieldStore.readFlow().addUse(bb, field.getInstanceFieldFlow());
        } else {
            fieldStore = instanceFieldsTypeStore.get(field.getPosition());
        }
    }
    return fieldStore;
}
Also used : AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) FieldTypeStore(com.oracle.graal.pointsto.typestore.FieldTypeStore)

Example 2 with FieldTypeStore

use of com.oracle.graal.pointsto.typestore.FieldTypeStore in project graal by oracle.

the class ContextSensitiveAnalysisObject method getReferencedObjects.

/**
 * Returns the list of referenced objects, i.e., field objects or array elements discovered by
 * the static analysis.
 *
 * Since this list is not updated during the analysis, for complete results this should only be
 * called when the base analysis has finished.
 */
public List<AnalysisObject> getReferencedObjects() {
    if (referencedObjects == null) {
        // TODO do we need to materialize the objects in a HashSet here, or could we just
        // iterate over them?
        HashSet<AnalysisObject> objectsSet = new HashSet<>();
        if (this.type().isArray()) {
            for (AnalysisObject object : arrayElementsTypeStore.readFlow().getState().objects()) {
                objectsSet.add(object);
            }
        } else {
            if (instanceFieldsTypeStore != null) {
                for (int i = 0; i < instanceFieldsTypeStore.length(); i++) {
                    FieldTypeStore fieldTypeStore = instanceFieldsTypeStore.get(i);
                    if (fieldTypeStore != null) {
                        FieldTypeFlow fieldFlow = ((UnifiedFieldTypeStore) fieldTypeStore).readWriteFlow();
                        if (!fieldFlow.getState().isUnknown()) {
                            /*
                                 * If the field state is unknown we don't process the state. Unknown
                                 * means that the state can contain any object of any type, but the
                                 * core analysis guarantees that there is no path on which the
                                 * objects of an unknown type state are converted to and used as
                                 * java objects; they are just used as data.
                                 */
                            for (AnalysisObject object : fieldFlow.getState().objects()) {
                                objectsSet.add(object);
                            }
                        }
                    }
                }
            }
        }
        referencedObjects = new ArrayList<>(objectsSet);
    }
    return referencedObjects;
}
Also used : FieldTypeFlow(com.oracle.graal.pointsto.flow.FieldTypeFlow) UnifiedFieldTypeStore(com.oracle.graal.pointsto.typestore.UnifiedFieldTypeStore) HashSet(java.util.HashSet) FieldTypeStore(com.oracle.graal.pointsto.typestore.FieldTypeStore) UnifiedFieldTypeStore(com.oracle.graal.pointsto.typestore.UnifiedFieldTypeStore)

Aggregations

FieldTypeStore (com.oracle.graal.pointsto.typestore.FieldTypeStore)2 FieldTypeFlow (com.oracle.graal.pointsto.flow.FieldTypeFlow)1 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)1 UnifiedFieldTypeStore (com.oracle.graal.pointsto.typestore.UnifiedFieldTypeStore)1 HashSet (java.util.HashSet)1