return edgeset;
}
+ static MySet<Edge> genEdges(TempDescriptor tmp, MySet<Edge> dstSet) {
+ MySet<Edge> edgeset=new MySet<Edge>();
+ for(Edge e:dstSet) {
+ edgeset.add(e.changeSrcVar(tmp));
+ }
+ return edgeset;
+ }
+
static MySet<Edge> genEdges(HashSet<AllocNode> srcSet, FieldDescriptor fd, HashSet<AllocNode> dstSet) {
MySet<Edge> edgeset=new MySet<Edge>();
for(AllocNode srcnode:srcSet) {
return edgeset;
}
+ static MySet<Edge> dereference(Graph graph, Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd) {
+ MySet<Edge> edgeset=new MySet<Edge>();
+ for(Edge edge:srcEdges) {
+ MySet<Edge> removeedges=delta.heapedgeremove.get(edge.dst);
+ for(Edge e:graph.getEdges(edge.dst)) {
+ if (e.fd==fd&&(removeedges==null||!removeedges.contains(e))) {
+ e=e.changeSrcVar(dst);
+ if (!edgeset.contains(e))
+ edgeset.add(e);
+ else {
+ Edge preve=edgeset.get(e);
+ e=e.merge(preve);
+ edgeset.add(e);
+ }
+ }
+ }
+ if (delta.heapedgeadd.containsKey(edge.dst))
+ for(Edge e:delta.heapedgeadd.get(edge.dst)) {
+ if (e.fd==fd) {
+ e=e.changeSrcVar(dst);
+ if (!edgeset.contains(e))
+ edgeset.add(e);
+ else {
+ Edge preve=edgeset.get(e);
+ e=e.merge(preve);
+ edgeset.add(e);
+ }
+ }
+ }
+ }
+ return edgeset;
+ }
+
+ static MySet<Edge> diffDereference(Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd) {
+ MySet<Edge> edgeset=new MySet<Edge>();
+ for(Edge edge:srcEdges) {
+ MySet<Edge> removeedges=delta.heapedgeremove.get(edge.dst);
+ if (delta.baseheapedge.containsKey(edge.dst)) {
+ for(Edge e:delta.baseheapedge.get(edge.dst)) {
+ if (e.fd==fd&&(removeedges==null||!removeedges.contains(e))) {
+ e=e.changeSrcVar(dst);
+ if (!edgeset.contains(e))
+ edgeset.add(e);
+ else {
+ Edge preve=edgeset.get(e);
+ e=e.merge(preve);
+ edgeset.add(e);
+ }
+ }
+ }
+ }
+ if (delta.heapedgeadd.containsKey(edge.dst))
+ for(Edge e:delta.heapedgeadd.get(edge.dst)) {
+ if (e.fd==fd) {
+ e=e.changeSrcVar(dst);
+ if (!edgeset.contains(e))
+ edgeset.add(e);
+ else {
+ Edge preve=edgeset.get(e);
+ e=e.merge(preve);
+ edgeset.add(e);
+ }
+ }
+ }
+ }
+ return edgeset;
+ }
+
static HashSet<AllocNode> getNodes(Graph graph, Delta delta, HashSet<AllocNode> srcNodes, FieldDescriptor fd) {
HashSet<AllocNode> nodes=new HashSet<AllocNode>();
for(AllocNode node:srcNodes) {
dst=fcn.getDst();
}
if (delta.getInit()) {
- HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, srcnodes);
+ MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, srcedges);
MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
} else {
/* First compute new src nodes */
- HashSet<AllocNode> newSrcNodes=GraphManip.getDiffNodes(delta, src);
+ MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
/* Compute the union, and then the set of edges */
- MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newSrcNodes);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newSrcEdges);
/* Compute set of edges to remove */
MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
if (!dst.getType().isPtr())
return delta;
if (delta.getInit()) {
- HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
- HashSet<AllocNode> fdnodes=GraphManip.getNodes(graph, delta, srcnodes, fd);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, fdnodes);
+ MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
+ MySet<Edge> edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd);
MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
} else {
/* First compute new objects we read fields of */
- HashSet<AllocNode> allsrcnodes=GraphManip.getNodes(graph, delta, src);
- HashSet<AllocNode> difffdnodes=GraphManip.getDiffNodes(delta, allsrcnodes, fd);
+ MySet<Edge> allsrcedges=GraphManip.getEdges(graph, delta, src);
+ MySet<Edge> edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd);
/* Next compute new targets of fields */
- HashSet<AllocNode> newsrcnodes=GraphManip.getDiffNodes(delta, src);
- HashSet<AllocNode> newfdnodes=GraphManip.getNodes(graph, delta, newsrcnodes, fd);
+ MySet<Edge> newsrcedges=GraphManip.getDiffEdges(delta, src);
+ MySet<Edge> newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd);
+
/* Compute the union, and then the set of edges */
- HashSet<AllocNode> newTargets=new HashSet<AllocNode>();
- newTargets.addAll(newfdnodes);
- newTargets.addAll(difffdnodes);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newTargets);
+ Edge.mergeEdgesInto(edgesToAdd, newfdedges);
/* Compute set of edges to remove */
MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);