Skip to content

Commit 3136574

Browse files
committed
Clean-up simplifier selection for points-to/reachability.
1 parent cce3830 commit 3136574

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public abstract class AbstractAnalysisEngine implements BigBang {
8080
protected final int maxConstantObjectsPerType;
8181
protected final boolean profileConstantObjects;
8282
protected final boolean optimizeReturnedParameter;
83+
protected final boolean useExperimentalReachabilityAnalysis;
8384

8485
protected final OptionValues options;
8586
protected final DebugContext debug;
@@ -124,6 +125,8 @@ public AbstractAnalysisEngine(OptionValues options, AnalysisUniverse universe, H
124125
maxConstantObjectsPerType = PointstoOptions.MaxConstantObjectsPerType.getValue(options);
125126
profileConstantObjects = PointstoOptions.ProfileConstantObjects.getValue(options);
126127
optimizeReturnedParameter = PointstoOptions.OptimizeReturnedParameter.getValue(options);
128+
useExperimentalReachabilityAnalysis = PointstoOptions.UseExperimentalReachabilityAnalysis.getValue(options);
129+
127130
this.snippetReflectionProvider = snippetReflectionProvider;
128131
this.constantReflectionProvider = constantReflectionProvider;
129132
this.wordTypes = wordTypes;
@@ -250,6 +253,11 @@ public boolean optimizeReturnedParameter() {
250253
return optimizeReturnedParameter;
251254
}
252255

256+
@Override
257+
public boolean isPointsToAnalysis() {
258+
return !useExperimentalReachabilityAnalysis;
259+
}
260+
253261
public void profileConstantObject(AnalysisType type) {
254262
if (profileConstantObjects) {
255263
PointsToAnalysis.ConstantObjectsProfiler.registerConstant(type);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public interface BigBang extends ReachabilityAnalysis {
6262

6363
UnsupportedFeatures getUnsupportedFeatures();
6464

65+
boolean isPointsToAnalysis();
66+
6567
/**
6668
* Checks if all user defined limitations such as the number of types are satisfied.
6769
*/

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ public Set<AnalysisMethod> getCallers() {
577577
/** Get the list of all invoke locations for this method, as inferred by the static analysis. */
578578
public abstract List<BytecodePosition> getInvokeLocations();
579579

580+
/** Get the node markers used to store per-node mappings to metadata for encoded nodes. */
581+
public abstract Iterable<EncodedGraph.EncodedNodeReference> getEncodedNodeReferences();
582+
580583
/**
581584
* Returns true if this method is a native entrypoint, i.e. it may be called from the host
582585
* environment.

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/PointsToAnalysisMethod.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.oracle.graal.pointsto.util.ConcurrentLightHashMap;
4444
import com.oracle.svm.common.meta.MultiMethod;
4545

46+
import jdk.graal.compiler.nodes.EncodedGraph;
4647
import jdk.vm.ci.code.BytecodePosition;
4748
import jdk.vm.ci.meta.JavaKind;
4849
import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -125,6 +126,11 @@ public static Object unwrapInvokeReason(Object reason) {
125126
return reason;
126127
}
127128

129+
@Override
130+
public Iterable<EncodedGraph.EncodedNodeReference> getEncodedNodeReferences() {
131+
return typeFlow.getMethodFlowsGraph().getNodeFlows().getKeys();
132+
}
133+
128134
@Override
129135
public List<BytecodePosition> getInvokeLocations() {
130136
List<BytecodePosition> locations = new ArrayList<>();

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.oracle.graal.pointsto.infrastructure.Universe;
4040
import com.oracle.graal.pointsto.meta.AnalysisMethod;
4141
import com.oracle.graal.pointsto.meta.AnalysisType;
42-
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
4342
import com.oracle.graal.pointsto.typestate.TypeState;
4443
import com.oracle.svm.util.ImageBuildStatistics;
4544

@@ -186,10 +185,6 @@ private static void reportNeverNullInstanceFields(BigBang bb) {
186185

187186
@SuppressWarnings("try")
188187
public final void applyResults(AnalysisMethod method) {
189-
var nodeReferences = method instanceof PointsToAnalysisMethod ptaMethod && ptaMethod.getTypeFlow().flowsGraphCreated()
190-
? ptaMethod.getTypeFlow().getMethodFlowsGraph().getNodeFlows().getKeys()
191-
: null;
192-
var debug = new DebugContext.Builder(bb.getOptions(), new GraalDebugHandlersFactory(bb.getSnippetReflectionProvider())).build();
193188

194189
if (method.analyzedInPriorLayer()) {
195190
/*
@@ -203,11 +198,15 @@ public final void applyResults(AnalysisMethod method) {
203198
return;
204199
}
205200

206-
var graph = method.decodeAnalyzedGraph(debug, nodeReferences);
207-
if (graph == null) {
201+
if (method.getAnalyzedGraph() == null) {
202+
/* Method was not analyzed, so there is nothing to strengthen. */
208203
return;
209204
}
210205

206+
var nodeReferences = method.getEncodedNodeReferences();
207+
var debug = new DebugContext.Builder(bb.getOptions(), new GraalDebugHandlersFactory(bb.getSnippetReflectionProvider())).build();
208+
var graph = method.decodeAnalyzedGraph(debug, nodeReferences);
209+
211210
preStrengthenGraphs(graph, method);
212211

213212
graph.resetDebug(debug);
@@ -225,6 +224,7 @@ public final void applyResults(AnalysisMethod method) {
225224

226225
postStrengthenGraphs(graph, method);
227226

227+
/* Preserve the strengthened graph in an encoded format. */
228228
method.setAnalyzedGraph(GraphEncoder.encodeSingleGraph(graph, AnalysisParsedGraph.HOST_ARCHITECTURE));
229229

230230
persistStrengthenGraph(method);
@@ -279,7 +279,7 @@ public class AnalysisStrengthenGraphsPhase extends BasePhase<CoreProviders> {
279279

280280
AnalysisStrengthenGraphsPhase(AnalysisMethod method, StructuredGraph graph) {
281281
ReachabilitySimplifier simplifier;
282-
if (method instanceof PointsToAnalysisMethod ptaMethod && ptaMethod.getTypeFlow().flowsGraphCreated()) {
282+
if (bb.isPointsToAnalysis()) {
283283
simplifier = new TypeFlowSimplifier(StrengthenGraphs.this, method, graph);
284284
} else {
285285
simplifier = new ReachabilitySimplifier(StrengthenGraphs.this, method, graph);

substratevm/src/com.oracle.graal.reachability/src/com/oracle/graal/reachability/ReachabilityAnalysisMethod.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import jdk.graal.compiler.debug.DebugContext;
4242
import jdk.graal.compiler.debug.GraalError;
43+
import jdk.graal.compiler.nodes.EncodedGraph;
4344
import jdk.graal.compiler.nodes.GraphEncoder;
4445
import jdk.graal.compiler.nodes.Invoke;
4546
import jdk.graal.compiler.nodes.StructuredGraph;
@@ -110,6 +111,11 @@ public List<BytecodePosition> getInvokeLocations() {
110111
return calledFrom;
111112
}
112113

114+
@Override
115+
public Iterable<EncodedGraph.EncodedNodeReference> getEncodedNodeReferences() {
116+
return null;
117+
}
118+
113119
public void addCaller(BytecodePosition bytecodePosition) {
114120
calledFrom.add(bytecodePosition);
115121
}

0 commit comments

Comments
 (0)