From 8f1ae7e7df912ee967739994c4266d61d7c682dd Mon Sep 17 00:00:00 2001 From: Marc Miltenberger Date: Wed, 22 Nov 2023 20:35:13 +0100 Subject: [PATCH 1/2] Replace some more numbered maps --- .../jimple/spark/internal/TypeManager.java | 7 +++-- .../soot/jimple/spark/solver/PropAlias.java | 7 ++--- .../soot/jimple/spark/solver/PropCycle.java | 7 ++--- .../callgraph/OnFlyCallGraphBuilder.java | 27 +++++++++---------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/main/java/soot/jimple/spark/internal/TypeManager.java b/src/main/java/soot/jimple/spark/internal/TypeManager.java index bdd048e48b1..29c1724d542 100644 --- a/src/main/java/soot/jimple/spark/internal/TypeManager.java +++ b/src/main/java/soot/jimple/spark/internal/TypeManager.java @@ -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; /** @@ -176,7 +175,7 @@ final public void clearTypeMask() { final public void makeTypeMask() { RefType.v("java.lang.Class"); - typeMask = new LargeNumberedMap(Scene.v().getTypeNumberer()); + typeMask = new HashMap(); if (fh == null) { return; } @@ -186,7 +185,7 @@ final public void makeTypeMask() { makeClassTypeMask(Scene.v().getSootClass(Scene.v().getObjectType().getClassName())); BitVector visitedTypes = new BitVector(); { - Iterator it = typeMask.keyIterator(); + Iterator it = typeMask.keySet().iterator(); while (it.hasNext()) { Type t = it.next(); visitedTypes.set(t.getNumber()); @@ -223,7 +222,7 @@ final public void makeTypeMask() { allocNodeListener = pag.allocNodeListener(); } - private LargeNumberedMap typeMask = null; + private Map typeMask = null; final public boolean castNeverFails(Type src, Type dst) { if (dst == null) { diff --git a/src/main/java/soot/jimple/spark/solver/PropAlias.java b/src/main/java/soot/jimple/spark/solver/PropAlias.java index 6e528bba71e..baebef9a972 100644 --- a/src/main/java/soot/jimple/spark/solver/PropAlias.java +++ b/src/main/java/soot/jimple/spark/solver/PropAlias.java @@ -23,6 +23,8 @@ */ import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -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; @@ -64,7 +65,7 @@ public class PropAlias extends Propagator { public PropAlias(PAG pag) { this.pag = pag; - loadSets = new LargeNumberedMap(pag.getFieldRefNodeNumberer()); + loadSets = new HashMap(); } /** Actually does the propagation. */ @@ -300,6 +301,6 @@ private boolean addToWorklist(VarNode n) { protected PAG pag; protected MultiMap fieldToBase = new HashMultiMap(); protected MultiMap aliasEdges = new HashMultiMap(); - protected LargeNumberedMap loadSets; + protected Map loadSets; protected OnFlyCallGraph ofcg; } diff --git a/src/main/java/soot/jimple/spark/solver/PropCycle.java b/src/main/java/soot/jimple/spark/solver/PropCycle.java index 866e4a53f5d..122c11bdf35 100644 --- a/src/main/java/soot/jimple/spark/solver/PropCycle.java +++ b/src/main/java/soot/jimple/spark/solver/PropCycle.java @@ -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; @@ -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. @@ -49,7 +50,7 @@ public class PropCycle extends Propagator { public PropCycle(PAG pag) { this.pag = pag; - varNodeToIteration = new LargeNumberedMap(pag.getVarNodeNumberer()); + varNodeToIteration = new HashMap(); } /** Actually does the propagation. */ @@ -163,5 +164,5 @@ public final void visit(Node n) { private PAG pag; private OnFlyCallGraph ofcg; private Integer currentIteration; - private final LargeNumberedMap varNodeToIteration; + private final Map varNodeToIteration; } diff --git a/src/main/java/soot/jimple/toolkits/callgraph/OnFlyCallGraphBuilder.java b/src/main/java/soot/jimple/toolkits/callgraph/OnFlyCallGraphBuilder.java index ee536af1887..5e80b4608a1 100644 --- a/src/main/java/soot/jimple/toolkits/callgraph/OnFlyCallGraphBuilder.java +++ b/src/main/java/soot/jimple/toolkits/callgraph/OnFlyCallGraphBuilder.java @@ -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; @@ -165,10 +163,10 @@ public class OnFlyCallGraphBuilder { // end type based reflection resolution protected final Map> receiverToSites; - protected final LargeNumberedMap> methodToReceivers; - protected final LargeNumberedMap> methodToInvokeBases; - protected final LargeNumberedMap> methodToInvokeArgs; - protected final LargeNumberedMap> methodToStringConstants; + protected final Map> methodToReceivers; + protected final Map> methodToInvokeBases; + protected final Map> methodToInvokeArgs; + protected final Map> methodToStringConstants; protected final Map> stringConstToSites; protected final HashSet analyzedMethods = new HashSet(); @@ -210,11 +208,10 @@ public OnFlyCallGraphBuilder(ContextManager cm, ReachableMethods rm, boolean app } { this.receiverToSites = new HashMap>(); - final IterableNumberer methodNumberer = sc.getMethodNumberer(); - this.methodToReceivers = new LargeNumberedMap>(methodNumberer); - this.methodToInvokeBases = new LargeNumberedMap>(methodNumberer); - this.methodToInvokeArgs = new LargeNumberedMap>(methodNumberer); - this.methodToStringConstants = new LargeNumberedMap>(methodNumberer); + this.methodToReceivers = new HashMap>(); + this.methodToInvokeBases = new HashMap>(); + this.methodToInvokeArgs = new HashMap>(); + this.methodToStringConstants = new HashMap>(); this.stringConstToSites = new HashMap>(); } @@ -257,19 +254,19 @@ public ContextManager getContextManager() { return cm; } - public LargeNumberedMap> methodToReceivers() { + public Map> methodToReceivers() { return methodToReceivers; } - public LargeNumberedMap> methodToInvokeArgs() { + public Map> methodToInvokeArgs() { return methodToInvokeArgs; } - public LargeNumberedMap> methodToInvokeBases() { + public Map> methodToInvokeBases() { return methodToInvokeBases; } - public LargeNumberedMap> methodToStringConstants() { + public Map> methodToStringConstants() { return methodToStringConstants; } From e5196cf2607f82cdb5fa63454b7b1df69033b818 Mon Sep 17 00:00:00 2001 From: Marc Miltenberger Date: Wed, 22 Nov 2023 20:38:34 +0100 Subject: [PATCH 2/2] Checkstyle --- src/main/java/soot/jimple/spark/solver/PropAlias.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/soot/jimple/spark/solver/PropAlias.java b/src/main/java/soot/jimple/spark/solver/PropAlias.java index baebef9a972..df5f8963cd6 100644 --- a/src/main/java/soot/jimple/spark/solver/PropAlias.java +++ b/src/main/java/soot/jimple/spark/solver/PropAlias.java @@ -22,8 +22,8 @@ * #L% */ -import java.util.HashSet; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet;