import java.util.*;
import Util.GraphNode;
-public class EGTaskNode extends TaskNode {
+public class EGTaskNode extends GraphNode {
private boolean source=false;
private FlagState fs;
private FlagState postfs;
private TaskDescriptor td;
private int index;
+ private String name;
+ private int uid;
+ private static int nodeid;
public EGTaskNode(String name, TaskDescriptor td, FlagState postfs){
this(name, null, td, -1, postfs);
}
public EGTaskNode(String name, FlagState fs, TaskDescriptor td, int index, FlagState postfs){
- super(name);
+ this.name=name;
+ this.uid=nodeid++;
this.fs = fs;
this.td = td;
this.index=index;
this.postfs=postfs;
}
+
+ public String getTextLabel() {
+ return "Task "+getName()+"["+fs+"]->["+postfs+"]";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLabel() {
+ return "N"+uid;
+ }
public int getIndex() {
return index;
}
+ public String toString() {
+ return getTextLabel();
+ }
+
public FlagState getPostFS() {
return postfs;
}
public void analyzeFS(FlagState fs, Set<EGTaskNode> egset, Hashtable<FlagState, Set<OptionalTaskDescriptor>> fstootd, Hashtable<FlagState, Set<FlagState>> fsusemap, HashSet<FlagState> tovisit) {
Hashtable<TaskIndex, Set<OptionalTaskDescriptor>> timap=new Hashtable<TaskIndex, Set<OptionalTaskDescriptor>>();
+ Set<TaskIndex> tiselfloops=new HashSet<TaskIndex>();
for(Iterator<EGTaskNode> egit=egset.iterator();egit.hasNext();) {
EGTaskNode egnode=egit.next();
}
TaskIndex ti=egnode.isRuntime()?new TaskIndex():new TaskIndex(egnode.getTD(), egnode.getIndex());
if (!ti.runtime) {
- //runtime edges don't do anything...don't have to take them, can't predict when we can.
- if (timap.containsKey(ti)) {
+ //runtime edges don't do anything...don't have to take
+ //them, can't predict when we can.
+ if (state.selfloops.contains(egnode.getTD().getSymbol())) {
+ System.out.println("Self loop for: "+egnode.getTD()+" "+egnode.getIndex());
+ if (timap.containsKey(ti)) {
+ if (egnode.getPostFS()!=fs) {
+ if (tiselfloops.contains(ti)) {
+ //dump old self loop
+ timap.put(ti, setotd);
+ tiselfloops.remove(ti);
+ } else {
+ //standard and case
+ timap.put(ti, createIntersection(timap.get(ti), setotd, fs.getClassDescriptor()));
+ }
+ }
+ } else {
+ //mark as self loop
+ timap.put(ti, setotd);
+ if (egnode.getPostFS()==fs) {
+ tiselfloops.add(ti);
+ }
+ }
+ } else if (timap.containsKey(ti)) {
//AND case
timap.put(ti, createIntersection(timap.get(ti), setotd, fs.getClassDescriptor()));
} else {
for(Iterator it_tasks=state.getTaskSymbolTable().getDescriptorsIterator();it_tasks.hasNext();) {
TaskDescriptor td = (TaskDescriptor)it_tasks.next();
String taskname=td.getSymbol();
-
+
/** counter to keep track of the number of parameters (of the
* task being analyzed) that are satisfied by the flagstate.
*/
Set newstates=taganalysis.getFlagStates(td);
for(Iterator fsit=newstates.iterator();fsit.hasNext();) {
FlagState fsnew=(FlagState) fsit.next();
- fsnew.setAsSourceNode();
- fsnew.addAllocatingTask(td);
- ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew);
+ System.out.println("SOURCE:"+fsnew);
if (! ((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).containsKey(fsnew)) {
((Hashtable<FlagState,FlagState>)flagstates.get(fsnew.getClassDescriptor())).put(fsnew, fsnew);
toprocess.add(fsnew);
+ } else {
+ fsnew=((Hashtable<FlagState, FlagState>)flagstates.get(fsnew.getClassDescriptor())).get(fsnew);
}
+ fsnew.setAsSourceNode();
+ fsnew.addAllocatingTask(td);
+
+ ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew);
}
Stack nodestack=new Stack();
nativeConnect(fd, address.getAddress(), port);
}
+ public void connect(String host, int port) {
+ InetAddress address=InetAddress.getByName(host);
+ fd=nativeBind(address.getAddress(), port);
+ nativeConnect(fd, address.getAddress(), port);
+ }
+
public void connect(InetAddress address, int port) {
fd=nativeBind(address.getAddress(), port);
nativeConnect(fd, address.getAddress(), port);
}
public boolean hasFlags() {
- return hasFlags;
+ return hasFlags||getSuperDesc()!=null&&getSuperDesc().hasFlags();
}
public void addField(FieldDescriptor fd) {
this.arraytypes=new HashSet();
this.arraytonumber=new Hashtable();
this.tagmap=new Hashtable();
+ this.selfloops=new HashSet();
}
public void addParseNode(ParseNode parsetree) {
public String structfile;
public String main;
+ public HashSet selfloops;
public SymbolTable classes;
public SymbolTable tasks;
public Set parsetrees;
public static void main(String args[]) throws Exception {
String ClassLibraryPrefix="./ClassLibrary/";
State state=new State();
-
+
for(int i=0;i<args.length;i++) {
String option=args[i];
if (option.equals("-precise"))
state.PREFETCH=true;
else if (option.equals("-dir"))
IR.Flat.BuildCode.PREFIX=args[++i]+"/";
+ else if (option.equals("-selfloop"))
+ state.selfloops.add(args[++i]);
else if (option.equals("-classlibrary"))
ClassLibraryPrefix=args[++i]+"/";
else if (option.equals("-mainclass"))
state.INSTRUCTIONFAILURE=true;
else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
+ System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
System.out.println("-dir outputdirectory -- output code in outputdirectory");
System.out.println("-struct structfile -- output structure declarations for repair tool");
System.out.println("-mainclass -- main function to call");
int hashCodetpd(struct taskparamdescriptor *ftd) {
int hash=(int)ftd->task;
- int i;
+ int i;
for(i=0;i<ftd->numParameters;i++){
hash^=(int)ftd->parameterArray[i];
}
tpd->parameterArray[j]=taskpointerarray[j];//store the actual parameters
#ifdef OPTIONAL
tpd->failed[j]=failed[j];
+ if (failed[j]!=0&&failed[j]!=1) {
+ printf("BAD\n");
+ }
#endif
}
/* Enqueue task */
genputtable(activetasks, tpd, tpd);
} else {
RUNFREE(tpd->parameterArray);
+#ifdef OPTIONAL
+ RUNFREE(tpd->failed);
+#endif
RUNFREE(tpd);
}
#endif
if(debugtask){
printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
+ {
+ int i;
+ printf("[%x]\n",currtpd);
+ for(i=0;i<currtpd->numParameters;i++) {
+ printf("%x ", currtpd->parameterArray[i]);
+ }
+ printf("\n");
+ }
((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
} else
/* Get object with tags */
struct ___Object___ *obj=objectarray[it->tagobjectslot];
struct ___Object___ *tagptr=obj->___tags___;
+#ifdef OPTIONAL
+ failed[it->slot]=0; //have to set it to something
+#endif
if (tagptr->type==TAGTYPE) {
it->tagobjindex++;
objectarray[it->slot]=tagptr;
echo -dmalloc link in dmalloc
echo -recover compile task code
echo -specdir directory
+echo -selfloop task - this task cannot self loop forever
echo -taskstate do task state analysis
echo -optional enable optional
echo -debug generate debug symbols
then
JAVAOPTS="$JAVAOPTS -mainclass $2"
shift
+elif [[ $1 = '-selfloop' ]]
+then
+JAVAOPTS="$JAVAOPTS -selfloop $2"
+shift
elif [[ $1 = '-dsm' ]]
then
JAVAOPTS="$JAVAOPTS -dsm"