First implementation of the optional args in runtime (still buggy).
Test cases added. use the dot files to see to what task structure the test cases correspond to.
TestRuntime contains the test designed for the runtime.
TestStaticAnalysis contains the ones designed for the static Analysis. They don't generate a good c code.
public boolean equals(Object o){
if (o instanceof OptionalTaskDescriptor) {
OptionalTaskDescriptor otd = (OptionalTaskDescriptor) o;
- if (this.td.getSymbol().compareTo(otd.td.getSymbol())==0)
+ /*if (this.td.getSymbol().compareTo(otd.td.getSymbol())==0)
if(this.flagstates.equals(otd.flagstates))
if(this.predicate.equals(otd.predicate))
return true;
+ return false;*/
+ if(this.hashCode()==otd.hashCode())
+ return true;
return false;
}
else return false;
safeexecution.put(processedclass, cdhashtable);
}
- cleanPredicates();
+ putinoptionaltaskdescriptors();
printTEST();
}
+ private void putinoptionaltaskdescriptors(){
+ Enumeration e = safeexecution.keys();
+ while (e.hasMoreElements()) {
+ ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
+ optionaltaskdescriptors.get(cdtemp).clear();
+ Hashtable hashtbtemp = safeexecution.get(cdtemp);
+ Enumeration fses = hashtbtemp.keys();
+ while(fses.hasMoreElements()){
+ FlagState fs = (FlagState)fses.nextElement();
+ HashSet availabletasks = (HashSet)hashtbtemp.get(fs);
+ for(Iterator otd_it = availabletasks.iterator(); otd_it.hasNext();){
+ OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
+ optionaltaskdescriptors.get(cdtemp).put(otd, otd);
+ }
+ }
+ }
+ }
+
private void printTEST(){
Enumeration e = safeexecution.keys();
HashSet fstemp = new HashSet();
fstemp.add(tn.getFS());
OptionalTaskDescriptor otd = new OptionalTaskDescriptor(tn.getTD(), fstemp, depth, temppredicate);
- //System.out.println("Create Optionaltaskdescriptor number "+otd.getuid()+" hascode "+otd.hashCode());
if(optionaltaskdescriptors.get(processedclass).get(otd)!=null){
otd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(otd);
}
HashSet fstemp = new HashSet();
fstemp.add(tn.getFS());
OptionalTaskDescriptor otd = new OptionalTaskDescriptor(tn.getTD(), fstemp, depth, temppredicate);
- //System.out.println("Create Optionaltaskdescriptor number "+otd.getuid()+" hascode "+otd.hashCode());
if(optionaltaskdescriptors.get(processedclass).get(otd)!=null){
otd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(otd);
}
private HashSet createIntersection( HashSet A, HashSet B){
HashSet result = new HashSet();
- HashSet processed = new HashSet();
+ //HashSet processed = new HashSet();
for(Iterator b_it = B.iterator(); b_it.hasNext();){
OptionalTaskDescriptor otd_b = (OptionalTaskDescriptor)b_it.next();
for(Iterator a_it = A.iterator(); a_it.hasNext();){
OptionalTaskDescriptor otd_a = (OptionalTaskDescriptor)a_it.next();
if(((String)otd_a.td.getSymbol()).compareTo((String)otd_b.td.getSymbol())==0){
- processed.add(otd_a);
- processed.add(otd_b);
+ //processed.add(otd_a);
+ //processed.add(otd_b);
HashSet newfs = new HashSet();
newfs.addAll(otd_a.flagstates);
OptionalTaskDescriptor newotd = new OptionalTaskDescriptor(otd_b.td, newfs, newdepth, combinePredicates(otd_a.predicate, otd_b.predicate));
if(optionaltaskdescriptors.get(processedclass).get(newotd)!=null){
//System.out.println("OTD found");
- //System.out.println("before "+newotd.getuid());
+ System.out.println("before "+newotd.getuid());
newotd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(newotd);
- //System.out.println("after "+newotd.getuid());
+ System.out.println("after "+newotd.getuid());
}
else optionaltaskdescriptors.get(processedclass).put(newotd, newotd);
result.add(newotd);
}
}
- for(Iterator a_it = A.iterator(); a_it.hasNext();){
+ /* for(Iterator a_it = A.iterator(); a_it.hasNext();){
OptionalTaskDescriptor otd = (OptionalTaskDescriptor)a_it.next();
if(!processed.contains(otd))
optionaltaskdescriptors.get(processedclass).remove(otd);
OptionalTaskDescriptor otd = (OptionalTaskDescriptor)b_it.next();
if(!processed.contains(otd))
optionaltaskdescriptors.get(processedclass).remove(otd);
- }
+ } */
return result;
}
otd.exitfses=result;
}
- private void cleanPredicates(){
-
- }
-
-
+
}
private void outputClassDeclarations(PrintWriter outclassdefs) {
if (state.THREAD)
outclassdefs.println("#include <pthread.h>");
+ if(state.OPTIONAL)
+ outclassdefs.println("#include \"optionalstruct.h\"");
outclassdefs.println("struct "+arraytype+";");
/* Start by declaring all structs */
Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
if (state.TASK) {
outclassdefs.println(" int flag;");
outclassdefs.println(" void * flagptr;");
- if(state.OPTIONAL)
+ if(state.OPTIONAL){
outclassdefs.println(" int failedstatus;");
+ outclassdefs.println(" int hashcode;");
+ outclassdefs.println(" int numexitfses;");
+ outclassdefs.println(" int * exitfses;");
+ outclassdefs.println(" int numotds;");
+ outclassdefs.println(" struct optionaltaskdescriptor ** otds;");
+ }
}
printClassStruct(typeutil.getClass(TypeUtil.ObjectClass), outclassdefs);
/** Force consistent field ordering between inherited classes. */
private void printClassStruct(ClassDescriptor cn, PrintWriter classdefout) {
+
ClassDescriptor sp=cn.getSuperDesc();
if (sp!=null)
printClassStruct(sp, classdefout);
if (state.TASK) {
classdefout.println(" int flag;");
classdefout.println(" void * flagptr;");
- if (state.OPTIONAL) classdefout.println(" int failedstatus;");
+ if (state.OPTIONAL){
+ classdefout.println(" int failedstatus;");
+ classdefout.println(" int hashcode;");
+ classdefout.println(" int numexitfses;");
+ classdefout.println(" int * exitfses;");
+ classdefout.println(" int numotds;");
+ classdefout.println(" struct optionaltaskdescriptor ** otds;");
+ }
}
printClassStruct(cn, classdefout);
classdefout.println("};\n");
//GENERATE HEADERS
headers.println("#include \"task.h\"\n\n");
+ headers.println("#ifndef _OPTIONAL_STRUCT_");
+ headers.println("#define _OPTIONAL_STRUCT_");
+
+
//STRUCT PREDICATEMEMBER
headers.println("int numtags;");
headers.println("int * tags;\n};\n\n");
- //STRUCT EXITFLAGSTATE
- headers.println("struct exitflagstate{");
- headers.println("int numflags;");
- headers.println("int * flags;");
- /*
- headers.println("int numtags;");
- headers.println("int * tags;");
- */
- headers.println("\n};\n\n");
-
- //STRUCT EXITSTATES
+ /*//STRUCT EXITSTATES
headers.println("struct exitstates{");
- headers.println("int numexitflagstates;");
- headers.println("struct exitflagstate * exitflagstatearray;\n};\n\n");
+ headers.println("int numflagstates;");
+ headers.println("int * flagstatearray;\n};\n\n");*///appeared to be useless
//STRUCT OPTIONALTASKDESCRIPTOR
headers.println("struct optionaltaskdescriptor{");
headers.println("struct taskdescriptor * task;");
+ headers.println("int numenterflags;");
+ headers.println("int * enterflags;");
headers.println("int numpredicatemembers;");
- headers.println("struct predicatemember * predicatememberarray;");
- headers.println("int numexitstates;");
- headers.println("struct existates * exitstatesarray;\n};\n\n");
+ headers.println("struct predicatemember ** predicatememberarray;");
+ //headers.println("int numexitstates;");
+ //headers.println("int numTotal;");
+ //headers.println("struct exitstates ** exitstatesarray;\n};\n\n");
+ headers.println("\n};\n\n");
//STRUCT FSANALYSISWRAPPER
headers.println("struct fsanalysiswrapper{");
- headers.println("int numflags;");
- headers.println("int * flags;");
+ headers.println("int flags;");
headers.println("int numtags;");
headers.println("int * tags;");
headers.println("int numoptionaltaskdescriptors;");
- headers.println("struct optionaltaskdescriptor * optionaltaskdescriptorarray;\n};\n\n");
+ headers.println("struct optionaltaskdescriptor ** optionaltaskdescriptorarray;\n};\n\n");
//STRUCT CLASSANALYSISWRAPPER
- headers.println("struct classanalyiswrapper{");
+ headers.println("struct classanalysiswrapper{");
headers.println("int type;");
+ headers.println("int numotd;");
+ headers.println("struct optionaltaskdescriptor ** otdarray;");
headers.println("int numfsanalysiswrappers;");
- headers.println("struct fsanalysiswrapper * fsanalysiswrapperarray;\n};\n\n");
+ headers.println("struct fsanalysiswrapper ** fsanalysiswrapperarray;\n};\n\n");
+
+ headers.println("struct classanalysiswrapper * classanalysiswrapperarray[];\n");
+
+
Iterator taskit=state.getTaskSymbolTable().getDescriptorsIterator();
while(taskit.hasNext()) {
headers.println("extern struct taskdescriptor task_"+td.getSafeSymbol()+";");
}
-
+
//GENERATE STRUCTS
output.println("#include \"optionalstruct.h\"\n\n");
HashSet processedcd = new HashSet();
-
+ int maxotd=0;
Enumeration e = safeexecution.keys();
while (e.hasMoreElements()) {
-
+ int numotd=0;
//get the class
ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
Hashtable flaginfo=(Hashtable)flagorder.get(cdtemp);//will be used several times
+ //////////////////////////DEBUG
+ System.out.println(cdtemp.getSymbol()+" "+cdtemp.getId());
+ for(Iterator flags = cdtemp.getFlags(); flags.hasNext();){
+ FlagDescriptor flagd = (FlagDescriptor)flags.next();
+ int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
+ System.out.println(" Flag "+flagd.getSymbol()+" 0x"+Integer.toHexString(flagid)+" int "+flagid);
+ }
+ ///////////////////////////
+
//Generate the struct of optionals
if((Hashtable)optionaltaskdescriptors.get(cdtemp)==null) System.out.println("Was in cd :"+cdtemp.getSymbol());
Collection c_otd = ((Hashtable)optionaltaskdescriptors.get(cdtemp)).values();
+ numotd = c_otd.size();
+ if(maxotd<numotd) maxotd = numotd;
if( !c_otd.isEmpty() ){
for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();){
OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
for (Iterator fen_it = fen_hashset.iterator(); fen_it.hasNext();){
FlagExpressionNode fen = (FlagExpressionNode)fen_it.next();
if (fen==null) {
- //output.println("0x0, 0x0 };");
- //numberterms+=1;
- }
+ }
else {
DNFFlag dflag=fen.getDNF();
for(int j=0;j<tagel.numTags();j++) {
if (j!=0)
output.println(",");
- /* for each tag we need */
- /* which slot it is */
- /* what type it is */
- //TagVarDescriptor tvd=(TagVarDescriptor)task.getParameterTable().get(tagel.getName(j));
TempDescriptor tmp=tagel.getTemp(j);
- //got rid of slot
+ //got rid of slot, maybe some improvments to do ???
output.println("/*tagid*/"+state.getTagId(tmp.getTag()));
}
numtags = tagel.numTags();
output.println("struct predicatemember * predicatememberarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
for( int j = 0; j<predicateindex; j++){
if( j != predicateindex-1)output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
- else output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+ else output.println("&predicatemember_"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
}
+ output.println("};\n");
- //generate the struct for possible exitfses
- HashSet<HashSet> exitfses = otd.exitfses;
+ //generate the struct for possible exitfses, appeared to be useless
+ /*HashSet<HashSet> exitfses = otd.exitfses;
int exitindex = 0;
int nbexit = exitfses.size();
int fsnumber;
//iterate through possible exits
+ int nbtotal=0;
for(Iterator exitfseshash = exitfses.iterator(); exitfseshash.hasNext();){
HashSet temp_hashset = (HashSet)exitfseshash.next();
fsnumber = 0 ;
-
+ output.println("int flag_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
//iterate through possible FSes corresponding to the exit
for(Iterator exfses = temp_hashset.iterator(); exfses.hasNext();){
- FlagState fs = (FlagState)exfses.next();
- fsnumber++;
- output.println("int flags"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
- int counterflag = 0;
- for(Iterator flags = fs.getFlags(); flags.hasNext();){
- FlagDescriptor flagd = (FlagDescriptor)flags.next();
- int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
- if( flags.hasNext() ) output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/,");
- else output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/");
- counterflag++;
- }
- output.println("};\n");
- //do the same for tags;
- //maybe not needed because no tag changes tolerated.
-
- //store the information into a struct
- output.println("struct exitflagstate exitflagstate"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
- output.println("/*number of flags*/"+counterflag+",");
- output.println("flags"+fsnumber+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
- output.println("};\n");
+ FlagState fs = (FlagState)exfses.next();
+ fsnumber++;
+ nbtotal++;
+ int flagid=0;
+ for(Iterator flags = fs.getFlags(); flags.hasNext();){
+ FlagDescriptor flagd = (FlagDescriptor)flags.next();
+ int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+ flagid+=id;
+ }
+ if(fsnumber!=1) output.print(",");
+ output.print(flagid);
+ //do the same for tags.
+ //maybe not needed because no tag changes tolerated.
}
+ output.println("};\n");
- //store fses corresponding to this exit into an array
- output.println("struct exitflagstate * exitflagstatearray"+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+" [] = {");
- for( int j = 0; j<fsnumber; j++){
- if( j != fsnumber-1)output.println("&exitflagstate"+(j+1)+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"'");
- else output.println("&exitflagstate"+(j+1)+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
- }
//store that information in a struct
output.println("struct exitstates exitstates"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
- output.println("/*number of exitflagstate*/"+fsnumber+",");
- output.println("exitflagstatearray"+"_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+ output.println(fsnumber+",");
+ output.println("flag_EXIT"+exitindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
output.println("};\n");
exitindex++;
for( int j = 0; j<nbexit; j++){
if( j != nbexit-1)output.println("&exitstates"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
else output.println("&exitstates"+j+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+ }*/
+
+ int fsnumber = 0 ;
+ output.println("int enterflag_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
+ //iterate through possible FSes corresponding to the state when entering
+ for(Iterator fses = otd.flagstates.iterator(); fses.hasNext();){
+ FlagState fs = (FlagState)fses.next();
+ fsnumber++;
+ int flagid=0;
+ for(Iterator flags = fs.getFlags(); flags.hasNext();){
+ FlagDescriptor flagd = (FlagDescriptor)flags.next();
+ int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+ flagid+=id;
+ }
+ if(fsnumber!=1) output.print(",");
+ output.print(flagid);
+ //tag information not needed because tag changes are not tolerated.
}
-
-
+ output.println("};\n");
+
+
//generate optionaltaskdescriptor that actually includes exit fses, predicate and the task concerned
output.println("struct optionaltaskdescriptor optionaltaskdescriptor_"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"={");
- output.println("task_"+otd.td.getSafeSymbol()+",");
+ output.println("&task_"+otd.td.getSafeSymbol()+",");
+ output.println("/*number of enter flags*/"+fsnumber+",");
+ output.println("enterflag_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
output.println("/*number of members */"+predicateindex+",");
output.println("predicatememberarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+",");
- output.println("/*number of exit fses */"+nbexit+",");
- output.println("exitstatearray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+ //output.println("/*number of exitstates */"+nbexit+",");
+ //output.println("/*total number of fses*/"+nbtotal+",");
+ //output.println("exitstatesarray_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
output.println("};\n");
}
}
else continue; // if there is no optionals, there is no need to build the rest of the struct
+ output.println("struct optionaltaskdescriptor * otdarray"+cdtemp.getSafeSymbol()+"[]={");
+ c_otd = ((Hashtable)optionaltaskdescriptors.get(cdtemp)).values();
+ int x=0;
+ if( !c_otd.isEmpty() ){
+ for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();){
+ OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next();
+ if(x!=0) output.println(",");
+ x++;
+ output.println("&optionaltaskdescriptor_"+otd.getuid()+"_"+cdtemp.getSafeSymbol());
+ }
+ }
+ output.println("};\n");
+
//get all the possible falgstates reachable by an object
Hashtable hashtbtemp = safeexecution.get(cdtemp);
Enumeration fses = hashtbtemp.keys();
output.println("struct optionaltaskdescriptor * optionaltaskdescriptorarray_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[] = {");
for(Iterator mos = availabletasks.iterator(); mos.hasNext();){
OptionalTaskDescriptor mm = (OptionalTaskDescriptor)mos.next();
- if(!mos.hasNext()) output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol()+"};\n");
+ if(!mos.hasNext()) output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol());
else output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol()+",");
}
+ output.println("};\n");
+
//process flag information (what the flag after failure is) so we know what optionaltaskdescriptors to choose.
- output.println("int flags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[]={");
+ int flagid=0;
for(Iterator flags = fs.getFlags(); flags.hasNext();){
FlagDescriptor flagd = (FlagDescriptor)flags.next();
- int flagid=1<<((Integer)flaginfo.get(flagd)).intValue();
- if( flags.hasNext() ) output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/,");
- else output.print("0x"+Integer.toHexString(flagid)+" /*"+Integer.toBinaryString(flagid)+"*/");
-
+ int id=1<<((Integer)flaginfo.get(flagd)).intValue();
+ flagid+=id;
}
+
+
//process tag information
int tagcounter = 0;
- //TagExpressionList tagel = fs.getTags();
- //output.println("int predicatetags_"+predicateindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={");
- //BUG...added next line to fix, test with any task program
-
- //if (tagel!=null){
- // for(int j=0;j<tagel.numTags();j++) {
- // if (j!=0)
- // output.println(",");
- // TempDescriptor tmp=tagel.getTemp(j);
- // output.println("/*tagid*/"+state.getTagId(tmp.getTag()));
- // }
- // numtags = tagel.numTags();
- //}
- //output.println("};");
+ boolean first = true;
+ Enumeration tag_enum = fs.getTags();
+ output.println("int tags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[]={");
+ while(tag_enum.hasMoreElements()){
+ tagcounter++;
+ TagDescriptor tagd = (TagDescriptor)tag_enum.nextElement();
+ if(first==true)
+ first = false;
+ else
+ output.println(", ");
+ output.println("/*tagid*/"+state.getTagId(tagd));
+ }
+ output.println("};");
//Store the result in fsanalysiswrapper
- output.println("};\n");
+
output.println("struct fsanalysiswrapper fsanalysiswrapper_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"={");
- output.println("/* number of flags*/"+fs.numFlags()+",");
- output.println("flags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+",");
+ output.println("/*flag*/"+flagid+",");
output.println("/* number of tags*/"+tagcounter+",");
output.println("tags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+",");
output.println("/* number of optionaltaskdescriptors */"+availabletasks.size()+",");
//Build the classanalysiswrapper referring to the previous array
output.println("struct classanalysiswrapper classanalysiswrapper_"+cdtemp.getSafeSymbol()+"={");
output.println("/*type*/"+cdtemp.getId()+",");
+ output.println("/*numotd*/"+numotd+",");
+ output.println("otdarray"+cdtemp.getSafeSymbol()+",");
output.println("/* number of fsanalysiswrappers */"+fscounter+",");
output.println("fsanalysiswrapperarray_"+cdtemp.getSafeSymbol()+"};\n");
fscounter = 0;
processedcd.add(cdtemp);
}
-
+
//build an array containing every classes for which code has been build
output.println("struct classanalysiswrapper * classanalysiswrapperarray[]={");
for(Iterator classit = processedcd.iterator(); classit.hasNext();){
if(!classit.hasNext()) output.println("&classanalysiswrapper_"+cdtemp.getSafeSymbol()+"};\n");
else output.println("&classanalysiswrapper_"+cdtemp.getSafeSymbol()+",");
}
- output.println("int numclasses = "+processedcd.size()+";");
+
+ output.println("int numclasses="+processedcd.size()+";");
+ headers.println("extern numclasses;");
+ output.println("int maxotd="+maxotd+";");
+ headers.println("extern maxotd;");
+ headers.println("#endif");
+
}
void genfreekey(struct genhashtable *ht, void * key) {
struct genpointerlist * ptr=ht->bins[genhashfunction(ht,key)];
-
+ if(ptr==NULL) printf("otr is null\n");
if (((ht->comp_function==NULL)&&(ptr->src==key))||((ht->comp_function!=NULL)&&(*ht->comp_function)(ptr->src,key))) {
ht->bins[genhashfunction(ht,key)]=ptr->next;
#include "SimpleHash.h"
#include "task.h"
#include "structdefs.h"
+#include "optionalstruct.h"
void flagorand(void * ptr, int ormask, int andmask);
void flagorandinit(void * ptr, int ormask, int andmask);
struct taskdescriptor * task;
int numParameters;
void ** parameterArray;
+ int containsoptional;
};
int hashCodetpd(struct taskparamdescriptor *);
#include "Queue.h"
#include "SimpleHash.h"
#include "GenericHashtable.h"
-#include "optionalstruct.h"
#include <sys/select.h>
#include <sys/types.h>
#include <sys/mman.h>
struct taskparamdescriptor * currtpd;
struct RuntimeHash * forward;
struct RuntimeHash * reverse;
-
+struct RuntimeHash * exitfsesdata;
int main(int argc, char **argv) {
#ifdef BOEHM_GC
/* Create queue of active tasks */
activetasks=genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd,
(int (*)(void *,void *)) &comparetpd);
-
-
+
+ exitfsesdata=allocateRuntimeHash(10);
/* Process task information */
processtasks();
int hashCodetpd(struct taskparamdescriptor *ftd) {
int hash=(int)ftd->task;
- int i;
- for(i=0;i<ftd->numParameters;i++) {
+ int i;
+ for(i=0;i<ftd->numParameters;i++){
hash^=(int)ftd->parameterArray[i];
}
return hash;
if (ftd1->task!=ftd2->task)
return 0;
for(i=0;i<ftd1->numParameters;i++)
- if (ftd1->parameterArray[i]!=ftd2->parameterArray[i])
+ if(ftd1->parameterArray[i]!=ftd2->parameterArray[i])
return 0;
return 1;
}
-
/* This function sets a tag. */
#ifdef PRECISE_GC
void tagset(void *ptr, struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) {
with the or mask and and's it with the andmask. */
void flagbody(struct ___Object___ *ptr, int flag);
+#ifdef OPTIONAL
+void enqueueoptional(struct ___Object___ * currobj);
+
+struct optionaltaskdescriptor *** makeintersectionotd(int num, struct fsanalysiswrapper ** wrapperarray, int *result){
+ int i,j,k;
+ (*result)=0;
+ struct optionaltaskdescriptor *** bigtmparray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **)*maxotd);
+ struct fsanalysiswrapper * tmpwrapper;
+ struct fsanalysiswrapper * firstwrapper = wrapperarray[0];/*we are sure that num>0*/
+ /*we check if the otd of the first wrapper is contained in all others*/
+ for(i=0; i<firstwrapper->numoptionaltaskdescriptors; i++){
+ struct optionaltaskdescriptor ** tmparray = RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * num);
+ struct optionaltaskdescriptor * otd = firstwrapper->optionaltaskdescriptorarray[i];
+ tmparray[0]=otd;
+ for(j=1; j<num; j++){
+ tmpwrapper = wrapperarray[j];
+ for(k=0; k<tmpwrapper->numoptionaltaskdescriptors; k++){
+ struct optionaltaskdescriptor * tmpotd=tmpwrapper->optionaltaskdescriptorarray[k];
+ if(otd->task->name == tmpotd->task->name){
+ tmparray[j]=tmpotd;
+ goto nextwrapper;
+ }
+ RUNFREE(tmparray);
+ goto nextotd;
+ }
+ nextwrapper:
+ ;
+ }
+ bigtmparray[(*result)]=tmparray;
+ (*result)++;
+ nextotd:
+ ;
+ }
+
+ {/*now allocate the good size for otdarray and put the otds*/
+ struct optionaltaskdescriptor *** otdarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * (*result));
+ for(i=0; i<(*result); i++)
+ otdarray[i]=bigtmparray[i];
+
+ RUNFREE(bigtmparray);
+ return otdarray;
+ }
+}
+#endif
+
void flagorand(void * ptr, int ormask, int andmask) {
int oldflag=((int *)ptr)[1];
int flag=ormask|oldflag;
- flag&=andmask;
- // Not sure why this was necessary
- // if (flag==oldflag) /* Don't do anything */
- // return;
- //else
- flagbody(ptr, flag);
+#ifdef OPTIONAL
+ struct ___Object___ * obj = (struct ___Object___ *)ptr;
+ if(obj->failedstatus==1){/*store the information about exitfses*/
+ int i,j,counter=0, offset=0;
+ for(i=0; i<obj->numotds; i++){
+ counter+=obj->otds[i]->numenterflags;
+ }
+ obj->numexitfses=counter;
+ if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+ obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+ for(i=0; i<obj->numotds; i++){
+ for(j=0; j<obj->otds[i]->numenterflags; j++){
+ oldflag=obj->otds[i]->enterflags[j];
+ flag=ormask|oldflag;
+ flag&=andmask;
+ obj->exitfses[j+offset]=flag;
+ }
+ offset+=obj->otds[i]->numenterflags;
+ }
+ enqueueoptional(ptr);
+ }
+ else
+#endif
+ {
+ flag&=andmask;
+ // Not sure why this was necessary
+ // if (flag==oldflag) /* Don't do anything */
+ // return;
+ //else
+ flagbody(ptr, flag);
+ }
}
-
+
void intflagorand(void * ptr, int ormask, int andmask) {
int oldflag=((int *)ptr)[1];
int flag=ormask|oldflag;
- flag&=andmask;
- if (flag==oldflag) /* Don't do anything */
- return;
- else flagbody(ptr, flag);
+#ifdef OPTIONAL
+ struct ___Object___ * obj = (struct ___Object___ *)ptr;
+ if(obj->failedstatus==1){/*store the information about exitfses*/
+ int i,j,counter=0, offset=0;
+ for(i=0; i<obj->numotds; i++){
+ counter+=obj->otds[i]->numenterflags;
+ }
+ obj->numexitfses=counter;
+ if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+ obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+ for(i=0; i<obj->numotds; i++){
+ for(j=0; j<obj->otds[i]->numenterflags; j++){
+ oldflag=obj->otds[i]->enterflags[j];
+ flag=ormask|oldflag;
+ flag&=andmask;
+ obj->exitfses[j+offset]=flag;
+ }
+ offset+=obj->otds[i]->numenterflags;
+ }
+ enqueueoptional(ptr);
+ }
+ else
+#endif
+ {
+ flag&=andmask;
+ if (flag==oldflag) /* Don't do anything */
+ return;
+ else flagbody(ptr, flag);
+ }
}
void flagorandinit(void * ptr, int ormask, int andmask) {
int oldflag=((int *)ptr)[1];
int flag=ormask|oldflag;
- flag&=andmask;
- flagbody(ptr,flag);
-}
-
-void flagbody(struct ___Object___ *ptr, int flag) {
- struct parameterwrapper *flagptr=(struct parameterwrapper *)ptr->flagptr;
- ptr->flag=flag;
-
- /*Remove object from all queues */
- while(flagptr!=NULL) {
- struct parameterwrapper *next;
- struct ___Object___ * tag=ptr->___tags___;
- RuntimeHashget(flagptr->objectset, (int) ptr, (int *) &next);
- RuntimeHashremove(flagptr->objectset, (int)ptr, (int) next);
- flagptr=next;
- }
-
- {
- struct QueueItem *tmpptr;
- struct parameterwrapper * parameter=objectqueues[ptr->type];
- int i;
- struct parameterwrapper * prevptr=NULL;
- struct ___Object___ *tagptr=ptr->___tags___;
-
- /* Outer loop iterates through all parameter queues an object of
- this type could be in. */
-
- while(parameter!=NULL) {
- /* Check tags */
- if (parameter->numbertags>0) {
- if (tagptr==NULL)
- goto nextloop;//that means the object has no tag but that param needs tag
- else if(tagptr->type==TAGTYPE) {//one tag
- struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
- for(i=0;i<parameter->numbertags;i++) {
- //slotid is parameter->tagarray[2*i];
- int tagid=parameter->tagarray[2*i+1];
- if (tagid!=tagptr->flag)
- goto nextloop; /*We don't have this tag */
- }
- } else {//multiple tags
- struct ArrayObject * ao=(struct ArrayObject *) tagptr;
- for(i=0;i<parameter->numbertags;i++) {
- //slotid is parameter->tagarray[2*i];
- int tagid=parameter->tagarray[2*i+1];
- int j;
- for(j=0;j<ao->___cachedCode___;j++) {
- if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, i)->flag)
- goto foundtag;
- }
- goto nextloop;
- foundtag:
- ;
- }
- }
- }
-
- /* Check flags */
- for(i=0;i<parameter->numberofterms;i++) {
- int andmask=parameter->intarray[i*2];
- int checkmask=parameter->intarray[i*2+1];
- if ((flag&andmask)==checkmask) {
- enqueuetasks(parameter, prevptr, ptr);
- prevptr=parameter;
- break;
- }
+#ifdef OPTIONAL
+ struct ___Object___ * obj = (struct ___Object___ *)ptr;
+ if(obj->failedstatus==1){/*store the information about exitfses*/
+ int i,j,counter=0, offset=0;
+ for(i=0; i<obj->numotds; i++){
+ counter+=obj->otds[i]->numenterflags;
+ }
+ obj->numexitfses=counter;
+ if(obj->exitfses!=NULL) RUNFREE(obj->exitfses);
+ obj->exitfses= RUNMALLOC(sizeof(int) * counter);
+ for(i=0; i<obj->numotds; i++){
+ for(j=0; j<obj->otds[i]->numenterflags; j++){
+ oldflag=obj->otds[i]->enterflags[j];
+ flag=ormask|oldflag;
+ flag&=andmask;
+ obj->exitfses[j+offset]=flag;
}
- nextloop:
- parameter=parameter->next;
+ offset+=obj->otds[i]->numenterflags;
}
- ptr->flagptr=prevptr;
+ enqueueoptional(ptr);
}
+ else
+#endif
+ {
+ flag&=andmask;
+ flagbody(ptr,flag);
+ }
}
-
-void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr) {
+
+#ifdef OPTIONAL
+ removeoptionalfromqueues(int hashcode, struct ___Object___ * currobj, struct parameterwrapper * flagptr){/*find a better way to free the useless instances of the object*/
+ while(flagptr!=NULL) {
+ struct ___Object___ *temp=NULL;
+ struct parameterwrapper *ptr;
+ struct RuntimeNode * node = flagptr->objectset->listhead;
+ while(node!=NULL){
+ temp=(struct ___Object___ *)node->key;
+ if(temp->failedstatus==1 && temp->hashcode==currobj->hashcode){
+ if(temp!=currobj){
+ RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr);
+ RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr);//remove from wrapper
+ //delete the fields that wont be removed by the GC.
+ if(temp->exitfses!=NULL) RUNFREE(temp->exitfses);
+ if(temp->otds!=NULL) RUNFREE(temp->otds);
+ goto nextwrapper;
+ }
+ else{
+ //remove from wrapper
+ RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr);
+ RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr);
+ goto nextwrapper;
+ }
+ }
+ node=node->next;
+ }
+ nextwrapper:
+ ;
+ flagptr=flagptr->next;
+ }
+ }
+#endif
+
+ void flagbody(struct ___Object___ *ptr, int flag) {
+ struct parameterwrapper *flagptr=(struct parameterwrapper *)ptr->flagptr;
+ ptr->flag=flag;
+
+ /*Remove object from all queues */
+ while(flagptr!=NULL) {
+ struct parameterwrapper *next;
+ struct ___Object___ * tag=ptr->___tags___;
+ RuntimeHashget(flagptr->objectset, (int) ptr, (int *) &next);
+ RuntimeHashremove(flagptr->objectset, (int)ptr, (int) next);
+ flagptr=next;
+ }
+
+ {
+ struct QueueItem *tmpptr;
+ struct parameterwrapper * parameter=objectqueues[ptr->type];
+ int i;
+ struct parameterwrapper * prevptr=NULL;
+ struct ___Object___ *tagptr=ptr->___tags___;
+
+ /* Outer loop iterates through all parameter queues an object of
+ this type could be in. */
+
+ while(parameter!=NULL) {
+ /* Check tags */
+ if (parameter->numbertags>0) {
+ if (tagptr==NULL)
+ goto nextloop;//that means the object has no tag but that param needs tag
+ else if(tagptr->type==TAGTYPE) {//one tag
+ struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
+ for(i=0;i<parameter->numbertags;i++) {
+ //slotid is parameter->tagarray[2*i];
+ int tagid=parameter->tagarray[2*i+1];
+ if (tagid!=tagptr->flag)
+ goto nextloop; /*We don't have this tag */
+ }
+ } else {//multiple tags
+ struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+ for(i=0;i<parameter->numbertags;i++) {
+ //slotid is parameter->tagarray[2*i];
+ int tagid=parameter->tagarray[2*i+1];
+ int j;
+ for(j=0;j<ao->___cachedCode___;j++) {
+ if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, i)->flag)
+ goto foundtag;
+ }
+ goto nextloop;
+ foundtag:
+ ;
+ }
+ }
+ }
+
+ /* Check flags */
+ for(i=0;i<parameter->numberofterms;i++) {
+ int andmask=parameter->intarray[i*2];
+ int checkmask=parameter->intarray[i*2+1];
+ if ((flag&andmask)==checkmask) {
+ enqueuetasks(parameter, prevptr, ptr);
+ prevptr=parameter;
+ break;
+ }
+ }
+ nextloop:
+ parameter=parameter->next;
+ }
+ ptr->flagptr=prevptr;
+ }
+ }
+
+#ifdef OPTIONAL
+
+ void enqueueoptional(struct ___Object___ * currobj){
+
+ struct classanalysiswrapper * classwrapper=NULL;
+ struct fsanalysiswrapper * fswrapper=NULL;
+ int counter=0;
+ int numoptionaltaskdescriptors=0;
+ struct optionaltaskdescriptor *** optionaltaskdescriptorarray=NULL;
+ struct fsanalysiswrapper ** goodfswrappersarray=NULL;
+ int numgoodfswrappers=0;
+#ifdef DEBUG
+ if(currobj->numexitfses==0)
+ printf("Handling failed object\nType : %i\nFlag : 0x%x\n", currobj->type, currobj->flag);
+ else{
+ printf("Handling failed object\nType : %i\n", currobj->type);
+ int fscount=0;
+ for(fscount=0; fscount<currobj->numexitfses; fscount++)
+ printf("Flag : 0x%x\n", currobj->exitfses[fscount]);
+ }
+ struct ___Object___ * tagptr = currobj->___tags___;
+ if(tagptr!=NULL){
+ if(tagptr->type==TAGTYPE) {
+ printf("Tag : %i\n", tagptr->flag);}
+ else {
+ struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+ int numbertags = ao->___length___;
+ for(counter=0; counter<numbertags; counter++){
+ printf("Tag : %i\n", ao[counter].flag);
+ }
+ }
+ }
+#endif
+ /*set the object as failed*/
+ currobj->failedstatus = 1;
+
+ /*test what optionaltaskdescriptors are available,
+ find the class corresponding*/
+
+ for(counter = 0; counter<numclasses; counter++){
+ classwrapper = classanalysiswrapperarray[counter];
+ if(classwrapper == NULL){
+ fprintf(stderr, "ERROR : \"struct classanalysiswrapper * classwraper\" is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+ goto nothingtodo;
+ }
+ /*check object type*/
+ if( currobj->type == classwrapper->type)
+ goto classchecked;
+ }
+#ifdef DEBUG
+ printf("No task will use this parameter as optional\n");
+#endif
+ removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+ goto nothingtodo;
+ classchecked:
+ ;
+#ifdef DEBUG
+ printf("Found the class, search through fses\n");
+#endif
+ /*search through fses*/
+ goodfswrappersarray = RUNMALLOC(sizeof(struct fsanalysiswrapper *) * classwrapper->numfsanalysiswrappers); /*max number of good fswrappers*/
+ if(goodfswrappersarray == NULL){
+ fprintf(stderr, "ERROR : \"struct fsanalysiswrapper ** goodfswrappersarray\" is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+ removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+ goto nothingtodo;
+ }
+ for(counter = 0; counter<classwrapper->numfsanalysiswrappers; counter++){
+ /*test the FS of the object (include flags and tags)*/
+ fswrapper = classwrapper->fsanalysiswrapperarray[counter];
+ if(fswrapper == NULL){
+ fprintf(stderr, "ERROR : struct fsanalysiswrapper * is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+ removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+ goto nothingtodo;
+ }
+ /*check tags*/
+ struct ___Object___ * tagptr = currobj->___tags___;
+ if(fswrapper->numtags>0){
+ if (tagptr==NULL)
+ goto nextloop;//that means the object has no tag but that param needs tag
+ else if(tagptr->type==TAGTYPE) {//one tag
+ if(fswrapper->numtags!=1) goto nextloop;//we don't have the right number of tags
+ struct ___TagDescriptor___ * tag=(struct ___TagDescriptor___*) tagptr;
+ if (fswrapper->tags[0]!=tagptr->flag)
+ goto nextloop;
+ }
+ else {//multiple tags
+ struct ArrayObject * ao=(struct ArrayObject *) tagptr;
+ int tag_counter=0;
+ if(ao->___length___!=fswrapper->numtags) goto nextloop;//we don't have the right number of tags
+ for(tag_counter=0;tag_counter<fswrapper->numtags;tag_counter++) {
+ int tagid=fswrapper->tags[tag_counter];
+ int j;
+ for(j=0;j<ao->___cachedCode___;j++) {
+ if (tagid==ARRAYGET(ao, struct ___TagDescriptor___*, tag_counter)->flag)
+ goto foundtag;
+ }
+ goto nextloop;
+ foundtag:
+ ; ;
+ }
+ }
+ }
+
+ //check flags
+ if(currobj->numexitfses==0){/*first time the method is invoqued*/
+ if( currobj->flag == fswrapper->flags){
+ int otdc;
+ optionaltaskdescriptorarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **) * fswrapper->numoptionaltaskdescriptors);
+ numoptionaltaskdescriptors = fswrapper->numoptionaltaskdescriptors;
+ for(otdc = 0; otdc<fswrapper->numoptionaltaskdescriptors; otdc++){
+ struct optionaltaskdescriptor ** tmpptr = RUNMALLOC(sizeof(struct optionaltaskdescriptor *));
+ tmpptr[0] = fswrapper->optionaltaskdescriptorarray[otdc];
+ optionaltaskdescriptorarray[otdc] = tmpptr;
+ }
+ numgoodfswrappers=1;
+ goto fschecked;
+ }
+ }
+ else if(currobj->numexitfses==1){/*one fs exit*/
+ if(currobj->exitfses[0] == fswrapper->flags){
+ int otdc;
+ optionaltaskdescriptorarray = RUNMALLOC(sizeof(struct optionaltaskdescriptor **) * fswrapper->numoptionaltaskdescriptors);
+ numoptionaltaskdescriptors = fswrapper->numoptionaltaskdescriptors;
+ for(otdc = 0; otdc<fswrapper->numoptionaltaskdescriptors; otdc++){
+ struct optionaltaskdescriptor ** tmpptr = RUNMALLOC(sizeof(struct optionaltaskdescriptor *));
+ tmpptr[0] = fswrapper->optionaltaskdescriptorarray[otdc];
+ optionaltaskdescriptorarray[otdc] = tmpptr;
+ }
+ numgoodfswrappers=1;
+ goto fschecked;
+ }
+ }
+ else{
+ int fscount=0;
+ for(fscount=0; fscount<currobj->numexitfses; fscount++){
+
+ if( currobj->exitfses[fscount] == fswrapper->flags ){/*see if the fswraper correspond to one of the fses*/
+ goodfswrappersarray[numgoodfswrappers]=fswrapper;
+ numgoodfswrappers++;
+ }
+ }
+ if(counter==classwrapper->numfsanalysiswrappers-1) goto makeintersection; /*last fswrapper*/
+ }
+ nextloop:
+ ;
+ }
+ nofs:
+ ;
+#ifdef DEBUG
+ printf("FS not found, Nothing more to do\n");
+#endif
+ removeoptionalfromqueues(currobj->hashcode,currobj, objectqueues[currobj->type]);
+ goto nothingtodo;
+ makeintersection:
+ ;
+ if(numgoodfswrappers==0 || numgoodfswrappers==1) goto nofs; /*nothing has been found, we expect more than one wrapper for multiple flags*/
+ optionaltaskdescriptorarray = makeintersectionotd(numgoodfswrappers, goodfswrappersarray, &numoptionaltaskdescriptors);
+ if(optionaltaskdescriptorarray==NULL){
+ fprintf(stderr, "ERROR : struct optionaltaskdescriptor ** is a NULL pointer\n, Analysis has been skipped, check Runtime/task.c, function enqueueoptional\n");
+ goto nothingtodo;
+ }
+
+ fschecked:
+ ;
+#ifdef DEBUG
+ printf("FS(es) found, intersection created, %i potential tasks :\n", numoptionaltaskdescriptors);
+
+
+ /*find the parameterwrapper corresponding to the potential task*/
+ for(counter = 0; counter<numoptionaltaskdescriptors; counter++){
+ struct optionaltaskdescriptor ** tmpptr = optionaltaskdescriptorarray[counter];
+ printf("Task %s\n", tmpptr[0]->task->name);
+ }
+
+#endif
+ {
+ struct parameterwrapper * prevptr = NULL;
+ struct parameterwrapper * flagptr = objectqueues[currobj->type];
+ removeoptionalfromqueues(currobj->hashcode,currobj, flagptr);
+ /*process for each otd*/
+ for(counter = 0; counter<numoptionaltaskdescriptors; counter++){
+ struct parameterwrapper * parameter = objectqueues[currobj->type];
+ struct optionaltaskdescriptor ** tmpptr = optionaltaskdescriptorarray[counter];
+ struct optionaltaskdescriptor * currotd = tmpptr[0];
+ int otd_counter=0;
+ while(parameter->task != currotd->task)
+ parameter=parameter->next;
+#ifdef DEBUG
+ printf("found parameterwrapper for task : %s\n", parameter->task->name);
+#endif
+
+ struct ___Object___ * newobj = RUNMALLOC(sizeof(struct ___Object___));
+ (*newobj)=(*currobj);
+ newobj->numotds=numgoodfswrappers;
+ newobj->otds=RUNMALLOC(sizeof(struct optionaltaskdescriptor *) * numgoodfswrappers);
+ for(otd_counter=0; otd_counter<numgoodfswrappers; otd_counter++){
+ newobj->otds[otd_counter]=tmpptr[otd_counter];
+ }
+ enqueuetasks(parameter, prevptr, newobj);
+ prevptr = parameter;
+
+ nextotd:
+ ;
+ }
+
+ }
+ nothingtodo:
+
+ /*if(currobj->exitfses!=NULL) RUNFREE(currobj->exitfses);
+ if(currobj->otds!=NULL) RUNFREE(currobj->otds);*///there has been a problem just before the program exit, maybe due to the GC ?
+ RUNFREE(optionaltaskdescriptorarray);
+ ;
+ }
+
+ /*we need to check if the object is optional, in this case, test the predicate*/
+ /*here is the code for predicate checking*/
+ /*The code has not been tested. I don't even know if it is working or efficient but it is a lead...
+ if(currotd->numpredicatemembers == 0){
+ printf("this task can be fired\n");
+ goto enqueuetask;
+ }
+ else{
+ int pred_counter;
+ int predicatetrue = 0;
+ for(pred_counter = 0; pred_counter<currotd->numpredicatemembers; pred_counter++){
+ struct predicatemember * currpred = currotd->predicatememberarray[pred_counter];
+ printf("predicate type : %i\n", currpred->type);
+
+ //test if the predicate member is true
+ struct parameterwrapper * paramwrapper = objectqueues[currpred->type];
+ while(paramwrapper!=NULL){
+ struct RuntimeIterator * it = allocateRuntimeIterator(paramwrapper->objectset->listhead);
+ do{
+ struct ___Object___ * obj = (struct ___Object___ *)Runkey(it);
+ printf("obj type : %i\n", obj->type);
+ if(obj->type == currpred->type){
+ //test the predicate
+ printf("predicate to test\n");
+ //only if good
+ goto enqueuetask;
+ }
+ Runnext(it);
+ }while(RunhasNext(it));
+ paramwrapper=paramwrapper->next;
+ }
+ printf("not the good predicate");
+ //goto endanalysis
+ }
+ //the predicate members have to be all true
+ }*/
+
+#endif
+
+ void enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr) {
void * taskpointerarray[MAXTASKPARAMS];
int j;
int numparams=parameter->task->numParameters;
while(1) {
/* Enqueue current state */
+ int launch = 0;
struct taskparamdescriptor *tpd=RUNMALLOC(sizeof(struct taskparamdescriptor));
tpd->task=task;
tpd->numParameters=numiterators+1;
tpd->parameterArray=RUNMALLOC(sizeof(void *)*(numiterators+1));
- for(j=0;j<=numiterators;j++)
+ for(j=0;j<=numiterators;j++){
+#ifdef OPTIONAL
+#ifdef DEBUG
+ struct ___Object___ * obj = (struct ___Object___ *)taskpointerarray[j];
+ if(obj->failedstatus==1)
+ printf("parameter %i used as optional for task %s\n", obj->type, task->name);
+#endif
+#endif
tpd->parameterArray[j]=taskpointerarray[j];//store the actual parameters
-
+ }
/* Enqueue task */
- if (!gencontains(failedtasks, tpd)&&!gencontains(activetasks,tpd)) {
+ if ((!gencontains(failedtasks, tpd)&&!gencontains(activetasks,tpd))) {
genputtable(activetasks, tpd, tpd);
} else {
RUNFREE(tpd->parameterArray);
arithmatic errors. */
void myhandler(int sig, siginfo_t *info, void *uap) {
+ sigset_t toclear;
#ifdef DEBUG
printf("sig=%d\n",sig);
printf("signal\n");
#endif
+ sigemptyset(&toclear);
+ sigaddset(&toclear, sig);
+ sigprocmask(SIG_UNBLOCK, &toclear,NULL);
longjmp(error_handler,1);
}
int i;
currtpd=(struct taskparamdescriptor *) getfirstkey(activetasks);
genfreekey(activetasks, currtpd);
-
- /* Check if this task has failed */
+
+ /* Check if this task has failed, allow a task that contains optional objects to fire */
if (gencontains(failedtasks, currtpd)) {
// Free up task parameter descriptor
RUNFREE(currtpd->parameterArray);
}
int numparams=currtpd->task->numParameters;
int numtotal=currtpd->task->numTotal;
-
+
/* Make sure that the parameters are still in the queues */
for(i=0;i<numparams;i++) {
void * parameter=currtpd->parameterArray[i];
struct parameterwrapper *pw=(struct parameterwrapper *) pd->queue;
int j;
/* Check that object is still in queue */
- if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) {
+#ifdef OPTIONAL
+ struct ___Object___ * obj = (struct ___Object___ *)parameter;
+ if(obj->failedstatus==1){
+ struct ___Object___ *temp=NULL;
+ struct parameterwrapper * ptr;
+ struct RuntimeNode * node = pw->objectset->listhead;
+ while(node!=NULL){
+ temp=(struct ___Object___ *)node->key;
+ if(temp->failedstatus==1 && temp->hashcode==obj->hashcode){
+ if(temp==obj)
+ goto parameterpresent;
+ }
+ node=node->next;
+ }
RUNFREE(currtpd->parameterArray);
RUNFREE(currtpd);
goto newtask;
}
+ else
+#endif
+ {
+ if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) {
+ RUNFREE(currtpd->parameterArray);
+ RUNFREE(currtpd);
+ goto newtask;
+ }
+ }
+ parameterpresent:
+ ;
/* Check that object still has necessary tags */
for(j=0;j<pd->numbertags;j++) {
int slotid=pd->tagarray[2*j]+numparams;
void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse);
int x;
if (x=setjmp(error_handler)) {
+ int counter;
/* Recover */
- int h;
#ifdef DEBUG
printf("Fatal Error=%d, Recovering!\n",x);
#endif
genputtable(failedtasks,currtpd,currtpd);
restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse);
- /*where we have to insert the code for optional tasks
- all the pointers I need are in currtpd->parameterArray */
+
+#ifdef OPTIONAL
+#ifdef DEBUG
+ printf("%i object(s) restored\n", currtpd->task->numParameters);
+#endif
+
+ for(counter=0; counter<currtpd->task->numParameters; counter++){
+ //remove the object from the previous parameterwrapper (maybe not necessary)
+ //do a new instance of the object. It allows the restored object to be used by other tasks as a non optional arg.
+ struct ___Object___ * currobj = RUNMALLOC(sizeof(struct ___Object___));
+ (*currobj)=(*(struct ___Object___ *)currtpd->parameterArray[counter]);
+ currobj->numexitfses = 0;
+ currobj->exitfses = NULL;
+ currobj->otds=NULL;
+ currobj->hashcode=(int)currobj;
+ enqueueoptional( currobj );
+ }
+#endif
freeRuntimeHash(forward);
freeRuntimeHash(reverse);
freemalloc();
((int *)taskpointerarray)[0]=currtpd->task->numParameters;
taskpointerarray[1]=NULL;
#endif
-
- if (debugtask) {
+ if(debugtask){
printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
} else
((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
+
freeRuntimeHash(forward);
freeRuntimeHash(reverse);
freemalloc();
}
}
}
-
+
/* This function processes an objects tags */
void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams) {
int i;
-
+
for(i=0;i<pd->numbertags;i++) {
int slotid=pd->tagarray[2*i];
int tagid=pd->tagarray[2*i+1];
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+ private int number;
+
+ public void Test(){
+ number=1;
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+ public void decrease(){
+ number--;
+ }
+
+ public int getNumber(){
+ return number;
+ }
+
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}){
+ o.decrease();
+ System.printString("Inside ONE\n");
+ int i = 100/o.getNumber();
+ taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+ System.printString("Inside TWO\n");
+ taskexit(o {!B, C});
+
+}
+
+task THREE(optional Test o{B}){
+System.printString("Inside THREE\n");
+ taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+ taskexit(o {!C, E});
+
+
+}
+
+task FIVE(Test o{D}){
+ System.printString("Inside FIVE\n");
+ taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+ System.printString("Inside SIX\n");
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+ System.printString("Inside SEVEN\n");
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}){
+ System.printString("Inside EIGHT\n");
+ taskexit(o {!G, H});
+
+}
+
--- /dev/null
+There is an error probably due to a leak of memory.
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+ private int number;
+
+ public void Test(){
+ number=1;
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+ public void decrease(){
+ number--;
+ }
+
+ public int getNumber(){
+ return number;
+ }
+
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}){
+ o.decrease();
+ System.printString("Inside ONE\n");
+ int i = 100/o.getNumber();
+ taskexit(o {!A, B});
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+ System.printString("Inside TWO\n");
+ if(false) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+
+}
+
+/*task THREE(Test o{B}){
+
+ taskexit(o {!B, D});
+ }*/
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+ taskexit(o {!C, E});
+
+
+}
+
+task FIVE(optional Test o{D}){
+ System.printString("Inside FIVE\n");
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+ System.printString("Inside SIX\n");
+ taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+ System.printString("Inside SEVEN\n");
+ taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+ System.printString("Inside EIGHT\n");
+
+ if(false) taskexit(o {!G, H});
+ else taskexit(o {!G, I});
+
+}
+
+task NINE(optional Test o{H}){
+System.printString("Inside NINE\n");
+taskexit(o {!H});
+}
+task TEN(optional Test o{I}){
+System.printString("Inside TEN\n");
+ if(true) taskexit(o {!I,L });
+ else taskexit(o {!I,M });
+}
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+ private int number;
+
+ public void Test(){
+ number=1;
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+ public void decrease(){
+ number--;
+ }
+
+ public int getNumber(){
+ return number;
+ }
+
+
+}
+
--- /dev/null
+//Same as the previous test but object is not optional
+//for task two. Implies multiple entering flags
+// (tricky part we spoke about, Brian and William)
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}){
+ o.decrease();
+ System.printString("Inside ONE\n");
+ int i = 100/o.getNumber();
+ taskexit(o {!A, B});
+ taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+ System.printString("Inside TWO\n");
+ if(false) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+
+}
+
+/*task THREE(Test o{B}){
+
+ taskexit(o {!B, D});
+ }*/
+
+task FOUR(Test o{C}){
+System.printString("Inside FOUR\n");
+ taskexit(o {!C, E});
+
+
+}
+
+task FIVE(optional Test o{D}){
+ System.printString("Inside FIVE\n");
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+ System.printString("Inside SIX\n");
+ taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+ System.printString("Inside SEVEN\n");
+ taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+ System.printString("Inside EIGHT\n");
+
+ if(false) taskexit(o {!G, H});
+ else taskexit(o {!G, I});
+
+}
+
+task NINE(optional Test o{H}){
+System.printString("Inside NINE\n");
+taskexit(o {!H});
+}
+task TEN(optional Test o{I}){
+System.printString("Inside TEN\n");
+ if(true) taskexit(o {!I,L });
+ else taskexit(o {!I,M });
+}
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{C}){
+
+ taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}){
+
+ taskexit(o {!D, E});
+}
+/*
+task FIVE(optional Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(optional Test o{C}){
+
+ taskexit(o {!C, D});
+
+}
+
+task FOUR(optional Test o{D}){
+
+ taskexit(o {!D, B});
+
+
+}
+
+task FIVE(optional Test o{D}){
+
+ taskexit(o {!D, E});
+
+}
+
+task SIX(optional Test o{E}){
+
+ if (true) taskexit(o {!E, F});
+
+}
+/*
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ if(o.is()) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+
+}
+
+/*task THREE(Test o{B}){
+
+ taskexit(o {!B, D});
+ }*/
+
+task FOUR(optional Test o{C}){
+
+ taskexit(o {!C, E});
+
+
+}
+
+task FIVE(optional Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+
+ taskexit(o {!E, G, J});
+
+}
+
+task SEVEN(optional Test o{F}){
+
+ taskexit(o {!F, G, K});
+
+}
+
+task EIGHT(optional Test o{G}){
+
+
+ if(true) taskexit(o {!G, H});
+ else taskexit(o {!G, I});
+
+}
+
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ if(o.is()) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C||D}){
+
+ taskexit(o {!C, !D, E});
+}
+
+task FOUR(optional Test o{C||D}){
+
+ taskexit(o {!C, !D, F});
+
+
+}
+/*
+task FIVE(Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{B}){
+
+ taskexit(o {!B, D});
+}
+
+task FOUR(optional Test o{C}){
+
+ taskexit(o {!C, E});
+}
+
+task FIVE(optional Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+/*
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{B}){
+
+ taskexit(o {!B, D});
+}
+
+task FOUR(optional Test o{D||C}){
+
+ taskexit(o {!D,!C, F});
+
+
+}
+/*
+task FIVE(Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ if(o.is()) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C}){
+
+ taskexit(o {!C, E});
+}
+
+task FOUR(optional Test o{D}){
+
+ taskexit(o {!D, F});
+
+
+}
+/*
+task FIVE(Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ if(o.is()) taskexit(o {!B, C});
+ else taskexit(o {!B, D});
+}
+
+task THREE(optional Test o{C||D}){
+
+ taskexit(o {!C,!D, E});
+}
+/*
+task FOUR(Test o{D}){
+
+ taskexit(o {!D, F});
+
+
+}
+
+task FIVE(Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(Test o{B}){
+
+ taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}){
+
+ taskexit(o {!C, E});
+
+
+}
+
+task FIVE(Test o{D}){
+
+ taskexit(o {!D, F});
+
+}
+
+task SIX(optional Test o{E}){
+
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(optional Test o{C}){
+
+ taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}){
+
+ taskexit(o {!D, E});
+
+
+}
+
+task FIVE(optional Test o{C}){
+
+ taskexit(o {C});
+
+}
+/*
+task SIX(Test o{E}){
+
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(optional Test o{C}){
+
+ if (true) taskexit(o {!C, D});
+ else taskexit(o {C});
+}
+
+task FOUR(optional Test o{D}){
+
+ taskexit(o {!D, E});
+
+
+}
+/*
+task FIVE(Test o{C}){
+
+ taskexit(o {C});
+
+}
+
+task SIX(Test o{E}){
+
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(optional Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(optional Test o{C}){
+
+ taskexit(o {!C, D});
+
+}
+
+task FOUR(optional Test o{D}){
+
+ if(true) taskexit(o {!D, E});
+ else taskexit(o {!D, B});
+
+}
+
+task FIVE(optional Test o{E}){
+
+ taskexit(o {!E, F});
+
+}
+/*
+task SIX(Test o{E}){
+
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(Test o{G}){
+
+ taskexit(o {!G, H});
+
+}
+*/
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+public class Test2 {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test2(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+
+ Test o = new Test() {A};
+ Test2 o2 = new Test2() {G};
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(optional Test o{B}){
+
+ taskexit(o {!B, C});
+}
+
+task THREE(optional Test o{C}, Test2 o2{G}){
+
+ taskexit(o {!C, D});
+}
+
+task FOUR(optional Test o{D}, Test2 o2{G}){
+
+ taskexit(o {!D, E});
+}
--- /dev/null
+public class Test {
+
+
+ flag A;
+ flag B;
+ flag C;
+ flag D;
+ flag E;
+ flag F;
+ flag G;
+ flag H;
+ flag I;
+ flag J;
+ flag K;
+ flag L;
+ flag M;
+
+ public void Test(){
+ }
+
+ public boolean is(){
+ return true;
+ }
+
+}
+
--- /dev/null
+
+
+task Startup(StartupObject s {initialstate}){
+ tag t =new tag(link);
+ Test o = new Test() {A}{t};
+ taskexit(s {!initialstate});
+
+}
+
+task ONE(Test o{A}{link l}){
+
+ taskexit(o {!A, B});
+}
+
+task TWO(Test o{B}{link l}){
+
+ taskexit(o {!B, C});
+
+}
+
+task THREE(Test o{B}{link l}){
+
+ taskexit(o {!B, D});
+}
+
+task FOUR(Test o{C}{link l}){
+ tag f =new tag(link);
+ taskexit(o {!C, E}{!l, f});
+
+
+}
+
+task FIVE(Test o{D}{link l}){
+ tag h =new tag(link);
+ taskexit(o {!D, F}{!l, h});
+
+}
+
+task SIX(optional Test o{E}{link l}){
+
+ taskexit(o {!E, G});
+
+}
+
+task SEVEN(Test o{F}{link l}){
+
+ taskexit(o {!F, G});
+
+}
+
+task EIGHT(optional Test o{G}{link l}){
+
+ taskexit(o {!G, H});
+
+}
+
EXTRAOPTIONS=''
MAINFILE='a'
JAVAOPTS=''
+OPTIONALFLAG=false
if [[ -z $1 ]]
then
elif [[ $1 = '-optional' ]]
then
JAVAOPTS="$JAVAOPTS -optional"
+OPTIONALFLAG=true
elif [[ $1 = '-dmalloc' ]]
then
USEDMALLOC=true
FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c"
fi
+if $OPTIONALFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
+FILES="$FILES tmpbuilddirectory/optionalarrays.c"
+fi
+
if $THREADFLAG
then
FILES="$FILES $ROBUSTROOT/Runtime/thread.c"