From dae581a6940b36483ddd74f02d3eb1ee56909b98 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 9 Nov 2007 23:01:23 +0000 Subject: [PATCH] more bugs --- .../TaskStateAnalysis/EGTaskNode.java | 24 +++++++++++++++-- .../TaskStateAnalysis/SafetyAnalysis.java | 26 +++++++++++++++++-- .../TaskStateAnalysis/TaskAnalysis.java | 12 ++++++--- Robust/src/ClassLibrary/Socket.java | 6 +++++ Robust/src/IR/ClassDescriptor.java | 2 +- Robust/src/IR/State.java | 2 ++ Robust/src/Main/Main.java | 5 +++- Robust/src/Runtime/task.c | 19 +++++++++++++- Robust/src/buildscript | 5 ++++ 9 files changed, 90 insertions(+), 11 deletions(-) diff --git a/Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java b/Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java index e6c9ac32..169e52a4 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java +++ b/Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java @@ -6,29 +6,49 @@ import IR.Flat.*; 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; } diff --git a/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java index 241a70e0..93961377 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java @@ -118,6 +118,7 @@ public class SafetyAnalysis { public void analyzeFS(FlagState fs, Set egset, Hashtable> fstootd, Hashtable> fsusemap, HashSet tovisit) { Hashtable> timap=new Hashtable>(); + Set tiselfloops=new HashSet(); for(Iterator egit=egset.iterator();egit.hasNext();) { EGTaskNode egnode=egit.next(); @@ -174,8 +175,29 @@ public class SafetyAnalysis { } 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 { diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java index 96875620..4ded241a 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java @@ -156,7 +156,7 @@ private void analyseTasks(FlagState fs) { 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. */ @@ -192,14 +192,18 @@ private void analyseTasks(FlagState fs) { 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)flagstates.get(fsnew.getClassDescriptor())).containsKey(fsnew)) { ((Hashtable)flagstates.get(fsnew.getClassDescriptor())).put(fsnew, fsnew); toprocess.add(fsnew); + } else { + fsnew=((Hashtable)flagstates.get(fsnew.getClassDescriptor())).get(fsnew); } + fsnew.setAsSourceNode(); + fsnew.addAllocatingTask(td); + + ((Vector)cdtorootnodes.get(fsnew.getClassDescriptor())).add(fsnew); } Stack nodestack=new Stack(); diff --git a/Robust/src/ClassLibrary/Socket.java b/Robust/src/ClassLibrary/Socket.java index a9f3fbf0..452e395e 100644 --- a/Robust/src/ClassLibrary/Socket.java +++ b/Robust/src/ClassLibrary/Socket.java @@ -30,6 +30,12 @@ public class Socket { 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); diff --git a/Robust/src/IR/ClassDescriptor.java b/Robust/src/IR/ClassDescriptor.java index b1e05b13..a86ea6af 100644 --- a/Robust/src/IR/ClassDescriptor.java +++ b/Robust/src/IR/ClassDescriptor.java @@ -107,7 +107,7 @@ public class ClassDescriptor extends Descriptor { } public boolean hasFlags() { - return hasFlags; + return hasFlags||getSuperDesc()!=null&&getSuperDesc().hasFlags(); } public void addField(FieldDescriptor fd) { diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 89fd4727..d0b2a079 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -15,6 +15,7 @@ public class State { this.arraytypes=new HashSet(); this.arraytonumber=new Hashtable(); this.tagmap=new Hashtable(); + this.selfloops=new HashSet(); } public void addParseNode(ParseNode parsetree) { @@ -56,6 +57,7 @@ public class State { public String structfile; public String main; + public HashSet selfloops; public SymbolTable classes; public SymbolTable tasks; public Set parsetrees; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index e61094c0..e6cb52ec 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -30,7 +30,7 @@ public class Main { public static void main(String args[]) throws Exception { String ClassLibraryPrefix="./ClassLibrary/"; State state=new State(); - + for(int i=0;itask; - int i; + int i; for(i=0;inumParameters;i++){ hash^=(int)ftd->parameterArray[i]; } @@ -917,6 +917,9 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr 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 */ @@ -924,6 +927,9 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr genputtable(activetasks, tpd, tpd); } else { RUNFREE(tpd->parameterArray); +#ifdef OPTIONAL + RUNFREE(tpd->failed); +#endif RUNFREE(tpd); } @@ -1187,6 +1193,14 @@ void executetasks() { #endif if(debugtask){ printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount)); + { + int i; + printf("[%x]\n",currtpd); + for(i=0;inumParameters;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 @@ -1563,6 +1577,9 @@ void toiNext(struct tagobjectiterator *it , void ** objectarray OPTARG(int * fai /* 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; diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 5963824c..fc3fdfb0 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -7,6 +7,7 @@ echo -check generate check code 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 @@ -60,6 +61,10 @@ elif [[ $1 = '-mainclass' ]] then JAVAOPTS="$JAVAOPTS -mainclass $2" shift +elif [[ $1 = '-selfloop' ]] +then +JAVAOPTS="$JAVAOPTS -selfloop $2" +shift elif [[ $1 = '-dsm' ]] then JAVAOPTS="$JAVAOPTS -dsm" -- 2.34.1