use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.
the class SpecialInvokeTypeFlow method updateReceiver.
protected void updateReceiver(BigBang bb, MethodFlowsGraph calleeFlows, AnalysisObject receiverObject) {
TypeState receiverTypeState = TypeState.forExactType(bb, receiverObject, false);
updateReceiver(bb, calleeFlows, receiverTypeState);
}
use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.
the class MethodTypeFlow method foldTypeFlow.
/**
* Get a type state containing the union of states over all the clones of the original flow.
*
* @param originalTypeFlow the original type flow
* @return the resulting type state object
*/
public TypeState foldTypeFlow(BigBang bb, TypeFlow<?> originalTypeFlow) {
if (originalTypeFlow == null) {
return null;
}
TypeState result = TypeState.forEmpty();
for (MethodFlowsGraph methodFlows : clonedMethodFlows.values()) {
TypeFlow<?> clonedTypeFlow = methodFlows.lookupCloneOf(bb, originalTypeFlow);
TypeState cloneState = clonedTypeFlow.getState();
/*
* Make a shallow copy of the clone state, i.e., only the types and not the concrete
* objects, so that the union operation doesn't merge the concrete objects with abstract
* objects.
*/
TypeState cloneStateCopy = TypeState.forContextInsensitiveTypeState(bb, cloneState);
result = TypeState.forUnion(bb, result, cloneStateCopy);
}
return result;
}
use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.
the class CloneTypeFlow method onObservedUpdate.
@Override
public void onObservedUpdate(BigBang bb) {
/* Only a clone should be updated */
assert this.isClone() && context != null;
/* The input state has changed, clone its objects. */
TypeState inputState = input.getState();
TypeState currentState = getState();
TypeState resultState;
if (inputState.isEmpty() || inputState.isNull()) {
/* Nothing to be cloned if the input state is not a concrete type state. */
resultState = inputState.forNonNull(bb);
} else {
resultState = inputState.typesStream().filter(t -> !currentState.containsType(t)).map(type -> TypeState.forClone(bb, source, cloneSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
assert !resultState.canBeNull();
}
/* Update the clone flow state. */
addState(bb, resultState);
}
use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.
the class CloneTypeFlow method update.
@Override
public void update(BigBang bb) {
assert this.isClone();
TypeState inputState = input.getState();
TypeState cloneState = this.getState();
for (AnalysisType type : inputState.types()) {
if (type.isArray()) {
/* The object array clones must also get the elements flows of the originals. */
for (AnalysisObject originalObject : inputState.objects(type)) {
if (originalObject.isPrimitiveArray() || originalObject.isEmptyObjectArrayConstant(bb)) {
/* Nothing to read from a primitive array or an empty array constant. */
continue;
}
ArrayElementsTypeFlow originalObjectElementsFlow = originalObject.getArrayElementsFlow(bb, false);
for (AnalysisObject cloneObject : cloneState.objects(type)) {
if (cloneObject.isPrimitiveArray() || cloneObject.isEmptyObjectArrayConstant(bb)) {
/* Cannot write to a primitive array or an empty array constant. */
continue;
}
ArrayElementsTypeFlow cloneObjectElementsFlow = cloneObject.getArrayElementsFlow(bb, true);
originalObjectElementsFlow.addUse(bb, cloneObjectElementsFlow);
}
}
} else {
/* The object clones must get field flows of the originals. */
for (AnalysisObject originalObject : inputState.objects(type)) {
/* Link all the field flows of the original to the clone. */
for (AnalysisField field : type.getInstanceFields(true)) {
FieldTypeFlow originalObjectFieldFlow = originalObject.getInstanceFieldFlow(bb, field, false);
for (AnalysisObject cloneObject : cloneState.objects(type)) {
FieldTypeFlow cloneObjectFieldFlow = cloneObject.getInstanceFieldFlow(bb, field, true);
originalObjectFieldFlow.addUse(bb, cloneObjectFieldFlow);
}
}
}
}
}
/* Element flows of array clones (if any) have been updated, update the uses. */
super.update(bb);
}
use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.
the class DynamicNewInstanceTypeFlow method onObservedUpdate.
@Override
public void onObservedUpdate(BigBang bb) {
/* Only a clone should be updated */
assert this.isClone();
/* The state of the new type provider has changed. */
TypeState newTypeState = newTypeFlow.getState();
TypeState currentTypeState = getState();
/* Generate a heap object for every new incoming type. */
TypeState resultState = newTypeState.typesStream().filter(t -> !currentTypeState.containsType(t)).map(type -> TypeState.forAllocation(bb, source, allocationSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
assert !resultState.canBeNull();
addState(bb, resultState);
}
Aggregations