Skip to content

Commit e22b4da

Browse files
committed
[GR-58690] Typeflow.getState() cleanup
PullRequest: graal/18980
2 parents a9883bc + d557cf6 commit e22b4da

38 files changed

+167
-78
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/PointsToAnalysis.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ public void forceUnsafeUpdate(AnalysisField field) {
210210
* update; an update of the receiver object flow will trigger an updated of the
211211
* observers, i.e., of the unsafe load.
212212
*/
213-
this.postFlow(unsafeLoad.receiver());
213+
if (unsafeLoad.receiver().isFlowEnabled()) {
214+
this.postFlow(unsafeLoad.receiver());
215+
}
214216
}
215217

216218
// force update of the unsafe stores
@@ -223,7 +225,9 @@ public void forceUnsafeUpdate(AnalysisField field) {
223225
* update; an update of the receiver object flow will trigger an updated of the
224226
* observers, i.e., of the unsafe store.
225227
*/
226-
this.postFlow(unsafeStore.receiver());
228+
if (unsafeStore.receiver().isFlowEnabled()) {
229+
this.postFlow(unsafeStore.receiver());
230+
}
227231
}
228232
}
229233

@@ -563,6 +567,7 @@ public interface TypeFlowRunnable extends DebugContextRunnable {
563567
}
564568

565569
public void postFlow(final TypeFlow<?> operation) {
570+
assert operation.isFlowEnabled() : "Only enabled flows should be updated: " + operation;
566571
if (operation.inQueue) {
567572
return;
568573
}
@@ -766,7 +771,8 @@ public void addCompleted(DebugContextRunnable r, long nanos) {
766771
TypeFlow<?> tf = ((TypeFlowRunnable) r).getTypeFlow();
767772
String source = String.valueOf(tf.getSource());
768773
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()),
769-
System.identityHashCode(tf), source, PointsToStats.asString(tf.getState()), System.identityHashCode(tf.getState()), tf.getUses().size(), tf.getObservers().size());
774+
System.identityHashCode(tf), source, PointsToStats.asString(tf.getRawState()), System.identityHashCode(tf.getRawState()), tf.getUses().size(),
775+
tf.getObservers().size());
770776
}
771777
}
772778

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/AbstractSpecialInvokeTypeFlow.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ protected AbstractSpecialInvokeTypeFlow(PointsToAnalysis bb, MethodFlowsGraph me
4747

4848
@Override
4949
protected void onFlowEnabled(PointsToAnalysis bb) {
50-
bb.postTask(() -> onObservedUpdate(bb));
50+
if (getReceiver().isFlowEnabled()) {
51+
bb.postTask(() -> onObservedUpdate(bb));
52+
}
5153
}
5254

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

7274
@Override
7375
public String toString() {
74-
return "SpecialInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
76+
return "SpecialInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
7577
}
7678

7779
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/AbstractStaticInvokeTypeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ protected AbstractStaticInvokeTypeFlow(PointsToAnalysis bb, MethodFlowsGraph met
4343

4444
@Override
4545
public String toString() {
46-
return "StaticInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
46+
return "StaticInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
4747
}
4848
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/AbstractVirtualInvokeTypeFlow.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public final boolean isDirectInvoke() {
8989

9090
@Override
9191
protected void onFlowEnabled(PointsToAnalysis bb) {
92-
bb.postTask(() -> onObservedUpdate(bb));
92+
if (getReceiver().isFlowEnabled()) {
93+
bb.postTask(() -> onObservedUpdate(bb));
94+
}
9395
}
9496

9597
@Override
@@ -129,6 +131,6 @@ public Collection<AnalysisMethod> getCalleesForReturnLinking() {
129131

130132
@Override
131133
public String toString() {
132-
return "VirtualInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();
134+
return "VirtualInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getStateDescription();
133135
}
134136
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/ActualParameterTypeFlow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
*/
2525
package com.oracle.graal.pointsto.flow;
2626

27-
import jdk.graal.compiler.nodes.ValueNode;
28-
2927
import com.oracle.graal.pointsto.meta.AnalysisType;
3028

29+
import jdk.graal.compiler.nodes.ValueNode;
30+
3131
/**
3232
* A sink type flow for the context insensitive invoke used to link in parameters in each caller
3333
* context.
@@ -39,6 +39,6 @@ public ActualParameterTypeFlow(AnalysisType declaredType) {
3939

4040
@Override
4141
public String toString() {
42-
return "ActualParameter<" + getState() + '>';
42+
return "ActualParameter<" + getStateDescription() + '>';
4343
}
4444
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/ActualReturnTypeFlow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met
5353

5454
@Override
5555
public String toString() {
56-
return "ActualReturn<" + getState() + '>';
56+
return "ActualReturn<" + getStateDescription() + '>';
5757
}
5858

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

7474
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/ArrayCopyTypeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ public TypeFlow<?> destination() {
141141

142142
@Override
143143
public String toString() {
144-
return "ArrayCopyTypeFlow<" + getState() + ">";
144+
return "ArrayCopyTypeFlow<" + getStateDescription() + ">";
145145
}
146146
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/ArrayElementsTypeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public AnalysisObject object() {
8585

8686
@Override
8787
public String toString() {
88-
return "MixedElementsFlow<" + source.getName() + "\n" + getState() + ">";
88+
return "MixedElementsFlow<" + source.getName() + "\n" + getStateDescription() + ">";
8989
}
9090

9191
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/BooleanPrimitiveCheckTypeFlow.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met
6161

6262
@Override
6363
public boolean addState(PointsToAnalysis bb, TypeState add) {
64-
return super.addState(bb, eval());
64+
return super.addState(bb, eval(bb));
6565
}
6666

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

7676
/**
7777
* Compares the type states of left and right.
7878
*
7979
* @return can be either empty, true, false, or any.
8080
*/
81-
public TypeState eval() {
82-
var leftState = left.isSaturated() ? TypeState.anyPrimitiveState() : left.getState();
83-
var rightState = right.isSaturated() ? TypeState.anyPrimitiveState() : right.getState();
81+
public TypeState eval(PointsToAnalysis bb) {
82+
var leftState = left.getOutputState(bb);
83+
var rightState = right.getOutputState(bb);
8484
if (leftState.isEmpty() || rightState.isEmpty()) {
8585
return TypeState.forEmpty();
8686
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/BoxTypeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph met
4646

4747
@Override
4848
public String toString() {
49-
return "BoxFlow<" + getState() + ">";
49+
return "BoxFlow<" + getStateDescription() + ">";
5050
}
5151

5252
}

0 commit comments

Comments
 (0)