Search in sources :

Example 1 with TypeFlow

use of com.oracle.graal.pointsto.flow.TypeFlow in project graal by oracle.

the class AnalysisType method updateAssignableTypes.

public static void updateAssignableTypes(BigBang bb) {
    /*
         * Update the assignable-state for all types. So do not post any update operations before
         * the computation is finished, because update operations must not see any intermediate
         * state.
         */
    List<AnalysisType> allTypes = bb.getUniverse().getTypes();
    List<TypeFlow<?>> changedFlows = new ArrayList<>();
    Map<Integer, BitSet> newAssignableTypes = new HashMap<>();
    for (AnalysisType type : allTypes) {
        if (type.isInstantiated()) {
            int arrayDimension = 0;
            AnalysisType elementalType = type;
            while (elementalType.isArray()) {
                elementalType = elementalType.getComponentType();
                arrayDimension++;
            }
            addTypeToAssignableLists(type.getId(), elementalType, arrayDimension, newAssignableTypes, true, bb);
            if (arrayDimension > 0) {
                addTypeToAssignableLists(type.getId(), type, 0, newAssignableTypes, true, bb);
            }
            for (int i = 0; i < arrayDimension; i++) {
                addTypeToAssignableLists(type.getId(), bb.getObjectType(), i, newAssignableTypes, false, bb);
            }
            if (!elementalType.isPrimitive()) {
                addTypeToAssignableLists(type.getId(), bb.getObjectType(), arrayDimension, newAssignableTypes, false, bb);
            }
        }
    }
    for (AnalysisType type : allTypes) {
        if (type.assignableTypes != null) {
            TypeState assignableTypeState = TypeState.forNull();
            if (newAssignableTypes.get(type.getId()) != null) {
                BitSet assignableTypes = newAssignableTypes.get(type.getId());
                if (type.assignableTypes.getState().hasExactTypes(assignableTypes)) {
                    /* Avoid creation of the expensive type state. */
                    continue;
                }
                assignableTypeState = TypeState.forExactTypes(bb, newAssignableTypes.get(type.getId()), true);
            }
            updateFlow(bb, type.assignableTypes, assignableTypeState, changedFlows);
            updateFlow(bb, type.assignableTypesNonNull, assignableTypeState.forNonNull(bb), changedFlows);
        }
    }
    for (TypeFlow<?> changedFlow : changedFlows) {
        bb.postFlow(changedFlow);
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AllInstantiatedTypeFlow(com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow) TypeFlow(com.oracle.graal.pointsto.flow.TypeFlow)

Aggregations

AllInstantiatedTypeFlow (com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow)1 TypeFlow (com.oracle.graal.pointsto.flow.TypeFlow)1 TypeState (com.oracle.graal.pointsto.typestate.TypeState)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1