Search in sources :

Example 1 with UnifiedFieldTypeStore

use of com.oracle.graal.pointsto.typestore.UnifiedFieldTypeStore 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

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