Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some more numbered maps #2026

Merged
merged 2 commits into from
Nov 22, 2023
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
7 changes: 3 additions & 4 deletions src/main/java/soot/jimple/spark/internal/TypeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import soot.jimple.toolkits.typing.fast.WeakObjectType;
import soot.util.ArrayNumberer;
import soot.util.BitVector;
import soot.util.LargeNumberedMap;
import soot.util.queue.QueueReader;

/**
Expand Down Expand Up @@ -176,7 +175,7 @@ final public void clearTypeMask() {

final public void makeTypeMask() {
RefType.v("java.lang.Class");
typeMask = new LargeNumberedMap<Type, BitVector>(Scene.v().getTypeNumberer());
typeMask = new HashMap<Type, BitVector>();
if (fh == null) {
return;
}
Expand All @@ -186,7 +185,7 @@ final public void makeTypeMask() {
makeClassTypeMask(Scene.v().getSootClass(Scene.v().getObjectType().getClassName()));
BitVector visitedTypes = new BitVector();
{
Iterator<Type> it = typeMask.keyIterator();
Iterator<Type> it = typeMask.keySet().iterator();
while (it.hasNext()) {
Type t = it.next();
visitedTypes.set(t.getNumber());
Expand Down Expand Up @@ -223,7 +222,7 @@ final public void makeTypeMask() {
allocNodeListener = pag.allocNodeListener();
}

private LargeNumberedMap<Type, BitVector> typeMask = null;
private Map<Type, BitVector> typeMask = null;

final public boolean castNeverFails(Type src, Type dst) {
if (dst == null) {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/soot/jimple/spark/solver/PropAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* #L%
*/

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

Expand All @@ -45,7 +47,6 @@
import soot.jimple.spark.sets.P2SetVisitor;
import soot.jimple.spark.sets.PointsToSetInternal;
import soot.util.HashMultiMap;
import soot.util.LargeNumberedMap;
import soot.util.MultiMap;
import soot.util.queue.QueueReader;

Expand All @@ -64,7 +65,7 @@ public class PropAlias extends Propagator {

public PropAlias(PAG pag) {
this.pag = pag;
loadSets = new LargeNumberedMap<FieldRefNode, PointsToSetInternal>(pag.getFieldRefNodeNumberer());
loadSets = new HashMap<FieldRefNode, PointsToSetInternal>();
}

/** Actually does the propagation. */
Expand Down Expand Up @@ -300,6 +301,6 @@ private boolean addToWorklist(VarNode n) {
protected PAG pag;
protected MultiMap<SparkField, VarNode> fieldToBase = new HashMultiMap<SparkField, VarNode>();
protected MultiMap<FieldRefNode, FieldRefNode> aliasEdges = new HashMultiMap<FieldRefNode, FieldRefNode>();
protected LargeNumberedMap<FieldRefNode, PointsToSetInternal> loadSets;
protected Map<FieldRefNode, PointsToSetInternal> loadSets;
protected OnFlyCallGraph ofcg;
}
7 changes: 4 additions & 3 deletions src/main/java/soot/jimple/spark/solver/PropCycle.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -36,7 +38,6 @@
import soot.jimple.spark.pag.PAG;
import soot.jimple.spark.pag.VarNode;
import soot.jimple.spark.sets.P2SetVisitor;
import soot.util.LargeNumberedMap;

/**
* Propagates points-to sets using an on-line cycle detection algorithm based on Heintze and Tardieu, PLDI 2000.
Expand All @@ -49,7 +50,7 @@ public class PropCycle extends Propagator {

public PropCycle(PAG pag) {
this.pag = pag;
varNodeToIteration = new LargeNumberedMap<VarNode, Integer>(pag.getVarNodeNumberer());
varNodeToIteration = new HashMap<VarNode, Integer>();
}

/** Actually does the propagation. */
Expand Down Expand Up @@ -163,5 +164,5 @@ public final void visit(Node n) {
private PAG pag;
private OnFlyCallGraph ofcg;
private Integer currentIteration;
private final LargeNumberedMap<VarNode, Integer> varNodeToIteration;
private final Map<VarNode, Integer> varNodeToIteration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@
import soot.toolkits.graph.ExceptionalUnitGraph;
import soot.toolkits.graph.ExceptionalUnitGraphFactory;
import soot.util.HashMultiMap;
import soot.util.IterableNumberer;
import soot.util.LargeNumberedMap;
import soot.util.MultiMap;
import soot.util.NumberedString;
import soot.util.StringNumberer;
Expand Down Expand Up @@ -165,10 +163,10 @@ public class OnFlyCallGraphBuilder {

// end type based reflection resolution
protected final Map<Local, List<VirtualCallSite>> receiverToSites;
protected final LargeNumberedMap<SootMethod, List<Local>> methodToReceivers;
protected final LargeNumberedMap<SootMethod, List<Local>> methodToInvokeBases;
protected final LargeNumberedMap<SootMethod, List<Local>> methodToInvokeArgs;
protected final LargeNumberedMap<SootMethod, List<Local>> methodToStringConstants;
protected final Map<SootMethod, List<Local>> methodToReceivers;
protected final Map<SootMethod, List<Local>> methodToInvokeBases;
protected final Map<SootMethod, List<Local>> methodToInvokeArgs;
protected final Map<SootMethod, List<Local>> methodToStringConstants;
protected final Map<Local, List<VirtualCallSite>> stringConstToSites;

protected final HashSet<SootMethod> analyzedMethods = new HashSet<SootMethod>();
Expand Down Expand Up @@ -210,11 +208,10 @@ public OnFlyCallGraphBuilder(ContextManager cm, ReachableMethods rm, boolean app
}
{
this.receiverToSites = new HashMap<Local, List<VirtualCallSite>>();
final IterableNumberer<SootMethod> methodNumberer = sc.getMethodNumberer();
this.methodToReceivers = new LargeNumberedMap<SootMethod, List<Local>>(methodNumberer);
this.methodToInvokeBases = new LargeNumberedMap<SootMethod, List<Local>>(methodNumberer);
this.methodToInvokeArgs = new LargeNumberedMap<SootMethod, List<Local>>(methodNumberer);
this.methodToStringConstants = new LargeNumberedMap<SootMethod, List<Local>>(methodNumberer);
this.methodToReceivers = new HashMap<SootMethod, List<Local>>();
this.methodToInvokeBases = new HashMap<SootMethod, List<Local>>();
this.methodToInvokeArgs = new HashMap<SootMethod, List<Local>>();
this.methodToStringConstants = new HashMap<SootMethod, List<Local>>();
this.stringConstToSites = new HashMap<Local, List<VirtualCallSite>>();
}

Expand Down Expand Up @@ -257,19 +254,19 @@ public ContextManager getContextManager() {
return cm;
}

public LargeNumberedMap<SootMethod, List<Local>> methodToReceivers() {
public Map<SootMethod, List<Local>> methodToReceivers() {
return methodToReceivers;
}

public LargeNumberedMap<SootMethod, List<Local>> methodToInvokeArgs() {
public Map<SootMethod, List<Local>> methodToInvokeArgs() {
return methodToInvokeArgs;
}

public LargeNumberedMap<SootMethod, List<Local>> methodToInvokeBases() {
public Map<SootMethod, List<Local>> methodToInvokeBases() {
return methodToInvokeBases;
}

public LargeNumberedMap<SootMethod, List<Local>> methodToStringConstants() {
public Map<SootMethod, List<Local>> methodToStringConstants() {
return methodToStringConstants;
}

Expand Down
Loading