Skip to content

Commit

Permalink
updates for upstream changes, modernized Atlas API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
benjholla committed Oct 7, 2018
1 parent 38376e7 commit 0f303cb
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 87 deletions.
8 changes: 4 additions & 4 deletions com.ensoftcorp.open.pointsto.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.ensoftcorp.open.pointsto.feature"
label="Points-to Toolbox"
version="3.3.0.qualifier"
version="3.3.7.qualifier"
provider-name="Ensoft Corp.">

<description url="https://ensoftcorp.github.io/points-to-toolbox/">
Expand Down Expand Up @@ -39,9 +39,9 @@ SOFTWARE.

<requires>
<import plugin="net.ontopia.utils" version="5.2.2" match="greaterOrEqual"/>
<import feature="com.ensoftcorp.open.jimple.commons.feature" version="3.3.0.qualifier"/>
<import feature="com.ensoftcorp.open.java.commons.feature" version="3.3.0.qualifier"/>
<import feature="com.ensoftcorp.open.commons.feature" version="3.3.0.qualifier"/>
<import feature="com.ensoftcorp.open.jimple.commons.feature" version="3.3.7.qualifier"/>
<import feature="com.ensoftcorp.open.java.commons.feature" version="3.3.7.qualifier"/>
<import feature="com.ensoftcorp.open.commons.feature" version="3.3.7.qualifier"/>
</requires>

<plugin
Expand Down
9 changes: 5 additions & 4 deletions com.ensoftcorp.open.pointsto/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Points-to Toolbox
Bundle-SymbolicName: com.ensoftcorp.open.pointsto;singleton:=true
Bundle-Version: 3.3.0.qualifier
Bundle-Version: 3.3.7.qualifier
Bundle-Vendor: EnSoft Corp.
Require-Bundle: net.ontopia.utils;bundle-version="5.2.2",
com.ensoftcorp.open.commons;bundle-version="3.3.0",
com.ensoftcorp.open.java.commons;bundle-version="3.3.0",
com.ensoftcorp.open.jimple.commons;bundle-version="3.3.0"
com.ensoftcorp.open.commons;bundle-version="3.3.7",
com.ensoftcorp.open.commons.ui;bundle-version="3.3.7",
com.ensoftcorp.open.java.commons;bundle-version="3.3.7",
com.ensoftcorp.open.jimple.commons;bundle-version="3.3.7"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.ensoftcorp.atlas.core.db.set.AtlasSet;
import com.ensoftcorp.atlas.core.query.Attr;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.open.java.commons.analysis.CommonQueries;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void dispose(){
}
isDisposed = true;
// remove the temporary attributes
AtlasSet<Node> addressedObjects = new AtlasHashSet<Node>(Common.universe().selectNode(POINTS_TO_SET).eval().nodes());
AtlasSet<Node> addressedObjects = new AtlasHashSet<Node>(Query.universe().selectNode(POINTS_TO_SET).eval().nodes());
while(!addressedObjects.isEmpty()){
Node addressedObject = addressedObjects.one();
addressedObject.removeAttr(POINTS_TO_SET);
Expand Down Expand Up @@ -132,7 +133,7 @@ public AtlasSet<Node> getAddressedNodes() {
if(isDisposed){
throw new RuntimeException("Points-to analysis was disposed.");
}
return new AtlasHashSet<Node>(Common.universe().selectNode(POINTS_TO_SET).eval().nodes());
return new AtlasHashSet<Node>(Query.universe().selectNode(POINTS_TO_SET).eval().nodes());
}

@Override
Expand Down Expand Up @@ -250,7 +251,7 @@ public Graph getInferredDataFlowGraph() {
private void seedFrontier() {
// set the first address (address 0) to be the null type
// technically there is no instantiation of null, but it can be useful to treat is as one
Node nullType = Common.universe().nodesTaggedWithAny(XCSG.Java.NullType).eval().nodes().getFirst();
Node nullType = Query.universe().nodes(XCSG.Java.NullType).eval().nodes().getFirst();
addressToInstantiation.put(NULL_TYPE_ADDRESS, nullType);
addressToType.put(NULL_TYPE_ADDRESS, nullType);

Expand All @@ -262,15 +263,15 @@ private void seedFrontier() {
// note: this set also includes null, but that case is explicitly handled in address creation
// so all null literals are represented with a single address id to save on space
// note: in source the instantiation for the enum constant is implied
Q specialInstantiations = Common.universe().nodesTaggedWithAny(XCSG.Java.EnumConstant);
Q specialInstantiations = Query.universe().nodes(XCSG.Java.EnumConstant);

// very expensive, and not really needed...
if(PointsToPreferences.isTrackPrimitivesEnabled()){
specialInstantiations = specialInstantiations.union(Common.universe().nodesTaggedWithAny(XCSG.Literal));
specialInstantiations = specialInstantiations.union(Query.universe().nodes(XCSG.Literal));
}

// create unique addresses for types of new statements and array instantiations
Q newRefs = Common.universe().nodesTaggedWithAny(XCSG.Instantiation, XCSG.ArrayInstantiation).union(specialInstantiations);
Q newRefs = Query.universe().nodes(XCSG.Instantiation, XCSG.ArrayInstantiation).union(specialInstantiations);
AtlasSet<Node> newRefNodes = newRefs.eval().nodes();
long newRefNodesSize = newRefNodes.size();
long newRefNodesSeeded = 0;
Expand Down Expand Up @@ -300,7 +301,7 @@ private void seedFrontier() {
if(PointsToPreferences.isArrayComponentTrackingEnabled() && statedType.hasAttr(Attr.Node.DIMENSION)){
Node arrayType = statedType;
int arrayDimension = (int) arrayType.getAttr(Attr.Node.DIMENSION);
Node arrayElementType = Common.universe().edgesTaggedWithAny(XCSG.ArrayElementType).successors(Common.toQ(arrayType)).eval().nodes().getFirst();
Node arrayElementType = Query.universe().edges(XCSG.ArrayElementType).successors(Common.toQ(arrayType)).eval().nodes().getFirst();
// the top dimension has already been addressed, so start at dimension minus 1
for(int i=arrayDimension-1; i>0; i--){
// map array dimension address to array dimension type
Expand Down Expand Up @@ -382,12 +383,12 @@ protected void runAnalysis() {

// create graphs and sets for resolving dynamic dispatches
AtlasHashSet<Node> dynamicCallsiteThisSet = AnalysisUtilities.getDynamicCallsiteThisSet(monitor);
Graph dfInvokeThisGraph = Common.resolve(monitor, Common.universe().edgesTaggedWithAny(XCSG.IdentityPassedTo)).eval();
Graph methodSignatureGraph = Common.resolve(monitor, Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction, XCSG.InvokedSignature)).eval();
Graph dfInvokeThisGraph = Common.resolve(monitor, Query.universe().edges(XCSG.IdentityPassedTo)).eval();
Graph methodSignatureGraph = Common.resolve(monitor, Query.universe().edges(XCSG.InvokedFunction, XCSG.InvokedSignature)).eval();

// create graphs for performing array analysis
Q arrayAccess = Common.universe().nodesTaggedWithAny(XCSG.ArrayAccess);
Q arrayIdentityFor = Common.universe().edgesTaggedWithAny(XCSG.ArrayIdentityFor);
Q arrayAccess = Query.universe().nodes(XCSG.ArrayAccess);
Q arrayIdentityFor = Query.universe().edges(XCSG.ArrayIdentityFor);
AtlasSet<Node> arrayReferences = arrayIdentityFor.predecessors(arrayAccess).eval().nodes();

// iteratively propagate points-to information until a fixed point is reached
Expand Down Expand Up @@ -568,8 +569,8 @@ private void updateArrayMemoryModels(Node arrayWrite) {
// add the AW addresses to the the array memory values set for the array REFW address
if(arrayMemoryModel.get(arrayWriteReferenceAddress).addAll(getPointsToSet(arrayWrite))){
// if new addresses were added to the array, propagate them to the corresponding reads
Q allArrayReads = Common.universe().nodesTaggedWithAny(XCSG.ArrayRead);
Q allArrayReadReferences = Common.universe().edgesTaggedWithAny(XCSG.ArrayIdentityFor).predecessors(allArrayReads);
Q allArrayReads = Query.universe().nodes(XCSG.ArrayRead);
Q allArrayReadReferences = Query.universe().edges(XCSG.ArrayIdentityFor).predecessors(allArrayReads);
for(Node arrayReadReference : allArrayReadReferences.eval().nodes()){
HashSet<Integer> arrayReadReferenceAddresses = getPointsToSet(arrayReadReference);
if(arrayReadReferenceAddresses.contains(arrayWriteReferenceAddress)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.ensoftcorp.atlas.core.db.set.AtlasSet;
import com.ensoftcorp.atlas.core.query.Attr;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.open.java.commons.analysis.CommonQueries;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void dispose(){
}
isDisposed = true;
// remove the temporary attributes
AtlasSet<Node> addressedObjects = new AtlasHashSet<Node>(Common.universe().selectNode(POINTS_TO_SET).eval().nodes());
AtlasSet<Node> addressedObjects = new AtlasHashSet<Node>(Query.universe().selectNode(POINTS_TO_SET).eval().nodes());
while(!addressedObjects.isEmpty()){
Node addressedObject = addressedObjects.one();
addressedObject.removeAttr(POINTS_TO_SET);
Expand Down Expand Up @@ -131,7 +132,7 @@ public AtlasSet<Node> getAddressedNodes() {
if(isDisposed){
throw new RuntimeException("Points-to analysis was disposed.");
}
return new AtlasHashSet<Node>(Common.universe().selectNode(POINTS_TO_SET).eval().nodes());
return new AtlasHashSet<Node>(Query.universe().selectNode(POINTS_TO_SET).eval().nodes());
}

@Override
Expand Down Expand Up @@ -249,17 +250,17 @@ public Graph getInferredDataFlowGraph() {
private void seedFrontier() {
// set the first address (address 0) to be the null type
// technically there is no instantiation of null, but it can be useful to treat is as one
Node nullType = Common.universe().nodesTaggedWithAny(XCSG.Java.NullType).eval().nodes().getFirst();
Node nullType = Query.universe().nodes(XCSG.Java.NullType).eval().nodes().getFirst();
addressToInstantiation.put(NULL_TYPE_ADDRESS, nullType);
addressToType.put(NULL_TYPE_ADDRESS, nullType);

// TODO: consider external root set objects

// note: enum constants are instantiated in jimple in the <clinit> method, but in source it is implied
// create unique addresses for types of new statements and array instantiations
Q newRefs = Common.universe().nodesTaggedWithAny(XCSG.Instantiation, XCSG.ArrayInstantiation);
Q newRefs = Query.universe().nodes(XCSG.Instantiation, XCSG.ArrayInstantiation);
if(PointsToPreferences.isTrackPrimitivesEnabled()){
Q literalInstantiations = Common.universe().nodesTaggedWithAny(XCSG.Literal);
Q literalInstantiations = Query.universe().nodes(XCSG.Literal);
newRefs = newRefs.union(literalInstantiations);
}

Expand Down Expand Up @@ -292,7 +293,7 @@ private void seedFrontier() {
if(PointsToPreferences.isArrayComponentTrackingEnabled() && statedType.hasAttr(Attr.Node.DIMENSION)){
Node arrayType = statedType;
int arrayDimension = (int) arrayType.getAttr(Attr.Node.DIMENSION);
Node arrayElementType = Common.universe().edgesTaggedWithAny(XCSG.ArrayElementType).successors(Common.toQ(arrayType)).eval().nodes().getFirst();
Node arrayElementType = Query.universe().edges(XCSG.ArrayElementType).successors(Common.toQ(arrayType)).eval().nodes().getFirst();
// the top dimension has already been addressed, so start at dimension minus 1
for(int i=arrayDimension-1; i>0; i--){
// map array dimension address to array dimension type
Expand Down Expand Up @@ -379,12 +380,12 @@ protected void runAnalysis() {

// create graphs and sets for resolving dynamic dispatches
AtlasHashSet<Node> dynamicCallsiteThisSet = AnalysisUtilities.getDynamicCallsiteThisSet(monitor);
Graph dfInvokeThisGraph = Common.resolve(monitor, Common.universe().edgesTaggedWithAny(XCSG.IdentityPassedTo)).eval();
Graph methodSignatureGraph = Common.resolve(monitor, Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction, XCSG.InvokedSignature)).eval();
Graph dfInvokeThisGraph = Common.resolve(monitor, Query.universe().edges(XCSG.IdentityPassedTo)).eval();
Graph methodSignatureGraph = Common.resolve(monitor, Query.universe().edges(XCSG.InvokedFunction, XCSG.InvokedSignature)).eval();

// create graphs for performing array analysis
Q arrayAccess = Common.universe().nodesTaggedWithAny(XCSG.ArrayAccess);
Q arrayIdentityFor = Common.universe().edgesTaggedWithAny(XCSG.ArrayIdentityFor);
Q arrayAccess = Query.universe().nodes(XCSG.ArrayAccess);
Q arrayIdentityFor = Query.universe().edges(XCSG.ArrayIdentityFor);
AtlasSet<Node> arrayReferences = arrayIdentityFor.predecessors(arrayAccess).eval().nodes();

// iteratively propagate points-to information until a fixed point is reached
Expand Down Expand Up @@ -537,8 +538,8 @@ private AtlasHashSet<Edge> modelPrimitiveInstantiationDataFlows() {
private AtlasHashSet<Edge> createDataFlowSummaryEdges(Q methods) {
AtlasHashSet<Edge> summaryEdges = new AtlasHashSet<Edge>();
for(Node method : methods.eval().nodes()){
Q parameters = Common.toQ(method).contained().nodesTaggedWithAny(XCSG.Parameter);
Q returnValues = Common.toQ(method).contained().nodesTaggedWithAny(XCSG.ReturnValue);
Q parameters = Common.toQ(method).contained().nodes(XCSG.Parameter);
Q returnValues = Common.toQ(method).contained().nodes(XCSG.ReturnValue);
for(Node parameter : parameters.eval().nodes()){
for(Node returnValue : returnValues.eval().nodes()){
Edge summaryEdge = Graph.U.createEdge(parameter, returnValue);
Expand Down Expand Up @@ -602,8 +603,8 @@ private void updateArrayMemoryModels(Node arrayWrite) {
// add the AW addresses to the the array memory values set for the array REFW address
if(arrayMemoryModel.get(arrayWriteReferenceAddress).addAll(getPointsToSet(arrayWrite))){
// if new addresses were added to the array, propagate them to the corresponding reads
Q allArrayReads = Common.universe().nodesTaggedWithAny(XCSG.ArrayRead);
Q allArrayReadReferences = Common.universe().edgesTaggedWithAny(XCSG.ArrayIdentityFor).predecessors(allArrayReads);
Q allArrayReads = Query.universe().nodes(XCSG.ArrayRead);
Q allArrayReadReferences = Query.universe().edges(XCSG.ArrayIdentityFor).predecessors(allArrayReads);
for(Node arrayReadReference : allArrayReadReferences.eval().nodes()){
HashSet<Integer> arrayReadReferenceAddresses = getPointsToSet(arrayReadReference);
if(arrayReadReferenceAddresses.contains(arrayWriteReferenceAddress)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.core.runtime.IProgressMonitor;

import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.open.commons.analysis.CommonQueries;
import com.ensoftcorp.open.commons.codemap.PrioritizedCodemapStage;
Expand Down Expand Up @@ -44,12 +44,12 @@ public void performIndexing(IProgressMonitor monitor) {
if(PointsToPreferences.isPointsToAnalysisEnabled()){
PointsTo pointsToAnalysis = null;
if(PointsToPreferences.isJavaPointsToAnalysisModeEnabled()){
if(!CommonQueries.isEmpty(Common.universe().nodes(XCSG.Language.Java))) {
if(!CommonQueries.isEmpty(Query.universe().nodes(XCSG.Language.Java))) {
pointsToAnalysis = new JavaPointsTo();
pointsToAnalysis.run();
}
} else if(PointsToPreferences.isJimplePointsToAnalysisModeEnabled()){
if(!CommonQueries.isEmpty(Common.universe().nodes(XCSG.Language.Jimple))) {
if(!CommonQueries.isEmpty(Query.universe().nodes(XCSG.Language.Jimple))) {
pointsToAnalysis = new JimplePointsTo();
pointsToAnalysis.run();
}
Expand All @@ -58,7 +58,7 @@ public void performIndexing(IProgressMonitor monitor) {
// make some graph enhancements
if(pointsToAnalysis != null) {
if(PointsToPreferences.isArrayComponentTrackingEnabled() && PointsToPreferences.isRewriteArrayComponentsEnabled()){
long numArrayComponents = Common.universe().nodesTaggedWithAny(XCSG.ArrayComponents).eval().nodes().size();
long numArrayComponents = Query.universe().nodes(XCSG.ArrayComponents).eval().nodes().size();
long numRewrittenArrayComponents = GraphEnhancements.rewriteArrayComponents(pointsToAnalysis);
if(PointsToPreferences.isGeneralLoggingEnabled()) Log.info("Rewrote " + numArrayComponents + " array components to " + numRewrittenArrayComponents + " array components.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.ensoftcorp.atlas.core.db.set.AtlasHashSet;
import com.ensoftcorp.atlas.core.db.set.AtlasSet;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.atlas.java.core.script.Common;

Expand Down Expand Up @@ -80,7 +81,7 @@ private static boolean isArrayMemoryModelAddress(Integer address) {
if(address == 0){
return true;
} else {
return !Common.universe().nodesTaggedWithAny((ARRAY_MEMORY_MODEL_PREFIX + address), NULL_ARRAY_MEMORY_MODEL)
return !Query.universe().nodes((ARRAY_MEMORY_MODEL_PREFIX + address), NULL_ARRAY_MEMORY_MODEL)
.eval().nodes().isEmpty();
}
}
Expand Down Expand Up @@ -152,7 +153,7 @@ public static AtlasSet<Node> getArrayMemoryModelAliases(Node arrayInstantiation)
if(tags.length == 0){
return new AtlasHashSet<Node>();
} else {
Q aliases = Common.universe().nodesTaggedWithAny(tags);
Q aliases = Query.universe().nodes(tags);
return new AtlasHashSet<Node>(aliases.eval().nodes());
}
}
Expand Down Expand Up @@ -207,7 +208,7 @@ public static Q getAliases(Node node){
if(tags.length == 0){
return Common.empty();
} else {
Q aliases = Common.universe().nodesTaggedWithAny(tags);
Q aliases = Query.universe().nodes(tags);
return aliases;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.ensoftcorp.atlas.core.highlight.Highlighter;
import com.ensoftcorp.atlas.core.markup.MarkupFromH;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.query.Query;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.script.FrontierStyledResult;
import com.ensoftcorp.atlas.core.script.StyledResult;
Expand Down Expand Up @@ -59,7 +60,7 @@ public FrontierStyledResult evaluate(IAtlasSelectionEvent event, int reverse, in
if(!useInferredDataFlow) {
aliasNodes.addAll(aliases.eval().nodes());
}
AtlasSet<Node> instantiations = aliases.nodesTaggedWithAny(XCSG.Instantiation, XCSG.ArrayInstantiation).eval().nodes();
AtlasSet<Node> instantiations = aliases.nodes(XCSG.Instantiation, XCSG.ArrayInstantiation).eval().nodes();
if(!instantiations.isEmpty()){
instantiationSet.addAll(instantiations);
} else {
Expand All @@ -70,10 +71,10 @@ public FrontierStyledResult evaluate(IAtlasSelectionEvent event, int reverse, in
Q inferredDF;
if(useInferredDataFlow) {
// this is easier to work with
inferredDF = Common.universe().edges(PointsToAnalysis.INFERRED_DATA_FLOW);
inferredDF = Query.universe().edges(PointsToAnalysis.INFERRED_DATA_FLOW);
} else {
// however if tagging was turned off we could fall back to inducing the edges from regular data flow
inferredDF = Common.toQ(aliasNodes).induce(Common.universe().edges(XCSG.DataFlow_Edge));
inferredDF = Common.toQ(aliasNodes).induce(Query.universe().edges(XCSG.DataFlow_Edge));
}

Q instantations = Common.toQ(instantiationSet);
Expand Down
Loading

0 comments on commit 0f303cb

Please sign in to comment.