Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ public void forceUnsafeUpdate(AnalysisField field) {
* update; an update of the receiver object flow will trigger an updated of the
* observers, i.e., of the unsafe load.
*/
this.postFlow(unsafeLoad.receiver());
if (unsafeLoad.receiver().isFlowEnabled()) {
this.postFlow(unsafeLoad.receiver());
}
}

// force update of the unsafe stores
Expand All @@ -223,7 +225,9 @@ public void forceUnsafeUpdate(AnalysisField field) {
* update; an update of the receiver object flow will trigger an updated of the
* observers, i.e., of the unsafe store.
*/
this.postFlow(unsafeStore.receiver());
if (unsafeStore.receiver().isFlowEnabled()) {
this.postFlow(unsafeStore.receiver());
}
}
}

Expand Down Expand Up @@ -563,6 +567,7 @@ public interface TypeFlowRunnable extends DebugContextRunnable {
}

public void postFlow(final TypeFlow<?> operation) {
assert operation.isFlowEnabled() : "Only enabled flows should be updated: " + operation;
if (operation.inQueue) {
return;
}
Expand Down Expand Up @@ -766,7 +771,8 @@ public void addCompleted(DebugContextRunnable r, long nanos) {
TypeFlow<?> tf = ((TypeFlowRunnable) r).getTypeFlow();
String source = String.valueOf(tf.getSource());
System.out.format("LONG RUNNING %.2f %s %x %s state %s %x uses %d observers %d%n", (double) nanos / 1_000_000_000, ClassUtil.getUnqualifiedName(tf.getClass()),
System.identityHashCode(tf), source, PointsToStats.asString(tf.getState()), System.identityHashCode(tf.getState()), tf.getUses().size(), tf.getObservers().size());
System.identityHashCode(tf), source, PointsToStats.asString(tf.getRawState()), System.identityHashCode(tf.getRawState()), tf.getUses().size(),
tf.getObservers().size());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ protected AbstractSpecialInvokeTypeFlow(PointsToAnalysis bb, MethodFlowsGraph me

@Override
protected void onFlowEnabled(PointsToAnalysis bb) {
bb.postTask(() -> onObservedUpdate(bb));
if (getReceiver().isFlowEnabled()) {
bb.postTask(() -> onObservedUpdate(bb));
}
}

@Override
Expand All @@ -71,7 +73,7 @@ public void onObservedSaturated(PointsToAnalysis bb, TypeFlow<?> observed) {

@Override
public String toString() {
return "SpecialInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
return "SpecialInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ protected AbstractStaticInvokeTypeFlow(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public String toString() {
return "StaticInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
return "StaticInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public final boolean isDirectInvoke() {

@Override
protected void onFlowEnabled(PointsToAnalysis bb) {
bb.postTask(() -> onObservedUpdate(bb));
if (getReceiver().isFlowEnabled()) {
bb.postTask(() -> onObservedUpdate(bb));
}
}

@Override
Expand Down Expand Up @@ -129,6 +131,6 @@ public Collection<AnalysisMethod> getCalleesForReturnLinking() {

@Override
public String toString() {
return "VirtualInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
return "VirtualInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
*/
package com.oracle.graal.pointsto.flow;

import jdk.graal.compiler.nodes.ValueNode;

import com.oracle.graal.pointsto.meta.AnalysisType;

import jdk.graal.compiler.nodes.ValueNode;

/**
* A sink type flow for the context insensitive invoke used to link in parameters in each caller
* context.
Expand All @@ -39,6 +39,6 @@ public ActualParameterTypeFlow(AnalysisType declaredType) {

@Override
public String toString() {
return "ActualParameter<" + getState() + '>';
return "ActualParameter<" + getStateDescription() + '>';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public String toString() {
return "ActualReturn<" + getState() + '>';
return "ActualReturn<" + getStateDescription() + '>';
}

public void setInvokeFlow(InvokeTypeFlow invokeFlow) {
Expand All @@ -68,7 +68,7 @@ public InvokeTypeFlow invokeFlow() {
public String format(boolean withState, boolean withSource) {
return "Actual return of call to " + invokeFlow.targetMethod.format("%H.%n(%p)") +
(withSource ? " at " + formatSource() : "") +
(withState ? " with state <" + getState() + ">" : "");
(withState ? " with state <" + getStateDescription() + ">" : "");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ public TypeFlow<?> destination() {

@Override
public String toString() {
return "ArrayCopyTypeFlow<" + getState() + ">";
return "ArrayCopyTypeFlow<" + getStateDescription() + ">";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public AnalysisObject object() {

@Override
public String toString() {
return "MixedElementsFlow<" + source.getName() + "\n" + getState() + ">";
return "MixedElementsFlow<" + source.getName() + "\n" + getStateDescription() + ">";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public boolean addState(PointsToAnalysis bb, TypeState add) {
return super.addState(bb, eval());
return super.addState(bb, eval(bb));
}

@Override
Expand All @@ -70,17 +70,17 @@ protected void onInputSaturated(PointsToAnalysis bb, TypeFlow<?> input) {
* If an input saturated, it does not mean that the condition has to always saturate as
* well, e.g. Any == {5} will return {5}.
*/
super.addState(bb, eval());
super.addState(bb, eval(bb));
}

/**
* Compares the type states of left and right.
*
* @return can be either empty, true, false, or any.
*/
public TypeState eval() {
var leftState = left.isSaturated() ? TypeState.anyPrimitiveState() : left.getState();
var rightState = right.isSaturated() ? TypeState.anyPrimitiveState() : right.getState();
public TypeState eval(PointsToAnalysis bb) {
var leftState = left.getOutputState(bb);
var rightState = right.getOutputState(bb);
if (leftState.isEmpty() || rightState.isEmpty()) {
return TypeState.forEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public String toString() {
return "BoxFlow<" + getState() + ">";
return "BoxFlow<" + getStateDescription() + ">";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public TypeState foldTypeFlow(PointsToAnalysis bb, TypeFlow<?> originalTypeFlow)
}
if (originalTypeFlow instanceof FieldTypeFlow || originalTypeFlow instanceof ArrayElementsTypeFlow) {
// field and array flows are not call site sensitive and thus not cloneable
return originalTypeFlow.state;
return originalTypeFlow.getState();
}
TypeState result = TypeState.forEmpty();
for (MethodFlowsGraph methodFlows : clonedMethodFlows.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met
return new CloneTypeFlow(bb, this, methodFlows, allocContext);
}

@Override
protected void onFlowEnabled(PointsToAnalysis bb) {
if (input.isFlowEnabled()) {
bb.postTask(() -> onObservedUpdate(bb));
}
}

@Override
public void onObservedUpdate(PointsToAnalysis bb) {
if (!isFlowEnabled()) {
return;
}
/* The input state has changed, clone its objects. */
TypeState inputState = input.getState();

Expand All @@ -73,7 +83,7 @@ public void onObservedUpdate(PointsToAnalysis bb) {
* encapsulate the location of the cloning. From the point of view of the analysis a clone
* flow is a source.
*/
TypeState resultState = bb.analysisPolicy().cloneState(bb, state, inputState, source, allocationContext);
TypeState resultState = bb.analysisPolicy().cloneState(bb, getState(), inputState, source, allocationContext);

/* Update the clone flow state. */
addState(bb, resultState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,24 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public void onObservedUpdate(PointsToAnalysis bb) {
addState(bb, condition.getState());
addState(bb, condition.getOutputState(bb));
}

@Override
public void onObservedSaturated(PointsToAnalysis bb, TypeFlow<?> observed) {
/* If the condition is already saturated, merge both inputs. */
super.addState(bb, TypeState.forUnion(bb, trueValue.getState(), falseValue.getState()));
super.addState(bb, TypeState.forUnion(bb, trueValue.getOutputState(bb), falseValue.getOutputState(bb)));
}

@Override
public boolean addState(PointsToAnalysis bb, TypeState add) {
TypeState trueState = trueValue.getOutputState(bb);
TypeState falseState = falseValue.getOutputState(bb);
if (condition.isSaturated()) {
/* If the condition is already saturated, merge both inputs. */
return super.addState(bb, TypeState.forUnion(bb, trueValue.getState(), falseValue.getState()));
return super.addState(bb, TypeState.forUnion(bb, trueState, falseState));
}
var conditionValue = condition.getState();
var conditionValue = condition.getOutputState(bb);
if (conditionValue.isEmpty()) {
/* If the condition is empty, do not produce any output yet. */
return false;
Expand All @@ -94,11 +96,11 @@ public boolean addState(PointsToAnalysis bb, TypeState add) {
var canBeTrue = prim.canBeTrue();
var canBeFalse = prim.canBeFalse();
if (canBeTrue && !canBeFalse) {
return super.addState(bb, trueValue.getState());
return super.addState(bb, trueState);
} else if (!canBeTrue && canBeFalse) {
return super.addState(bb, falseValue.getState());
return super.addState(bb, falseState);
}
return super.addState(bb, TypeState.forUnion(bb, trueValue.getState(), falseValue.getState()));
return super.addState(bb, TypeState.forUnion(bb, trueState, falseState));
}
throw AnalysisError.shouldNotReachHere("Unexpected non-primitive type state of the condition: " + conditionValue + ", at flow " + this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ConstantPrimitiveSourceTypeFlow(BytecodePosition source, AnalysisType typ
}

public ConstantPrimitiveSourceTypeFlow(ConstantPrimitiveSourceTypeFlow original, MethodFlowsGraph methodFlows) {
super(original, methodFlows, original.getState());
super(original, methodFlows, original.getRawState());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public boolean needsInitialization() {

@Override
public String toString() {
return "ConstantFlow<" + getState() + ">";
return "ConstantFlow<" + getStateDescription() + ">";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean addState(PointsToAnalysis bb, TypeState add) {

@Override
public String toString() {
return "ContextInsensitiveFieldTypeFlow<" + source.format("%h.%n") + System.lineSeparator() + getState() + ">";
return "ContextInsensitiveFieldTypeFlow<" + source.format("%h.%n") + System.lineSeparator() + getStateDescription() + ">";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,21 @@ public boolean needsInitialization() {
return true;
}

@Override
protected void onFlowEnabled(PointsToAnalysis bb) {
if (newTypeFlow.isFlowEnabled()) {
bb.postTask(() -> onObservedUpdate(bb));
}
}

@Override
public void onObservedUpdate(PointsToAnalysis bb) {
if (!isFlowEnabled()) {
return;
}
/* The state of the new type provider has changed. */
TypeState newTypeState = newTypeFlow.getState();
TypeState updateState = bb.analysisPolicy().dynamicNewInstanceState(bb, state, newTypeState, source, allocationContext);
TypeState updateState = bb.analysisPolicy().dynamicNewInstanceState(bb, getState(), newTypeState, source, allocationContext);
addState(bb, updateState);
}

Expand All @@ -108,6 +118,6 @@ public boolean canSaturate() {

@Override
public String toString() {
return "DynamicNewInstanceFlow<" + getState() + ">";
return "DynamicNewInstanceFlow<" + getStateDescription() + ">";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public FieldFilterTypeFlow filterFlow(PointsToAnalysis bb) {

@Override
public String toString() {
return "FieldFlow<" + source.format("%h.%n") + System.lineSeparator() + getState() + ">";
return "FieldFlow<" + source.format("%h.%n") + System.lineSeparator() + getStateDescription() + ">";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public int position() {
public String format(boolean withState, boolean withSource) {
return "Parameter " + position + " of " + method().format("%H.%n(%p)") +
(withSource ? " at " + formatSource() : "") +
(withState ? " with state <" + getState() + ">" : "");
(withState ? " with state <" + getStateDescription() + ">" : "");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean addReceiverState(PointsToAnalysis bb, TypeState add) {
public String format(boolean withState, boolean withSource) {
return "Formal receiver of " + method().format("%H.%n(%p)") +
(withSource ? " at " + formatSource() : "") +
(withState ? " with state <" + getState() + ">" : "");
(withState ? " with state <" + getStateDescription() + ">" : "");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met
public String format(boolean withState, boolean withSource) {
return "Formal return from " + method().format("%H.%n(%p)") +
(withSource ? " at " + formatSource() : "") +
(withState ? " with state <" + getState() + ">" : "");
(withState ? " with state <" + getStateDescription() + ">" : "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public boolean needsInitialization() {

@Override
public String toString() {
return "LoadStaticFieldTypeFlow<" + getState() + ">";
return "LoadStaticFieldTypeFlow<" + getStateDescription() + ">";
}

}
Expand Down Expand Up @@ -163,7 +163,7 @@ protected void onSaturated() {

@Override
public String toString() {
return "LoadInstanceFieldTypeFlow<" + getState() + ">";
return "LoadInstanceFieldTypeFlow<" + getStateDescription() + ">";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met

@Override
public String toString() {
return "MergeTypeFlow<" + getState() + ">";
return "MergeTypeFlow<" + getStateDescription() + ">";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ public boolean isSaturated(@SuppressWarnings("unused") PointsToAnalysis bb, Type
* Return the type state of the original flow.
*/
public TypeState foldTypeFlow(@SuppressWarnings("unused") PointsToAnalysis bb, TypeFlow<?> originalTypeFlow) {
return originalTypeFlow == null ? null : originalTypeFlow.getState();
if (originalTypeFlow == null) {
return null;
}
assert !originalTypeFlow.isSaturated() : "Saturated flows should not be accessed here: " + originalTypeFlow;
return originalTypeFlow.getState();
}

/**
Expand Down
Loading