protected Vector<Integer> ithOldest;
protected Integer summary;
protected FlatNew flatNew;
+ protected boolean forceAnalyze;
public static final int AGE_notInThisSite = 100;
public static final int AGE_in_I = 101;
public static final int SHADOWAGE_summary = -103;
- public AllocationSite(int allocationDepth, FlatNew flatNew) {
+ public AllocationSite(int allocationDepth, FlatNew flatNew, boolean forceAnalyze) {
assert allocationDepth >= 1;
this.allocationDepth = allocationDepth;
this.flatNew = flatNew;
+ this.forceAnalyze = forceAnalyze;
ithOldest = new Vector<Integer>(allocationDepth);
id = generateUniqueAllocationSiteID();
}
+ public boolean doForceAnalyze() {
+ return forceAnalyze;
+ }
+
+
public int getAllocationDepth() {
return allocationDepth;
}
mapMethodContextToNumUpdates = new Hashtable<MethodContext, Integer>();
}
- // initialize methods to visit as the set of all tasks in the
- // program and then any method that could be called starting
- // from those tasks
- Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();
- while( taskItr.hasNext() ) {
- Descriptor d = (Descriptor) taskItr.next();
- scheduleAllCallees(d);
+
+ if( state.TASK ) {
+ // initialize methods to visit as the set of all tasks in the
+ // program and then any method that could be called starting
+ // from those tasks
+ Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();
+ while( taskItr.hasNext() ) {
+ Descriptor d = (Descriptor) taskItr.next();
+ scheduleAllCallees(d);
+ }
+
+ } else {
+ // we are not in task mode, just normal Java, so start with
+ // the main method
+
+ // get all classes, get all methods, look for static main, then stop?
+
+ // YOU CAN DEFINE MORE THAN ONE MAIN!!!!
+
+ Iterator classItr = state.getClassSymbolTable().getDescriptorsIterator();
+ while( classItr.hasNext() ) {
+ ClassDescriptor cd = (ClassDescriptor) classItr.next();
+
+ Iterator methItr = cd.getMethods();
+ while( methItr.hasNext() ) {
+ Descriptor d = (Descriptor) methItr.next();
+ scheduleAllCallees(d);
+ }
+ }
+
}
+
// before beginning analysis, initialize every scheduled method
// with an ownership graph that has populated parameter index tables
// by analyzing the first node which is always a FlatMethod node
private AllocationSite getAllocationSiteFromFlatNewPRIVATE(FlatNew fn) {
if( !mapFlatNewToAllocationSite.containsKey(fn) ) {
- AllocationSite as = new AllocationSite(allocationDepth, fn);
+ AllocationSite as = new AllocationSite(allocationDepth, fn, fn.isDisjoint());
// the newest nodes are single objects
for( int i = 0; i < allocationDepth; ++i ) {
}
if( alpha == null ) {
- if( isFlagged || isParameter ) {
+ if( isFlagged || isParameter || allocSite.doForceAnalyze() ) {
alpha = new ReachabilitySet(
new TokenTuple(id,
!isSingleObject,
private NodePair flattenCreateObjectNode(CreateObjectNode con,TempDescriptor out_temp) {
TypeDescriptor td=con.getType();
if (!td.isArray()) {
- FlatNew fn=new FlatNew(td, out_temp, con.isGlobal());
+ FlatNew fn=new FlatNew(td, out_temp, con.isGlobal(), con.isDisjoint());
TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
FlatNode last=fn;
// Build arguments
out_temp :
TempDescriptor.tempFactory("arg",en.getType());
}
- FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal());
+ FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal(), con.isDisjoint());
last.addNext(fn);
if (temps.length>1) {
NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
TypeDescriptor type;
TempDescriptor size;
boolean isglobal;
+ boolean isdisjoint;
public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal) {
this.type=type;
this.dst=dst;
this.size=null;
this.isglobal=isglobal;
+ this.isdisjoint=false;
+ }
+
+ public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal, boolean isdisjoint) {
+ this.type=type;
+ this.dst=dst;
+ this.size=null;
+ this.isglobal=isglobal;
+ this.isdisjoint=isdisjoint;
}
public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
this.dst=dst;
this.size=size;
this.isglobal=isglobal;
+ this.isdisjoint=false;
+ }
+
+ public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal, boolean isdisjoint) {
+ this.type=type;
+ this.dst=dst;
+ this.size=size;
+ this.isglobal=isglobal;
+ this.isdisjoint=isdisjoint;
}
public boolean isGlobal() {
return isglobal;
}
+ public boolean isDisjoint() {
+ return isdisjoint;
+ }
+
public String toString() {
String str = "FlatNew_"+dst.toString()+"= NEW "+type.toString();
if (size!=null)
TypeDescriptor td=parseTypeDescriptor(pn);
Vector args=parseArgumentList(pn);
boolean isglobal=pn.getChild("global")!=null;
- CreateObjectNode con=new CreateObjectNode(td, isglobal);
+ boolean isdisjoint=pn.getChild("disjoint")!=null;
+ CreateObjectNode con=new CreateObjectNode(td, isglobal, isdisjoint);
for(int i=0; i<args.size(); i++) {
con.addArgument((ExpressionNode)args.get(i));
}
} else if (isNode(pn,"createarray")) {
//System.out.println(pn.PPrint(3,true));
boolean isglobal=pn.getChild("global")!=null;
+ boolean isdisjoint=pn.getChild("disjoint")!=null;
TypeDescriptor td=parseTypeDescriptor(pn);
Vector args=parseDimExprs(pn);
int num=0;
num=((Integer)pn.getChild("dims_opt").getLiteral()).intValue();
for(int i=0; i<(args.size()+num); i++)
td=td.makeArray(state);
- CreateObjectNode con=new CreateObjectNode(td, isglobal);
+ CreateObjectNode con=new CreateObjectNode(td, isglobal, isdisjoint);
for(int i=0; i<args.size(); i++) {
con.addArgument((ExpressionNode)args.get(i));
}
MethodDescriptor md;
FlagEffects fe;
boolean isglobal;
+ boolean isdisjoint;
- public CreateObjectNode(TypeDescriptor type, boolean isglobal) {
+ public CreateObjectNode(TypeDescriptor type, boolean isglobal, boolean isdisjoint) {
td=type;
argumentlist=new Vector();
this.isglobal=isglobal;
+ this.isdisjoint=isdisjoint;
}
public boolean isGlobal() {
return isglobal;
}
+ public boolean isDisjoint() {
+ return isdisjoint;
+ }
+
public void addFlagEffects(FlagEffects fe) {
this.fe=fe;
}
key_table.put("global", new Integer(Sym.GLOBAL));
//Keywords for hacking prefetch calls in java
key_table.put("getoffset", new Integer(Sym.GETOFFSET));
+ //Keywords for disjointness in Java
+ key_table.put("disjoint", new Integer(Sym.DISJOINT));
//Keywords for coarse-grain parallelization
key_table.put("sese", new Integer(Sym.SESE));
}
static final String[] keywords = new String[] {
"abstract", "assert", "atomic", "boolean", "break", "byte", "case", "catch", "char",
- "class", "const", "continue", "default", "do", "double", "else", "enum",
+ "class", "const", "continue",
+ "default", "disjoint", "do", "double",
+ "else", "enum",
"extends", "external", "final", "finally",
"flag", //keyword for failure aware computation
"float", "for","getoffset", "global", "goto", "if",
non terminal ParseNode atomic_statement;
non terminal ParseNode getoffset_expression;
+//disjointness for Java
+terminal DISJOINT;
+
//coarse-grain parallelization
terminal SESE;
non terminal ParseNode sese_statement;
pn.addChild("global");
RESULT=pn;
:}
+ // Objects we want to track in disjointness analysis
+ | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
+ ParseNode pn=new ParseNode("createobject");
+ pn.addChild(type);
+ pn.addChild(args);
+ pn.addChild(feo);
+ pn.addChild("disjoint");
+ pn.addChild(id);
+ RESULT=pn;
+ :}
| NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
ParseNode pn=new ParseNode("createobject");
pn.addChild(type);
pn.addChild("global");
RESULT=pn;
:}
+ | DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
+ ParseNode pn=new ParseNode("createarray");
+ pn.addChild(type);
+ pn.addChild(dimexpr);
+ pn.addChild("dims_opt").setLiteral(dims);
+ pn.addChild("disjoint");
+ pn.addChild(id);
+ RESULT=pn;
+ :}
| GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
ParseNode pn=new ParseNode("createarray");
pn.addChild(type);
pn.addChild("dims_opt").setLiteral(dims);
pn.addChild("global");
RESULT=pn;
- :}
+ :}
+ | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
+ ParseNode pn=new ParseNode("createarray");
+ pn.addChild(type);
+ pn.addChild(dimexpr);
+ pn.addChild("dims_opt").setLiteral(dims);
+ pn.addChild("disjoint");
+ pn.addChild(id);
+ RESULT=pn;
+ :}
;
//array_creation_init ::=
// NEW primitive_type dims array_initializer
SOURCE_FILES=$(PROGRAM).java
BUILDSCRIPT=~/research/Robust/src/buildscript
-BSFLAGS= -recover -ownership -ownallocdepth 1 -ownaliasfile aliases.txt -ownwritedots final -enable-assertions -flatirtasks
+BSFLAGS= -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirtasks #-recover -ownaliasfile aliases.txt
all: $(PROGRAM).bin
+public class Test {
-
-task Startup( StartupObject s{ initialstate } ) {
-
- int a = 0;
-
- sese {
- int x = 3;
- }
-
- a = x;
-
-
- sese {
- int y = 4;
- y+=4;
-
+ public static void main( String args[] ) {
+
+ /*
+ int a = 0;
+
sese {
- int z = x + y;
- z+=6;
- Integer n=new Integer(23);
+ int x = 3;
}
- }
+
+ a = x;
+
+
+ sese {
+ int y = 4;
+ y+=4;
+
+ sese {
+ int z = x + y;
+ z+=6;
+ Integer n=new Integer(23);
+ }
+ }
+
+ x = y + z;
+ */
- x = y + z;
+ Integer r = disjoint t1 new Integer(23);
+ int[] s = disjoint t2 new int[10];
- taskexit( s{ !initialstate } );
+ Integer[] t = disjoint t3 new Integer[10];
+ }
}