private final HashSet flagstate;
private final ClassDescriptor cd;
private final Hashtable<TagDescriptor,Integer> tags;
+ private boolean issourcenode;
/** Class constructor
* Creates a new flagstate with all flags set to false.
this.cd=cd;
this.tags=new Hashtable<TagDescriptor,Integer>();
this.uid=FlagState.nodeid++;
+ this.issourcenode=false;
}
/** Class constructor
this.cd=cd;
this.tags=tags;
this.uid=FlagState.nodeid++;
+ this.issourcenode=false;
}
public boolean get(FlagDescriptor fd) {
return flagstate.contains(fd);
}
+
+ /** Checks if the flagstate is a source node.
+ * @return true if the flagstate is a sourcenode(i.e. Is the product of an allocation site).
+ */
+
+ public boolean isSourceNode(){
+ return issourcenode;
+ }
+
+ /** Sets the flagstate as a source node.
+ */
+ public void setAsSourceNode(){
+ issourcenode=true;
+ }
public String toString() {
this.state=state;
this.typeutil=new TypeUtil(state);
this.taganalysis=taganalysis;
+
}
/** Builds a table of flags for each class in the Bristlecone program.
Set newstates=taganalysis.getFlagStates(td);
for(Iterator fsit=newstates.iterator();fsit.hasNext();) {
FlagState fsnew=(FlagState) fsit.next();
+ fsnew.setAsSourceNode();
+
if (! ((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).containsKey(fsnew)) {
((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).put(fsnew, fsnew);
toprocess.add(fsnew);
for(Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();classit.hasNext();) {
ClassDescriptor cd=(ClassDescriptor) classit.next();
- produceTaskNodes(cd);
+ if (cd.hasFlags())
+ produceTaskNodes(cd);
}
}
public void createDOTfiles() {
- for(Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();classit.hasNext();) {
- ClassDescriptor cd=(ClassDescriptor) classit.next();
+ for(Iterator it_classes=(Iterator)cdtonodes.keys();it_classes.hasNext();) {
+ ClassDescriptor cd=(ClassDescriptor) it_classes.next();
Set tasknodes=getTaskNodes(cd);
if (tasknodes!=null) {
try {
Set fsnodes=taskanalysis.getFlagStates(cd);
if (fsnodes==null)
return;
-
+
Hashtable<TaskNode,TaskNode> tasknodes=new Hashtable<TaskNode,TaskNode>();
cdtonodes.put(cd, tasknodes);
for(Iterator it=fsnodes.iterator();it.hasNext();) {
FlagState fs=(FlagState)it.next();
-
Iterator it_inedges=fs.inedges();
- TaskNode tn;
- do {
- if (!fs.inedges().hasNext()){
- tn=new TaskNode("Start Node");
- } else {
+ TaskNode tn,sn;
+
+ if (fs.isSourceNode()) {
+ sn=new TaskNode("Start Node");
+ if(fs.edges().hasNext()){
+ addEdges(fs,sn);
+ }
+ }
+
+ while(it_inedges.hasNext()){
+
FEdge inedge=(FEdge)it_inedges.next();
tn=new TaskNode(inedge.getLabel());
- }
- if(fs.edges().hasNext()){
- tn=(TaskNode)canonicalizeTaskNode(tasknodes, tn);
- for (Iterator it_edges=fs.edges();it_edges.hasNext();){
- TaskNode target=new TaskNode(((FEdge)it_edges.next()).getLabel());
- target=(TaskNode)canonicalizeTaskNode(tasknodes,target);
- TEdge tedge=new TEdge(target);
- // if (!tn.edges.contains(tedge))
- tn.addEdge(new TEdge(target));
- }
- }
- } while(it_inedges.hasNext());
+ if(fs.edges().hasNext()){
+ addEdges(fs,tn);
+ }
+ }
}
}
+ private void addEdges(FlagState fs, TaskNode tn){
+
+ Hashtable<TaskNode,TaskNode> tasknodes=(Hashtable<TaskNode,TaskNode>)cdtonodes.get(fs.getClassDescriptor());
+ tn=(TaskNode)canonicalizeTaskNode(tasknodes, tn);
+ for (Iterator it_edges=fs.edges();it_edges.hasNext();){
+ TaskNode target=new TaskNode(((FEdge)it_edges.next()).getLabel());
+ target=(TaskNode)canonicalizeTaskNode(tasknodes,target);
+
+ TEdge newedge=new TEdge(target);
+ if (! tn.edgeExists(newedge))
+ tn.addEdge(new TEdge(target));
+ }
+
+ }
}