// 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();
}
output.println("};");
}
+ output.println(" /* regular local primitives */");
for(int i=0; i<objecttemp.numPrimitives(); i++) {
TempDescriptor td=objecttemp.getPrimitive(i);
TypeDescriptor type=td.getType();
// 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();
}
// declare variables for tracking dynamic sources
+ output.println(" /* dynamic variable sources */");
Iterator<TempDescriptor> dynSrcItr = fsen.getDynamicVarSet().iterator();
while( dynSrcItr.hasNext() ) {
TempDescriptor dynSrcVar = dynSrcItr.next();
// 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();
// 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+";");
}
}
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
// 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,
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
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
// return;
//}
}
+
+ /*
+ public static void setTo3( Foo foo ) {
+ sese func {
+ foo.f = 3;
+ }
+ }
+ */
}