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 @@ -49,7 +49,7 @@ public class StandalonePointsToAnalysis extends PointsToAnalysis {

public StandalonePointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostVM hostVM, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, DebugContext debugContext, TimerCollection timerCollection) {
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, new UnsupportedFeatures(), debugContext, timerCollection, true);
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, new UnsupportedFeatures(), debugContext, timerCollection);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@
import java.util.List;
import java.util.function.Function;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugContext.Builder;
import jdk.graal.compiler.debug.DebugHandlersFactory;
import jdk.graal.compiler.debug.Indent;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.DeoptBciSupplier;
import jdk.graal.compiler.nodes.StateSplit;
import jdk.graal.compiler.nodes.ValueNode;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.printer.GraalDebugHandlersFactory;
import jdk.graal.compiler.word.WordTypes;
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.graal.pointsto.api.HostVM;
Expand All @@ -59,6 +47,18 @@
import com.oracle.graal.pointsto.util.TimerCollection;
import com.oracle.svm.common.meta.MultiMethod;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugContext.Builder;
import jdk.graal.compiler.debug.DebugHandlersFactory;
import jdk.graal.compiler.debug.Indent;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.DeoptBciSupplier;
import jdk.graal.compiler.nodes.StateSplit;
import jdk.graal.compiler.nodes.ValueNode;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.printer.GraalDebugHandlersFactory;
import jdk.graal.compiler.word.WordTypes;
import jdk.vm.ci.code.BytecodeFrame;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.ConstantReflectionProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
import java.util.List;
import java.util.function.Function;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugHandlersFactory;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;

import com.oracle.graal.pointsto.api.HostVM;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatures;
import com.oracle.graal.pointsto.meta.AnalysisField;
Expand All @@ -45,6 +39,11 @@
import com.oracle.graal.pointsto.util.CompletionExecutor;
import com.oracle.svm.common.meta.MultiMethod;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugHandlersFactory;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.word.WordTypes;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.ConstantReflectionProvider;

Expand Down Expand Up @@ -95,8 +94,6 @@ default HostedProviders getProviders(AnalysisMethod method) {

void runAnalysis(DebugContext debug, Function<AnalysisUniverse, Boolean> duringAnalysisAction) throws InterruptedException;

boolean strengthenGraalGraphs();

/** You can blacklist certain callees here. */
@SuppressWarnings("unused")
default boolean isCallAllowed(PointsToAnalysis bb, AnalysisMethod caller, AnalysisMethod target, BytecodePosition srcPosition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,12 @@ public abstract class PointsToAnalysis extends AbstractAnalysisEngine {

public final Timer typeFlowTimer;

private final boolean strengthenGraalGraphs;

@SuppressWarnings("this-escape")
public PointsToAnalysis(OptionValues options, AnalysisUniverse universe, HostVM hostVM, AnalysisMetaAccess metaAccess, SnippetReflectionProvider snippetReflectionProvider,
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, UnsupportedFeatures unsupportedFeatures, DebugContext debugContext, TimerCollection timerCollection,
boolean strengthenGraalGraphs) {
ConstantReflectionProvider constantReflectionProvider, WordTypes wordTypes, UnsupportedFeatures unsupportedFeatures, DebugContext debugContext, TimerCollection timerCollection) {
super(options, universe, hostVM, metaAccess, snippetReflectionProvider, constantReflectionProvider, wordTypes, unsupportedFeatures, debugContext, timerCollection);
this.typeFlowTimer = timerCollection.createTimer("(typeflow)");

this.strengthenGraalGraphs = strengthenGraalGraphs;

this.objectType = metaAccess.lookupJavaType(Object.class);
/*
* Make sure the all-instantiated type flow is created early. We do not have any
Expand Down Expand Up @@ -149,11 +144,6 @@ public void printTimerStatistics(PrintWriter out) {
StatisticsPrinter.printLast(out, "total_memory_bytes", analysisTimer.getTotalMemory());
}

@Override
public boolean strengthenGraalGraphs() {
return strengthenGraalGraphs;
}

public boolean trackTypeFlowInputs() {
return trackTypeFlowInputs;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,21 @@
import java.lang.reflect.Modifier;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.EconomicSet;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.EncodedGraph.EncodedNodeReference;

import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
import com.oracle.graal.pointsto.util.AnalysisError;

import jdk.vm.ci.code.BytecodePosition;
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.EncodedGraph.EncodedNodeReference;

public class MethodFlowsGraph implements MethodFlowsGraphInfo {
/**
Expand Down Expand Up @@ -76,14 +72,7 @@ public enum GraphKind {
protected FormalParamTypeFlow[] parameters;
protected List<TypeFlow<?>> miscEntryFlows;
protected EconomicMap<EncodedNodeReference, TypeFlow<?>> nodeFlows;
/*
* We keep a bci->flow mapping for instanceof and invoke flows since they are queried by the
* analysis results builder.
*/
protected EconomicSet<Object> nonUniqueBcis;
protected EconomicMap<Object, InstanceOfTypeFlow> instanceOfFlows;
protected EconomicMap<Object, InvokeTypeFlow> invokeFlows;

protected List<InvokeTypeFlow> invokeFlows;
protected FormalReturnTypeFlow returnFlow;

protected volatile boolean isLinearized;
Expand Down Expand Up @@ -214,13 +203,8 @@ private Iterator<TypeFlow<?>> flowsIterator() {
}
}
}
if (instanceOfFlows != null) {
for (var value : instanceOfFlows.getValues()) {
worklist.add(value);
}
}
if (invokeFlows != null) {
for (var value : invokeFlows.getValues()) {
for (var value : invokeFlows) {
worklist.add(value);
}
}
Expand Down Expand Up @@ -302,24 +286,12 @@ public TypeFlow<?>[] getParameters() {
return parameters;
}

public void addNodeFlow(PointsToAnalysis bb, Node node, TypeFlow<?> input) {
if (bb.strengthenGraalGraphs()) {
addNodeFlow(new EncodedNodeReference(node), input);
} else {
addMiscEntryFlow(input);
}
}

public void addNodeFlow(EncodedNodeReference key, TypeFlow<?> flow) {
public void addNodeFlow(Node node, TypeFlow<?> flow) {
assert flow != null && !(flow instanceof AllInstantiatedTypeFlow) : flow;
if (nodeFlows == null) {
nodeFlows = EconomicMap.create();
}
nodeFlows.put(key, flow);
}

public Collection<TypeFlow<?>> getMiscFlows() {
return miscEntryFlows == null ? Collections.emptyList() : miscEntryFlows;
nodeFlows.put(new EncodedNodeReference(node), flow);
}

public EconomicMap<EncodedNodeReference, TypeFlow<?>> getNodeFlows() {
Expand All @@ -342,58 +314,15 @@ public FormalReturnTypeFlow getReturnFlow() {
return this.returnFlow;
}

public EconomicMap<Object, InvokeTypeFlow> getInvokes() {
return invokeFlows == null ? EconomicMap.emptyMap() : invokeFlows;
public List<InvokeTypeFlow> getInvokes() {
return invokeFlows == null ? List.of() : invokeFlows;
}

public EconomicMap<Object, InstanceOfTypeFlow> getInstanceOfFlows() {
return instanceOfFlows == null ? EconomicMap.emptyMap() : instanceOfFlows;
}

void addInstanceOf(Object key, InstanceOfTypeFlow instanceOf) {
if (instanceOfFlows == null) {
instanceOfFlows = EconomicMap.create();
}
doAddFlow(key, instanceOf, instanceOfFlows);
}

void addInvoke(Object key, InvokeTypeFlow invokeTypeFlow) {
void addInvoke(InvokeTypeFlow invokeTypeFlow) {
if (invokeFlows == null) {
invokeFlows = EconomicMap.create();
}
doAddFlow(key, invokeTypeFlow, invokeFlows);
}

private <T extends TypeFlow<BytecodePosition>> void doAddFlow(Object key, T flow, EconomicMap<Object, T> map) {
assert map == instanceOfFlows || map == invokeFlows : "Keys of these maps must not be overlapping";
Object uniqueKey = key;
if ((nonUniqueBcis != null && nonUniqueBcis.contains(key)) || removeNonUnique(key, instanceOfFlows) || removeNonUnique(key, invokeFlows)) {
uniqueKey = new Object();
}
map.put(uniqueKey, flow);
}

private <T extends TypeFlow<BytecodePosition>> boolean removeNonUnique(Object key, EconomicMap<Object, T> map) {
if (map == null) {
return false;
}
T oldFlow = map.removeKey(key);
if (oldFlow != null) {
/*
* This can happen when Graal inlines jsr/ret routines and the inlined nodes share the
* same bci. Or for some invokes where the bytecode parser needs to insert a type check
* before the invoke. Remove the old bci->flow pairing and replace it with a
* uniqueKey->flow pairing.
*/
map.put(new Object(), oldFlow);
if (nonUniqueBcis == null) {
nonUniqueBcis = EconomicSet.create();
}
nonUniqueBcis.add(key);
return true;
} else {
return false;
invokeFlows = new ArrayList<>();
}
invokeFlows.add(invokeTypeFlow);
}

public boolean isLinearized() {
Expand All @@ -415,7 +344,7 @@ public List<MethodFlowsGraph> allNonStubCallers(PointsToAnalysis bb) {
List<MethodFlowsGraph> callers = new ArrayList<>();
for (AnalysisMethod caller : method.getCallers()) {
for (MethodFlowsGraph callerFlowGraph : PointsToAnalysis.assertPointsToAnalysisMethod(caller).getTypeFlow().getFlows()) {
for (InvokeTypeFlow callerInvoke : callerFlowGraph.getInvokes().getValues()) {
for (InvokeTypeFlow callerInvoke : callerFlowGraph.getInvokes()) {
InvokeTypeFlow invoke = callerInvoke;
if (InvokeTypeFlow.isContextInsensitiveVirtualInvoke(callerInvoke)) {
/* The invoke has been replaced by the context insensitive one. */
Expand Down Expand Up @@ -445,7 +374,7 @@ public List<MethodFlowsGraph> allNonStubCallers(PointsToAnalysis bb) {
* @return the InvokeTypeFlow object belonging to the caller that linked to this callee.
*/
public InvokeTypeFlow invokeFlow(MethodFlowsGraph callerFlowGraph, PointsToAnalysis bb) {
for (InvokeTypeFlow callerInvoke : callerFlowGraph.getInvokes().getValues()) {
for (InvokeTypeFlow callerInvoke : callerFlowGraph.getInvokes()) {
for (MethodFlowsGraph calleeFlowGraph : callerInvoke.getAllNonStubCalleesFlows(bb)) {
// 'this' method graph was found among the callees of an invoke flow in the caller
// method clone, hence we register return it
Expand Down Expand Up @@ -495,8 +424,6 @@ final void removeInternalFlows(PointsToAnalysis bb) {
miscEntryFlows = null;
nodeFlows = null;

nonUniqueBcis = null;
instanceOfFlows = null;
invokeFlows = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ private void cloneOriginalFlowsHelper(PointsToAnalysis bb, boolean isReclone) {
}

nodeFlows = lookupClonesOf(bb, originalFlowsGraph.nodeFlows);
instanceOfFlows = lookupClonesOf(bb, originalFlowsGraph.instanceOfFlows);
miscEntryFlows = lookupClonesOf(bb, originalFlowsGraph.miscEntryFlows);
invokeFlows = lookupClonesOf(bb, originalFlowsGraph.invokeFlows);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.util.Collections;
import java.util.List;

import org.graalvm.collections.EconomicMap;

import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException;
import com.oracle.graal.pointsto.flow.builder.TypeFlowGraphBuilder;
Expand Down Expand Up @@ -228,9 +226,9 @@ public Collection<MethodFlowsGraph> getFlows() {
return flowsGraph == null ? Collections.emptyList() : List.of(flowsGraph);
}

public EconomicMap<Object, InvokeTypeFlow> getInvokes() {
public List<InvokeTypeFlow> getInvokes() {
ensureFlowsGraphSealed();
return flowsGraph == null ? EconomicMap.emptyMap() : flowsGraph.getInvokes();
return flowsGraph == null ? List.of() : flowsGraph.getInvokes();
}

public TypeFlow<?> getParameter(int idx) {
Expand Down
Loading