more bugs
authorbdemsky <bdemsky>
Fri, 9 Nov 2007 23:01:23 +0000 (23:01 +0000)
committerbdemsky <bdemsky>
Fri, 9 Nov 2007 23:01:23 +0000 (23:01 +0000)
Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java
Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java
Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java
Robust/src/ClassLibrary/Socket.java
Robust/src/IR/ClassDescriptor.java
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Runtime/task.c
Robust/src/buildscript

index e6c9ac32adaf4ec094ce87ac5c0853269a2df11a..169e52a4ed0a8f3610fe967c809cbc4613d9a65c 100644 (file)
@@ -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;
     }
index 241a70e06614ff84167ecd162ee543b3a460dc85..939613773cf40408298017cbfbd77720e28c5812 100644 (file)
@@ -118,6 +118,7 @@ public class SafetyAnalysis {
 
     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();
@@ -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 {
index 96875620b226e6b0ef6b4d272bd3113d8c430fbc..4ded241a75ead5b7b8e85612a370804f38af8bfa 100644 (file)
@@ -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<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();
index a9f3fbf03cfeaef56779b66745a0c7dded1b4bf8..452e395e4e1890c0fe204dce5e194b47368534cf 100644 (file)
@@ -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);
index b1e05b136e9d2009734b3ddbec69a441777928e1..a86ea6af6004bfb2256d7ae5f30d18f3bdf51e37 100644 (file)
@@ -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) {
index 89fd4727f9b352494a79bd304757fff987578d12..d0b2a079d4f0c97a98315fc1b196ea9f4c232984 100644 (file)
@@ -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;
index e61094c04aa9f4e8fdf03d15d34bb01b72d9c33c..e6cb52ec0b91f41b14ca80082e2acf3d7f009d59 100644 (file)
@@ -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;i<args.length;i++) {
          String option=args[i];
          if (option.equals("-precise"))
@@ -39,6 +39,8 @@ public class Main {
              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"))
@@ -75,6 +77,7 @@ public class Main {
              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");
index 4e5a79c6b2f9445c51e6484c5eedcf175c485451..5dd4e889ab92ba50c7bb0814c82dc7d3ae5c298c 100644 (file)
@@ -83,7 +83,7 @@ void createstartupobject(int argc, char ** argv) {
 
 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];
   }
@@ -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;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
@@ -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;
index 5963824c9259b1239fbc2811cc2a0decb8520358..fc3fdfb0ed864f675f3456cb6ffff753afad0c27 100755 (executable)
@@ -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"