Skip to content

Commit 48b282d

Browse files
committed
Refactor TypeFlow init.
1 parent e7e6257 commit 48b282d

File tree

7 files changed

+31
-40
lines changed

7 files changed

+31
-40
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void forceUnsafeUpdate(AnalysisField field) {
181181
// force update of the unsafe loads
182182
for (AbstractUnsafeLoadTypeFlow unsafeLoad : unsafeLoads.keySet()) {
183183
/* Force update for unsafe accessed static fields. */
184-
unsafeLoad.initFlow(this);
184+
unsafeLoad.forceUpdate(this);
185185

186186
/*
187187
* Force update for unsafe accessed instance fields: post the receiver object flow for
@@ -194,7 +194,7 @@ public void forceUnsafeUpdate(AnalysisField field) {
194194
// force update of the unsafe stores
195195
for (AbstractUnsafeStoreTypeFlow unsafeStore : unsafeStores.keySet()) {
196196
/* Force update for unsafe accessed static fields. */
197-
unsafeStore.initFlow(this);
197+
unsafeStore.forceUpdate(this);
198198

199199
/*
200200
* Force update for unsafe accessed instance fields: post the receiver object flow for

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ protected AbstractStaticInvokeTypeFlow(PointsToAnalysis bb, MethodFlowsGraph met
4141
super(bb, methodFlows, original);
4242
}
4343

44+
@Override
45+
public void initFlow(PointsToAnalysis bb) {
46+
/* Trigger the update for static invokes, there is no receiver to trigger it. */
47+
bb.postFlow(this);
48+
}
49+
4450
@Override
4551
public String toString() {
4652
return "StaticInvoke<" + targetMethod.format("%h.%n") + ">" + ":" + getState();

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
import org.graalvm.compiler.nodes.EncodedGraph.EncodedNodeReference;
4242

4343
import com.oracle.graal.pointsto.PointsToAnalysis;
44-
import com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.AbstractUnsafeLoadTypeFlow;
45-
import com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.AbstractUnsafeStoreTypeFlow;
4644
import com.oracle.graal.pointsto.meta.AnalysisMethod;
4745
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
4846
import com.oracle.graal.pointsto.util.AnalysisError;
@@ -115,23 +113,11 @@ public <T extends TypeFlow<?>> T lookupCloneOf(@SuppressWarnings("unused") Point
115113

116114
public void init(final PointsToAnalysis bb) {
117115
for (TypeFlow<?> flow : flows()) {
118-
if (flow instanceof AbstractUnsafeLoadTypeFlow) {
119-
bb.registerUnsafeLoad((AbstractUnsafeLoadTypeFlow) flow);
120-
}
121-
if (flow instanceof AbstractUnsafeStoreTypeFlow) {
122-
bb.registerUnsafeStore((AbstractUnsafeStoreTypeFlow) flow);
123-
}
124-
125116
/*
126117
* Run initialization code for corner case type flows. This can be used to add link from
127118
* 'outside' into the graph.
128119
*/
129120
flow.initFlow(bb);
130-
131-
/* Trigger the update for static invokes, there is no receiver to trigger it. */
132-
if (flow instanceof AbstractStaticInvokeTypeFlow) {
133-
bb.postFlow(flow);
134-
}
135121
}
136122
}
137123

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ void linkCloneFlows(final PointsToAnalysis bb) {
210210
clone.addUse(bb, clonedUse);
211211
}
212212
}
213-
214-
if (clone instanceof AbstractStaticInvokeTypeFlow) {
215-
/* Trigger the update for static invokes, there is no receiver to trigger it. */
216-
AbstractStaticInvokeTypeFlow invokeFlow = (AbstractStaticInvokeTypeFlow) clone;
217-
bb.postFlow(invokeFlow);
218-
}
219213
}
220214
}
221215

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,17 @@ public abstract static class AbstractUnsafeLoadTypeFlow extends OffsetLoadTypeFl
152152
}
153153

154154
@Override
155-
public final AbstractUnsafeLoadTypeFlow copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
156-
AbstractUnsafeLoadTypeFlow copy = makeCopy(bb, methodFlows);
157-
// Register the unsafe load. It will be force-updated when new unsafe fields are
158-
// registered. Only the clones are registered since the original flows are not updated.
159-
bb.registerUnsafeLoad(copy);
160-
return copy;
155+
public void initFlow(PointsToAnalysis bb) {
156+
assert !bb.analysisPolicy().isContextSensitiveAnalysis() || this.isClone();
157+
/*
158+
* Register the unsafe load. It will be force-updated when new unsafe fields are
159+
* registered.
160+
*/
161+
bb.registerUnsafeLoad(this);
162+
forceUpdate(bb);
161163
}
162164

163-
protected abstract AbstractUnsafeLoadTypeFlow makeCopy(PointsToAnalysis bb, MethodFlowsGraph methodFlows);
164-
165-
@Override
166-
public void initFlow(PointsToAnalysis bb) {
165+
public void forceUpdate(PointsToAnalysis bb) {
167166
/*
168167
* Unsafe load type flow models unsafe reads from both instance and static fields. From
169168
* an analysis stand point for static fields the base doesn't matter. An unsafe load can
@@ -186,7 +185,7 @@ private UnsafeLoadTypeFlow(PointsToAnalysis bb, MethodFlowsGraph methodFlows, Un
186185
}
187186

188187
@Override
189-
public UnsafeLoadTypeFlow makeCopy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
188+
public AbstractUnsafeLoadTypeFlow copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
190189
return new UnsafeLoadTypeFlow(bb, methodFlows, this);
191190
}
192191

@@ -244,7 +243,7 @@ private UnsafePartitionLoadTypeFlow(PointsToAnalysis bb, MethodFlowsGraph method
244243
}
245244

246245
@Override
247-
public UnsafePartitionLoadTypeFlow makeCopy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
246+
public AbstractUnsafeLoadTypeFlow copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
248247
return new UnsafePartitionLoadTypeFlow(bb, methodFlows, this);
249248
}
250249

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,23 @@ public abstract static class AbstractUnsafeStoreTypeFlow extends OffsetStoreType
192192

193193
@Override
194194
public final AbstractUnsafeStoreTypeFlow copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
195-
AbstractUnsafeStoreTypeFlow copy = makeCopy(bb, methodFlows);
196-
// Register the unsafe store. It will be force-updated when new unsafe fields are
197-
// registered. Only the clones are registered since the original flows are not updated.
198-
bb.registerUnsafeStore(copy);
199-
return copy;
195+
return makeCopy(bb, methodFlows);
200196
}
201197

202198
protected abstract AbstractUnsafeStoreTypeFlow makeCopy(PointsToAnalysis bb, MethodFlowsGraph methodFlows);
203199

204200
@Override
205201
public void initFlow(PointsToAnalysis bb) {
202+
assert !bb.analysisPolicy().isContextSensitiveAnalysis() || this.isClone();
203+
/*
204+
* Register the unsafe store. It will be force-updated when new unsafe fields are
205+
* registered.
206+
*/
207+
bb.registerUnsafeStore(this);
208+
forceUpdate(bb);
209+
}
210+
211+
public void forceUpdate(PointsToAnalysis bb) {
206212
/*
207213
* Unsafe store type flow models unsafe writes to both instance and static fields. From
208214
* an analysis stand point for static fields the base doesn't matter. An unsafe store

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public TypeFlow<T> copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
180180
}
181181

182182
/**
183-
* Initialization code for some clone corner case type flows.
183+
* Initialization code for some type flow corner cases.
184184
*
185185
* @param bb
186186
*/

0 commit comments

Comments
 (0)