// Output function prototypes and structures for SESE's and code
if( state.MLP ) {
+
+ // used to differentiate, during code generation, whether we are
+ // passing over SESE body code, or non-SESE code
nonSESEpass = false;
// first generate code for each sese's internals
// Build normal temp object for bogus method descriptor
TempObject objecttemps = new TempObject( objectparams, mdBogus, tag++ );
tempstable.put( mdBogus, objecttemps );
-
- for(Iterator nodeit=fsen.getNodeSet().iterator(); nodeit.hasNext();) {
- FlatNode fn=(FlatNode)nodeit.next();
- TempDescriptor[] writes=fn.writesTemps();
- for(int i=0; i<writes.length; i++) {
- TempDescriptor temp=writes[i];
- TypeDescriptor type=temp.getType();
- if (type.isPtr()&&GENERATEPRECISEGC) {
- objecttemps.addPtr(temp);
+
+ for( Iterator nodeit = fsen.getNodeSet().iterator(); nodeit.hasNext(); ) {
+ FlatNode fn = (FlatNode)nodeit.next();
+ TempDescriptor[] writes = fn.writesTemps();
+
+ for( int i = 0; i < writes.length; i++ ) {
+ TempDescriptor temp = writes[i];
+ TypeDescriptor type = temp.getType();
+
+ if( type.isPtr() ) {
+ objecttemps.addPtr( temp );
} else {
- objecttemps.addPrim(temp);
+ objecttemps.addPrim( temp );
}
}
}
PrintWriter outputMethods
) {
- ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
-
- TempObject objecttemps = (TempObject) tempstable.get( fsen.getmdBogus() );
+ ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
+ TempObject objecttemps = (TempObject) tempstable .get( fsen.getmdBogus() );
// generate locals structure
- outputStructs.println("struct "+fsen.getcdEnclosing().getSafeSymbol()+fsen.getmdBogus().getSafeSymbol()+"_"+fsen.getmdBogus().getSafeMethodDescriptor()+"_locals {");
+ outputStructs.println("struct "+
+ fsen.getcdEnclosing().getSafeSymbol()+
+ fsen.getmdBogus().getSafeSymbol()+"_"+
+ fsen.getmdBogus().getSafeMethodDescriptor()+
+ "_locals {");
outputStructs.println(" INTPTR size;");
outputStructs.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
+
+ if( fsen.getPrettyIdentifier().equals( "calc" ) ) {
+ System.out.println( " got a pointer "+temp );
+ }
+
if (temp.getType().isNull())
outputStructs.println(" void * "+temp.getSafeSymbol()+";");
else
- outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
+ outputStructs.println(" struct "+
+ temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+";");
}
outputStructs.println("};\n");
return;
}
+ // get the enter node for this exit that has meta data embedded
+ FlatSESEEnterNode fsen = fsexn.getFlatEnter();
+
// there may be an SESE in an unreachable method, skip over
- if( !mlpa.getAllSESEs().contains( fsexn.getFlatEnter() ) ) {
+ if( !mlpa.getAllSESEs().contains( fsen ) ) {
return;
}
// also, if we have encountered a placeholder, just jump it
- if( fsexn.getFlatEnter().getIsCallerSESEplaceholder() ) {
+ if( fsen.getIsCallerSESEplaceholder() ) {
return;
}
output.println(" }");
// copy out-set from local temps into the sese record
- Iterator<TempDescriptor> itr = fsexn.getFlatEnter().getOutVarSet().iterator();
+ Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
while( itr.hasNext() ) {
- TempDescriptor temp = itr.next();
+ TempDescriptor temp = itr.next();
+
+ // only have to do this for primitives
+ if( !temp.getType().isPrimitive() ) {
+ continue;
+ }
+
+ // have to determine the context enclosing this sese
+ boolean useParentContext = false;
+
+ if( fsen != mlpa.getMainSESE() ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
+
+ String from;
+ if( useParentContext ) {
+ from = generateTemp( fsen.getParent().getfmBogus(), temp, null );
+ } else {
+ from = generateTemp( fsen.getfmEnclosing(), temp, null );
+ }
+
output.println(" "+paramsprefix+
"->"+temp.getSafeSymbol()+
- " = "+temp.getSafeSymbol()+";" );
+ " = "+from+";");
}
// mark yourself done, your SESE data is now read-only
+public class Foo {
+ public int z;
+
+ public Foo( int z ) {
+ this.z = z;
+ }
+}
public class Test {
public static void main( String args[] ) {
int x = Integer.parseInt( args[0] );
- doSomeWork( x );
+ Foo f = new Foo( x + 10000 );
+ doSomeWork( x, f );
nullMethodBodyFinalNode();
}
- public static void doSomeWork( int x ) {
+ public static void doSomeWork( int x, Foo f ) {
for( int i = 0; i < x; ++i ) {
sese calc {
+ Foo g = new Foo( i );
int sum = 0;
for( int j = 0; j <= i; ++j ) {
sum = calculateStuff( sum, 1, 0 );
if( i % 3 == 0 ) {
sum = sum + (i % 20);
}
+ g.z = sum + 1000;
+ }
+ sese modobj {
+ g.z = g.z + f.z;
}
if( i % 2 == 0 ) {
sese change {
for( int l = 0; l < 3; ++l ) {
sum = calculateStuff( sum, 2, 2 );
- }
- }
+ }
+ }
sese prnt {
- mightPrint( x, i, sum );
+ mightPrint( x, i, sum, g );
}
}
}
}
}
- public static void mightPrint( int x, int i, int sum ) {
+ public static void mightPrint( int x, int i, int sum, Foo g ) {
if( i == x - 1 ) {
- System.out.println( "sum of integers 0-"+i+"("+x+") is "+sum );
+ System.out.println( "Results "+i+", "+x+", "+sum+", "+g.z );
}
}
}
+public class Foo {
+ public int z;
+
+ public Foo( int z ) {
+ this.z = z;
+ }
+}
public class Test {
- public static void main( String args[] ) {
+ public static void main( String args[] ) {
int x = Integer.parseInt( args[0] );
- doSomeWork( x );
+ Foo f = new Foo( x + 10000 );
+ doSomeWork( x, f );
+ nullMethodBodyFinalNode();
}
- public static void doSomeWork( int x ) {
+ public static void doSomeWork( int x, Foo f ) {
for( int i = 0; i < x; ++i ) {
- int sum = 0;
+ sese calc {
+ Foo g = new Foo( i );
+ int sum = 0;
+ for( int j = 0; j <= i; ++j ) {
+ sum = calculateStuff( sum, 1, 0 );
+ }
+ }
+ sese forceVirtualReal {
+ if( i % 3 == 0 ) {
+ sum = sum + (i % 20);
+ }
+ g.z = sum + 1000;
+ }
+ sese modobj {
+ g.z = g.z + f.z;
+ }
+ if( i % 2 == 0 ) {
+ sese change {
+ for( int k = 0; k < i*2; ++k ) {
+ sum = calculateStuff( sum, k, 1 );
+ }
+ sum = sum + 1;
+ }
- sese change {
- sum = sum + 1;
- }
-
- for( int l = 0; l < 3; ++l ) {
- sum = calculateStuff( sum, 2, 2 );
+ for( int l = 0; l < 3; ++l ) {
+ sum = calculateStuff( sum, 2, 2 );
+ }
}
-
sese prnt {
- mightPrint( x, i, sum );
+ mightPrint( x, i, sum, g );
}
}
}
public static int calculateStuff( int sum, int num, int mode ) {
- return sum + 10;
+ int answer = sum;
+ sese makePlaceholderStallAfter {
+ sum = sum + 1;
+ }
+ sum = sum + 1;
+ if( mode == 0 ) {
+ sese mode1 {
+ answer = sum + num;
+ }
+ } else if( mode == 1 ) {
+ sese mode2 {
+ answer = sum + (num/2);
+ }
+ } else {
+ sese mode3 {
+ answer = sum / num;
+ }
+ }
+ return answer;
+ }
+
+ public static void nullMethodBodyFinalNode() {
+ int y = 1;
+ sese nothing {
+ int x = 0;
+ }
+ y = x;
+ if( x > y ) {
+ return;
+ } else {
+ return;
+ }
}
- public static void mightPrint( int x, int i, int sum ) {
+ public static void mightPrint( int x, int i, int sum, Foo g ) {
if( i == x - 1 ) {
- System.out.println( "sum of integers 0-"+i+"("+x+") is "+sum );
+ System.out.println( "Results "+i+", "+x+", "+sum+", "+g.z );
}
}
}