bug fixes
authorjjenista <jjenista>
Mon, 17 Aug 2009 20:30:04 +0000 (20:30 +0000)
committerjjenista <jjenista>
Mon, 17 Aug 2009 20:30:04 +0000 (20:30 +0000)
Robust/src/Analysis/MLP/VarSrcTokTable.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Tests/mlp/tinyTest/test.java

index bb48bc5bd238b8d302bce72b7651e46a140301dc..0f15ea5a84e4668cdf4deca43991e636afe8e821 100644 (file)
@@ -305,28 +305,45 @@ public class VarSrcTokTable {
   // any curr tokens increase age by 1
   public void age( FlatSESEEnterNode curr ) {
 
+    Set<VariableSourceToken> forRemoval =
+      new HashSet<VariableSourceToken>();
+
+    Set<VariableSourceToken> forAddition =
+      new HashSet<VariableSourceToken>();
+
     Iterator<VariableSourceToken> itr = trueSet.iterator();
     while( itr.hasNext() ) {
       VariableSourceToken vst = itr.next();
 
       if( vst.getSESE().equals( curr ) ) {
 
-       Integer newAge = vst.getAge()+1;
-       if( newAge > MAX_AGE ) {
-         newAge = MAX_AGE;
-       }
+       // only age if the token isn't already the maximum age
+       if( vst.getAge() < MAX_AGE ) {
        
-       remove( vst );
-
-        add( new VariableSourceToken( vst.getRefVars(), 
-                                     curr,                                           
-                                     newAge,
-                                     vst.getAddrVar()
-                                     )
-            );
+         forRemoval.add( vst );
+
+         forAddition.add( new VariableSourceToken( vst.getRefVars(), 
+                                                   curr,                                           
+                                                   vst.getAge() + 1,
+                                                   vst.getAddrVar()
+                                                   )
+                          );
+       }
       }        
     }
     
+    itr = forRemoval.iterator();
+    while( itr.hasNext() ) {
+      VariableSourceToken vst = itr.next();
+      remove( vst );
+    }
+    
+    itr = forRemoval.iterator();
+    while( itr.hasNext() ) {
+      VariableSourceToken vst = itr.next();
+      add( vst );
+    }
+
     assertConsistency();
   }
 
index 5e55f09f0e7c3f0b28fd9dc56662f9d56c955d11..cff00ce7efd5b137aa6271030de098e4b10ad9dc 100644 (file)
@@ -1863,6 +1863,7 @@ public class BuildCode {
       output.println("};");
     }
 
+    output.println("   /* regular local primitives */");
     for(int i=0; i<objecttemp.numPrimitives(); i++) {
       TempDescriptor td=objecttemp.getPrimitive(i);
       TypeDescriptor type=td.getType();
@@ -1876,6 +1877,7 @@ public class BuildCode {
 
 
     // declare variables for naming static SESE's
+    output.println("   /* static SESE names */");
     Iterator<SESEandAgePair> pItr = fsen.getNeededStaticNames().iterator();
     while( pItr.hasNext() ) {
       SESEandAgePair p = pItr.next();
@@ -1883,6 +1885,7 @@ public class BuildCode {
     }
 
     // declare variables for tracking dynamic sources
+    output.println("   /* dynamic variable sources */");
     Iterator<TempDescriptor> dynSrcItr = fsen.getDynamicVarSet().iterator();
     while( dynSrcItr.hasNext() ) {
       TempDescriptor dynSrcVar = dynSrcItr.next();
@@ -1892,6 +1895,7 @@ public class BuildCode {
 
     // declare local temps for in-set primitives, and if it is
     // a ready-source variable, get the value from the record
+    output.println("   /* local temps for in-set primitives */");
     Iterator<TempDescriptor> itrInSet = fsen.getInVarSet().iterator();
     while( itrInSet.hasNext() ) {
       TempDescriptor temp = itrInSet.next();
@@ -1907,11 +1911,12 @@ public class BuildCode {
 
     // declare local temps for out-set primitives if its not already
     // in the in-set, and it's value will get written so no problem
+    output.println("   /* local temp for out-set prim, not already in the in-set */");
     Iterator<TempDescriptor> itrOutSet = fsen.getOutVarSet().iterator();
     while( itrOutSet.hasNext() ) {
       TempDescriptor temp = itrOutSet.next();
       TypeDescriptor type = temp.getType();
-      if( !type.isPtr() && !fsen.getReadyInVarSet().contains( temp ) ) {
+      if( !type.isPtr() && !fsen.getInVarSet().contains( temp ) ) {
        output.println("   "+type+" "+temp+";");       
       }
     }    
@@ -1936,17 +1941,17 @@ public class BuildCode {
       TempDescriptor temp = tempItr.next();
 
       // go grab it from the SESE source
-      output.println("     if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
-      output.println("       "+generateTemp( fsen.getfmBogus(), temp, null )+
-                            " = *(("+temp.getType()+"*) ("+
+      output.println("   if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
+      output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
+                            " = *(("+temp.getType().toPrettyString()+"*) ("+
                             paramsprefix+"->"+temp+"_srcSESE + "+
                             paramsprefix+"->"+temp+"_srcOffset));");
 
       // or if the source was our parent, its in the record to grab
-      output.println("     } else {");
-      output.println("       "+generateTemp( fsen.getfmBogus(), temp, null )+
-                            " = "+paramsprefix+"->"+temp+";");
-      output.println("     }");
+      output.println("   } else {");
+      output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
+                          " = "+paramsprefix+"->"+temp+";");
+      output.println("   }");
     }
 
     // Check to see if we need to do a GC if this is a
@@ -2963,16 +2968,16 @@ public class BuildCode {
     
     // if parent is stalling on you, let them know you're done
     if( fsexn.getFlatEnter() != mlpa.getRootSESE() ) {
-      output.println("     psem_give( &("+paramsprefix+"->common.stallSem) );");
+      output.println("   psem_give( &("+paramsprefix+"->common.stallSem) );");
     }
 
     // last of all, decrement your parent's number of running children    
-    output.println("     if( "+paramsprefix+"->common.parent != NULL ) {");
-    output.println("       pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
-    output.println("       --("+paramsprefix+"->common.parent->numRunningChildren);");
-    output.println("       pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
-    output.println("       pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
-    output.println("     }");    
+    output.println("   if( "+paramsprefix+"->common.parent != NULL ) {");
+    output.println("     pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
+    output.println("     --("+paramsprefix+"->common.parent->numRunningChildren);");
+    output.println("     pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
+    output.println("     pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
+    output.println("   }");    
   }
 
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,  
@@ -2999,13 +3004,14 @@ public class BuildCode {
       
       SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
       
+      FlatSESEEnterNode current = fwdvn.getEnclosingSESE();
+
       output.println("   {");
 
-      if( fwdvn.getEnclosingSESE().equals( vst.getSESE() ) ) {
+      if( current.equals( vst.getSESE() ) ) {
        // if the src comes from this SESE, it's a method local variable,
        // mark src pointer NULL to signify that the var is up-to-date
        output.println("     "+vst.getAddrVar()+"_srcSESE = NULL;");
-       output.println("     "+refVar+" = "+vst.getAddrVar()+";");
 
       } else {
        // otherwise we track where it will come from
index 5fb474354337317f25629e40c0d07acda8b463d8..17e45e0b93c6aa12be024d9bfef37ebcf397d78a 100644 (file)
@@ -12,46 +12,31 @@ public class Test {
     int y = Integer.parseInt( args[1] );
     //System.out.println( "root: x="+x+", y="+y );
 
-
+    /*
     Foo foo = new Foo();
     foo.f = x;
-
-    sese jumbo {
-      foo.f = y;
-    }
-
-    System.out.println( "f="+foo.f );
-
+    */
 
     /*
-    if( x > 3 ) {
-      sese fee {
-       y = y + 10;
-       //System.out.println( "fee: y="+y );
+    int[] a = new int[x];
+    for( int i = 0; i < x; ++i ) {
+      sese fill {
+       a[i] = i;
       }
     }
+    */
 
-    System.out.println( "yo" );
-
-    sese fie {
-      double xyz = -2.0;
+    int total = 0;
+    for( int i = 0; i < x; ++i ) {
+      sese sum {
+       total = total + i;
+      }
     }
 
-    System.out.println( "go" );
-
-    double jjj = Math.abs( xyz );
-
-
 
-    // see that values from sese fi are
-    // forwarded to this sibling
-    sese foe {
-      //System.out.println( "fo: x="+x+", y="+y );
-      System.out.println( "foe: y="+y+" jjj="+jjj );
-      //System.out.println( "foe: y="+y );
-    }
-    */
+    //setTo3( foo );
 
+    System.out.println( "total="+total );
 
     // just for testing root's ability to
     // realize a single exit after all returns
@@ -60,4 +45,12 @@ public class Test {
     //  return;
     //}
   }
+
+  /*
+  public static void setTo3( Foo foo ) {
+    sese func {
+      foo.f = 3;
+    }   
+  }
+  */
 }