From f239b540309f4fd092e4b51cde8821265faf5b72 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 22 Mar 2011 09:15:09 +0000 Subject: [PATCH] fix mistake....allocnodes are like disjoint heapregionnodes... create new class allocsitenode which is like allocsite from disjointness... hacked rcr file so it would compile with this change..unclear if it will work correctly --- .../Analysis/Disjoint/EffectsAnalysis.java | 5 +- Robust/src/Analysis/Pointer/AllocFactory.java | 80 +++++++++++++++++-- Robust/src/Analysis/Pointer/Pointer.java | 18 ++--- .../src/IR/Flat/RuntimeConflictResolver.java | 4 +- 4 files changed, 88 insertions(+), 19 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java index 42826e80..59a8ae97 100644 --- a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java +++ b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java @@ -7,6 +7,7 @@ import java.io.*; import IR.*; import IR.Flat.*; import Analysis.Pointer.Edge; +import Analysis.Pointer.AllocFactory.AllocNode; ///////////////////////////////////////////// // @@ -147,7 +148,7 @@ public class EffectsAnalysis { public void analyzeFlatFieldNode(Set sources, FieldDescriptor fld, FlatNode currentProgramPoint) { for (Edge edge:sources) { TaintSet taintSet = edge.getTaints(); - Alloc affectedAlloc = edge.getDst(); + Alloc affectedAlloc = edge.getDst().getAllocSite(); Effect effect = new Effect(affectedAlloc, Effect.read, fld); if (taintSet!=null) @@ -190,7 +191,7 @@ public class EffectsAnalysis { public void analyzeFlatSetFieldNode(Set dstedges, FieldDescriptor fld, FlatNode currentProgramPoint) { for (Edge edge:dstedges) { TaintSet taintSet = edge.getTaints(); - Alloc affectedAlloc = edge.getDst(); + Alloc affectedAlloc = edge.getDst().getAllocSite(); Effect effect = new Effect(affectedAlloc, Effect.write, fld); if (taintSet!=null) for (Taint taint:taintSet.getTaints()) { diff --git a/Robust/src/Analysis/Pointer/AllocFactory.java b/Robust/src/Analysis/Pointer/AllocFactory.java index 0e0ab7e6..ed997a9e 100644 --- a/Robust/src/Analysis/Pointer/AllocFactory.java +++ b/Robust/src/Analysis/Pointer/AllocFactory.java @@ -6,12 +6,14 @@ import IR.*; import IR.Flat.*; public class AllocFactory { - public static AllocNode dummyNode=new AllocNode(-1, null, false); + public static AllocSiteNode dummySite=new AllocSiteNode(-1, null); + public static AllocNode dummyNode=new AllocNode(-1, null, false, dummySite); - public static class AllocNode implements Alloc { + public static class AllocNode { int allocsite; boolean summary; FlatNew node; + AllocSiteNode as; public AllocNode(int allocsite, FlatNew node, boolean summary) { this.allocsite=allocsite; @@ -19,6 +21,17 @@ public class AllocFactory { this.node=node; } + public AllocNode(int allocsite, FlatNew node, boolean summary, AllocSiteNode as) { + this.allocsite=allocsite; + this.summary=summary; + this.node=node; + this.as=as; + } + + public AllocSiteNode getAllocSite() { + return as; + } + public TypeDescriptor getType() { return node.getType(); } @@ -47,10 +60,6 @@ public class AllocFactory { return false; } - public String toStringBrief() { - return getID(); - } - public String toString() { return getID(); } @@ -63,9 +72,56 @@ public class AllocFactory { } } + public static class AllocSiteNode implements Alloc { + int allocsite; + FlatNew node; + + public AllocSiteNode(int allocsite, FlatNew node) { + this.allocsite=allocsite; + this.node=node; + } + + public TypeDescriptor getType() { + return node.getType(); + } + + public FlatNew getFlatNew() { + return node; + } + + public int getUniqueAllocSiteID() { + return allocsite; + } + + public int hashCode() { + return allocsite; + } + + public boolean equals(Object o) { + if (o instanceof AllocSiteNode) { + AllocSiteNode an=(AllocSiteNode)o; + return (allocsite==an.allocsite); + } + return false; + } + + public String toStringBrief() { + return getID(); + } + + public String toString() { + return getID(); + } + + public String getID() { + return "N"+allocsite; + } + } + public AllocFactory(State state, TypeUtil typeUtil) { allocMap=new HashMap(); allocNodeMap=new HashMap(); + allocSiteMap=new HashMap(); this.typeUtil=typeUtil; ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.StringClass); TypeDescriptor stringtd=new TypeDescriptor(stringcd); @@ -87,6 +143,7 @@ public class AllocFactory { AllocNode key=new AllocNode(site, node, isSummary); if (!allocNodeMap.containsKey(key)) { allocNodeMap.put(key, key); + key.as=getAllocSite(key); return key; } else return allocNodeMap.get(key); @@ -97,12 +154,23 @@ public class AllocFactory { AllocNode key=new AllocNode(site, node.node, isSummary); if (!allocNodeMap.containsKey(key)) { allocNodeMap.put(key, key); + key.as=getAllocSite(key); return key; } else return allocNodeMap.get(key); } + public AllocSiteNode getAllocSite(AllocNode node) { + AllocSiteNode as=new AllocSiteNode(node.allocsite, node.node); + if (!allocSiteMap.containsKey(as)) { + allocSiteMap.put(as, as); + return as; + } else + return allocSiteMap.get(as); + } + HashMap allocNodeMap; + HashMap allocSiteMap; HashMap allocMap; TypeUtil typeUtil; int siteCounter=2; diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index dd0c943f..4666894a 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -444,7 +444,7 @@ public class Pointer implements HeapAnalysis{ if (delta.getInit()) { removeInitTaints(null, delta, graph); for (TempDescriptor tmp:sese.getInVarSet()) { - Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty); + Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty); MySet edges=GraphManip.getEdges(graph, delta, tmp); for(Edge e:edges) { Edge newe=e.addTaint(taint); @@ -454,7 +454,7 @@ public class Pointer implements HeapAnalysis{ } else { removeDiffTaints(null, delta); for (TempDescriptor tmp:sese.getInVarSet()) { - Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty); + Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty); MySet edges=GraphManip.getDiffEdges(delta, tmp); for(Edge e:edges) { Edge newe=e.addTaint(taint); @@ -975,9 +975,9 @@ public class Pointer implements HeapAnalysis{ delta.addVarEdge(e); } } - + public Alloc getAllocationSiteFromFlatNew(FlatNew node) { - return allocFactory.getAllocNode(node, false); + return allocFactory.getAllocNode(node, false).getAllocSite(); } void processSumHeapEdgeSet(HashMap> map, Delta delta, Graph graph) { @@ -1308,13 +1308,13 @@ public class Pointer implements HeapAnalysis{ MySet dstEdges=GraphManip.getEdges(graph, delta, dst); if (OoOJava&&!accessible.isAccessible(node, src)) { - Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty); srcEdges=Edge.taintAll(srcEdges, srcStallTaint); updateVarDelta(graph, delta, src, srcEdges, null); } if (OoOJava&&!accessible.isAccessible(node, dst)) { - Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty); dstEdges=Edge.taintAll(dstEdges, dstStallTaint); updateVarDelta(graph, delta, dst, dstEdges, null); } @@ -1344,13 +1344,13 @@ public class Pointer implements HeapAnalysis{ MySet newDstEdges=GraphManip.getDiffEdges(delta, dst); if (OoOJava&&!accessible.isAccessible(node, src)) { - Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty); newSrcEdges=Edge.taintAll(newSrcEdges, srcStallTaint); updateVarDelta(graph, delta, src, newSrcEdges, null); } if (OoOJava&&!accessible.isAccessible(node, dst)) { - Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty); newDstEdges=Edge.taintAll(newDstEdges, dstStallTaint); updateVarDelta(graph, delta, dst, newDstEdges, null); } @@ -1456,7 +1456,7 @@ public class Pointer implements HeapAnalysis{ dst=ffn.getDst(); } if (OoOJava&&!accessible.isAccessible(node, src)) { - taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty)); + taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty)); } //Do nothing for non pointers diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index 484f146f..23b90ee4 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -513,7 +513,7 @@ public class RuntimeConflictResolver { //TODO what if we have more than one way in?! >< i.e. more than 1 temp descriptor... Set insetVars = ptrGraph.getEdges(var); for(Edge invar: insetVars) { - Alloc rootKey = invar.getSrcAlloc(); + Alloc rootKey = invar.getSrcAlloc().getAllocSite(); if(!created.contains(rootKey)) { //null -> no transitions by reading this object (does not apply to its references @@ -546,7 +546,7 @@ public class RuntimeConflictResolver { for(Edge e: edges) { //since we're starting from a src, it should match... assert e.getSrcAlloc().equals(curr.alloc); - Alloc dst = e.getDst(); + Alloc dst = e.getDst().getAllocSite(); String field = e.getFieldDesc().getSafeSymbol(); ce = et.getCombinedEffects(curr.alloc, field); ConcreteRuntimeObjNode child; -- 2.34.1