package Analysis.TaskStateAnalysis;
import Util.*;
-public class Allocations {
+public class Allocations extends Namer {
public Allocations() {}
public String nodeLabel(GraphNode gn) {
}
}
if (label==null)
- return "";
+ return " ";
return label;
}
ClassDescriptor startupobject=typeutil.getClass(TypeUtil.StartupClass);
sourcenodes=(Hashtable<FlagState,FlagState>)flagstates.get(startupobject);
-
FlagState fsstartup=new FlagState(startupobject);
+
+
FlagDescriptor[] fd=(FlagDescriptor[])flags.get(startupobject);
fsstartup=fsstartup.setFlag(fd[0],true);
-
+ fsstartup.setAsSourceNode();
+
sourcenodes.put(fsstartup,fsstartup);
toprocess.add(fsstartup);
}
}
+ Stack nodestack=new Stack();
+ HashSet discovered=new HashSet();
+ nodestack.push(fm);
+ discovered.add(fm);
//Iterating through the nodes
- Set nodeset=fm.getNodeSet();
- for(Iterator nodeit=nodeset.iterator();nodeit.hasNext();) {
- FlatNode fn1 = (FlatNode) nodeit.next();
+ while(!nodestack.isEmpty()) {
+ FlatNode fn1 = (FlatNode) nodestack.pop();
- if (fn1.kind()==FKind.FlatFlagActionNode) {
+ if (fn1.kind()==FKind.FlatReturnNode) {
+ /* Self edge */
+ FEdge newedge=new FEdge(fs, taskname);
+ fs.addEdge(newedge);
+ continue;
+ } else if (fn1.kind()==FKind.FlatFlagActionNode) {
FlatFlagActionNode ffan=(FlatFlagActionNode)fn1;
if (ffan.getTaskType() == FlatFlagActionNode.PRE) {
if (ffan.getTempFlagPairs().hasNext()||ffan.getTempTagPairs().hasNext())
//FEdge newedge=new FEdge(fs_taskexit,td);
fs.addEdge(newedge);
}
+ continue;
+ }
+ }
+ /* Queue other nodes past this one */
+ for(int i=0;i<fn1.numNext();i++) {
+ FlatNode fnext=fn1.getNext(i);
+ if (!discovered.contains(fnext)) {
+ discovered.add(fnext);
+ nodestack.push(fnext);
}
}
}
HashSet visited=new HashSet();
int labelindex=0;
Hashtable nodetolabel=new Hashtable();
- tovisit.add(fm.methodEntryNode());
+ tovisit.add(fm.getNext(0));
FlatNode current_node=null;
//Assign labels 1st
//Do the actual code generation
tovisit=new HashSet();
visited=new HashSet();
- tovisit.add(fm.methodEntryNode());
+ tovisit.add(fm.getNext(0));
while(current_node!=null||!tovisit.isEmpty()) {
if (current_node==null) {
current_node=(FlatNode)tovisit.iterator().next();
private void flattenTask(TaskDescriptor td) {
BlockNode bn=state.getMethodBody(td);
- FlatNode fn=flattenBlockNode(bn).getBegin();
+ NodePair np=flattenBlockNode(bn);
+ FlatNode fn=np.getBegin();
+ if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ FlatReturnNode rnflat=new FlatReturnNode(null);
+ np.getEnd().addNext(rnflat);
+ }
+
FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.PRE);
ffan.addNext(fn);
- FlatMethod fm=new FlatMethod(td, ffan);
+ FlatMethod fm=new FlatMethod(td);
+ fm.addNext(ffan);
HashSet visitedset=new HashSet();
MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
FlatCall fcunlock=new FlatCall(memdex, null, thistd, new TempDescriptor[0]);
np.getEnd().addNext(fcunlock);
+ FlatReturnNode rnflat=new FlatReturnNode(null);
+ fcunlock.addNext(rnflat);
}
+ } else if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ FlatReturnNode rnflat=new FlatReturnNode(null);
+ np.getEnd().addNext(rnflat);
}
- FlatMethod fm=new FlatMethod(currmd, fn);
+ FlatMethod fm=new FlatMethod(currmd);
+ fm.addNext(fn);
if (!currmd.isStatic())
fm.addParameterTemp(getTempforParam(currmd.getThis()));
for(int i=0;i<currmd.numParameters();i++) {
import java.util.*;
public class FlatMethod extends FlatNode {
- FlatNode method_entry;
MethodDescriptor method;
TaskDescriptor task;
Vector parameterTemps;
Vector tagTemps;
Hashtable tagtointmap;
- FlatMethod(MethodDescriptor md, FlatNode entry) {
+ FlatMethod(MethodDescriptor md) {
method=md;
task=null;
- method_entry=entry;
parameterTemps=new Vector();
tagTemps=new Vector();
tagtointmap=new Hashtable();
}
- FlatMethod(TaskDescriptor td, FlatNode entry) {
+ FlatMethod(TaskDescriptor td) {
task=td;
method=null;
- method_entry=entry;
parameterTemps=new Vector();
tagTemps=new Vector();
tagtointmap=new Hashtable();
return (TempDescriptor) parameterTemps.get(i);
}
- public FlatNode methodEntryNode() {
- return method_entry;
- }
-
/** This method returns a set of the nodes in this flat representation */
public Set getNodeSet() {
HashSet tovisit=new HashSet();
HashSet visited=new HashSet();
- tovisit.add(method_entry);
+ tovisit.add(this);
while(!tovisit.isEmpty()) {
FlatNode fn=(FlatNode)tovisit.iterator().next();
tovisit.remove(fn);
HashSet visited=new HashSet();
int labelindex=0;
Hashtable nodetolabel=new Hashtable();
- tovisit.add(method_entry);
+ tovisit.add(this);
FlatNode current_node=null;
//Assign labels 1st
//Node needs a label if it is
//Do the actual printing
tovisit=new HashSet();
visited=new HashSet();
- tovisit.add(method_entry);
+ tovisit.add(this);
while(current_node!=null||!tovisit.isEmpty()) {
if (current_node==null) {
current_node=(FlatNode)tovisit.iterator().next();
taskmap.put("/"+cd.getSymbol()+".html", cd);
}
if (taskgraph.getTaskNodes(cd)!=null) {
- pw.println("<a href=\""+cd.getSymbol()+"-t.html\">"+ cd.getSymbol() +"</a>");
+ pw.println("<a href=\""+cd.getSymbol()+"-t.html\">Task Graph "+ cd.getSymbol() +"</a>");
pw.println("<br>");
taskgraphmap.put("/"+cd.getSymbol()+"-t.html", cd);
}
IR/Tree/TaskExitNode.class IR/Tree/TreeNode.class \
IR/Tree/Walkable.class Analysis/TaskStateAnalysis/FEdge.class \
Analysis/TaskStateAnalysis/FlagState.class \
+Analysis/TaskStateAnalysis/Allocations.class \
Analysis/TaskStateAnalysis/TEdge.class \
Analysis/TaskStateAnalysis/TagAnalysis.class \
Analysis/TaskStateAnalysis/TagBinding.class \
javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath . -private -d javadoc Lex Util IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Analysis.TaskStateAnalysis Main
clean:
- rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Util/Relation/*.class
+ rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Util/Relation/*.class Interface/*.class
cleandoc:
rm -rf javadoc
\ No newline at end of file