package IR.Flat;
-import Analysis.MLP.VariableSourceToken;
-import Analysis.MLP.SESEandAgePair;
-import IR.MethodDescriptor;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.Vector;
+import java.util.Iterator;
+import java.util.Collection;
+import Analysis.OoOJava.VariableSourceToken;
+import Analysis.OoOJava.SESEandAgePair;
+import Analysis.OwnershipAnalysis.HeapRegionNode;
import IR.ClassDescriptor;
+import IR.FieldDescriptor;
+import IR.MethodDescriptor;
import IR.TypeDescriptor;
import IR.Tree.SESENode;
-import java.util.*;
public class FlatSESEEnterNode extends FlatNode {
// sequentially from 0 to 1-(total # SESE's)
private static int identifier=0;
- private int id;
- protected FlatSESEExitNode exit;
- protected SESENode treeNode;
- protected FlatSESEEnterNode parent;
+ private int id;
+ protected FlatSESEExitNode exit;
+ protected SESENode treeNode;
+
+ // a leaf tasks simply has no children, ever
+ protected static final int ISLEAF_UNINIT = 1;
+ protected static final int ISLEAF_FALSE = 2;
+ protected static final int ISLEAF_TRUE = 3;
+ protected int isLeafSESE;
+
+ // there is only one main sese that is implicit
+ // (spliced in by the compiler around whole program)
+ protected boolean isMainSESE;
+
+ // this is a useful static name for whichever task
+ // invoked the current local method context
+ protected boolean isCallerProxySESE;
+
+ // all children tasks, INCLUDING those that are reachable
+ // by calling methods
protected Set<FlatSESEEnterNode> children;
+
+ // all possible parents
+ protected Set<FlatSESEEnterNode> parents;
+
+ // sometimes it is useful to know the locally defined
+ // parent or children of an SESE for various analysis,
+ // and by local it is one SESE nested within another
+ // in a single method context
+ protected Set<FlatSESEEnterNode> localChildren;
+ protected FlatSESEEnterNode localParent;
+
+
protected Set<TempDescriptor> inVars;
protected Set<TempDescriptor> outVars;
- protected Set<SESEandAgePair> needStaticNameInCode;
+
+ protected Set<TempDescriptor> readyInVars;
+ protected Set<TempDescriptor> staticInVars;
+ protected Set<TempDescriptor> dynamicInVars;
+
+ protected Set<SESEandAgePair> staticInVarSrcs;
+
+ protected Hashtable<TempDescriptor, VariableSourceToken> staticInVar2src;
+
+ // get the oldest age of this task that other contexts
+ // have a static name for when tracking variables
+ protected Integer oldestAgeToTrack;
+
+
+ // a subset of the in-set variables that shouuld be traversed during
+ // the dynamic coarse grained conflict strategy, remember them here so
+ // buildcode can be dumb and just gen the traversals
+ protected Vector<TempDescriptor> inVarsForDynamicCoarseConflictResolution;
+
// scope info for this SESE
protected FlatMethod fmEnclosing;
protected FlatMethod fmBogus;
protected MethodDescriptor mdBogus;
+ // used during code generation to calculate an offset
+ // into the SESE-specific record, specifically to the
+ // first field in a sequence of pointers to other SESE
+ // records which is relevant to garbage collection
+ protected String firstDepRecField;
+ protected int numDepRecs;
+
public FlatSESEEnterNode( SESENode sn ) {
this.id = identifier++;
treeNode = sn;
- parent = null;
children = new HashSet<FlatSESEEnterNode>();
+ parents = new HashSet<FlatSESEEnterNode>();
+ localChildren = new HashSet<FlatSESEEnterNode>();
+ localParent = null;
inVars = new HashSet<TempDescriptor>();
outVars = new HashSet<TempDescriptor>();
- needStaticNameInCode = new HashSet<SESEandAgePair>();
+ readyInVars = new HashSet<TempDescriptor>();
+ staticInVars = new HashSet<TempDescriptor>();
+ dynamicInVars = new HashSet<TempDescriptor>();
+ staticInVarSrcs = new HashSet<SESEandAgePair>();
+ oldestAgeToTrack = new Integer( 0 );
+
+ staticInVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
+
+ inVarsForDynamicCoarseConflictResolution = new Vector<TempDescriptor>();
+
+
+ fmEnclosing = null;
+ mdEnclosing = null;
+ cdEnclosing = null;
+
+ isLeafSESE = ISLEAF_UNINIT;
+
+ isMainSESE = false;
+ isCallerProxySESE = false;
+
+ firstDepRecField = null;
+ numDepRecs = 0;
}
public void rewriteUse() {
return exit;
}
+ public void setIsMainSESE() {
+ isMainSESE = true;
+ }
+
+ public boolean getIsMainSESE() {
+ return isMainSESE;
+ }
+
+ public void setIsCallerProxySESE() {
+ isCallerProxySESE = true;
+ }
+
+ public boolean getIsCallerProxySESE() {
+ return isCallerProxySESE;
+ }
+
public int kind() {
return FKind.FlatSESEEnterNode;
}
return id;
}
- public String getPrettyIdentifier() {
- if( treeNode.getID() != null ) {
+ public String getPrettyIdentifier() {
+ if( treeNode != null && treeNode.getID() != null ) {
return treeNode.getID();
}
return ""+id;
public String toString() {
return "sese "+getPrettyIdentifier()+" enter";
}
+
+ public String toPrettyString() {
+ return "sese "+getPrettyIdentifier()+getIdentifier();
+ }
+
+
+ public void mustTrackAtLeastAge( Integer age ) {
+ if( age > oldestAgeToTrack ) {
+ oldestAgeToTrack = new Integer( age );
+ }
+ }
+
+ public Integer getOldestAgeToTrack() {
+ return oldestAgeToTrack;
+ }
+
+
+ public void addParent( FlatSESEEnterNode parent ) {
+ parents.add( parent );
+ }
- public void setParent( FlatSESEEnterNode parent ) {
- this.parent = parent;
+ public Set<FlatSESEEnterNode> getParents() {
+ return parents;
}
- public FlatSESEEnterNode getParent() {
- return parent;
+ public void setLocalParent( FlatSESEEnterNode parent ) {
+ localParent = parent;
+ }
+
+ public FlatSESEEnterNode getLocalParent() {
+ return localParent;
}
public void addChild( FlatSESEEnterNode child ) {
children.add( child );
}
+ public void addChildren( Set<FlatSESEEnterNode> batch ) {
+ children.addAll( batch );
+ }
+
public Set<FlatSESEEnterNode> getChildren() {
return children;
}
+ public void addLocalChild( FlatSESEEnterNode child ) {
+ localChildren.add( child );
+ }
+
+ public Set<FlatSESEEnterNode> getLocalChildren() {
+ return localChildren;
+ }
+
+
+
public void addInVar( TempDescriptor td ) {
- inVars.add( td );
+ if (!inVars.contains(td))
+ inVars.add( td );
}
public void addOutVar( TempDescriptor td ) {
}
public void addInVarSet( Set<TempDescriptor> s ) {
- inVars.addAll( s );
+ inVars.addAll(s);
}
public void addOutVarSet( Set<TempDescriptor> s ) {
return vecinVars.size();
}
- /*
- public String namespaceStructNameString() {
- return "struct SESE_"+getPrettyIdentifier()+"_namespace";
- }
-
- public String namespaceStructDeclarationString() {
- String s = "struct SESE_"+getPrettyIdentifier()+"_namespace {\n";
- for( int i = 0; i < numParameters(); ++i ) {
- TempDescriptor td = getParameter( i );
- TypeDescriptor type = td.getType();
- s += " "+type.toString()+" "+td+";\n";
- }
- s += "};\n";
- return s;
- }
-
- public String namespaceStructAccessString( TempDescriptor td ) {
- return "SESE_"+getPrettyIdentifier()+"_namespace."+td;
- }
- */
-
public Set<FlatNode> getNodeSet() {
HashSet<FlatNode> tovisit=new HashSet<FlatNode>();
HashSet<FlatNode> visited=new HashSet<FlatNode>();
return outVars;
}
- public void addNeededStaticName( SESEandAgePair p ) {
- needStaticNameInCode.add( p );
+ public void addStaticInVarSrc( SESEandAgePair p ) {
+ staticInVarSrcs.add( p );
+ }
+
+ public Set<SESEandAgePair> getStaticInVarSrcs() {
+ return staticInVarSrcs;
+ }
+
+ public void addReadyInVar( TempDescriptor td ) {
+ readyInVars.add( td );
+ }
+
+ public Set<TempDescriptor> getReadyInVarSet() {
+ return readyInVars;
+ }
+
+ public void addStaticInVar( TempDescriptor td ) {
+ staticInVars.add( td );
+ }
+
+ public Set<TempDescriptor> getStaticInVarSet() {
+ return staticInVars;
}
- public Set<SESEandAgePair> getNeededStaticNames() {
- return needStaticNameInCode;
+ public void putStaticInVar2src( TempDescriptor staticInVar,
+ VariableSourceToken vst ) {
+ staticInVar2src.put( staticInVar, vst );
}
+ public VariableSourceToken getStaticInVarSrc( TempDescriptor staticInVar ) {
+ return staticInVar2src.get( staticInVar );
+ }
+
+ public void addDynamicInVar( TempDescriptor td ) {
+ dynamicInVars.add( td );
+ }
+
+ public Set<TempDescriptor> getDynamicInVarSet() {
+ return dynamicInVars;
+ }
+
+
public void setfmEnclosing( FlatMethod fm ) { fmEnclosing = fm; }
public FlatMethod getfmEnclosing() { return fmEnclosing; }
public MethodDescriptor getmdBogus() { return mdBogus; }
public String getSESEmethodName() {
+ assert cdEnclosing != null;
+ assert mdBogus != null;
+
return
cdEnclosing.getSafeSymbol()+
mdBogus.getSafeSymbol()+
}
public String getSESErecordName() {
+ assert cdEnclosing != null;
+ assert mdBogus != null;
+
return
"struct "+
cdEnclosing.getSafeSymbol()+
mdBogus.getSafeMethodDescriptor()+
"_SESErec";
}
+
+ public boolean equals( Object o ) {
+ if( o == null ) {
+ return false;
+ }
+
+ if( !(o instanceof FlatSESEEnterNode) ) {
+ return false;
+ }
+
+ FlatSESEEnterNode fsen = (FlatSESEEnterNode) o;
+ return id == fsen.id;
+ }
+
+ public int hashCode() {
+ return 31*id;
+ }
+
+
+
+ public void setFirstDepRecField( String field ) {
+ firstDepRecField = field;
+ }
+
+ public String getFirstDepRecField() {
+ return firstDepRecField;
+ }
+
+ public void incNumDepRecs() {
+ ++numDepRecs;
+ }
+
+ public int getNumDepRecs() {
+ return numDepRecs;
+ }
+
+ public Vector<TempDescriptor> getInVarsForDynamicCoarseConflictResolution() {
+ return inVarsForDynamicCoarseConflictResolution;
+ }
+
+ public void addInVarForDynamicCoarseConflictResolution(TempDescriptor inVar) {
+ if (!inVarsForDynamicCoarseConflictResolution.contains(inVar))
+ inVarsForDynamicCoarseConflictResolution.add(inVar);
+ }
+
+ public void setIsLeafSESE( boolean isLeaf ) {
+ if( isLeaf ) {
+ isLeafSESE = ISLEAF_TRUE;
+ } else {
+ isLeafSESE = ISLEAF_FALSE;
+ }
+ }
+
+ public boolean getIsLeafSESE() {
+ if( isLeafSESE == ISLEAF_UNINIT ) {
+ throw new Error( "isLeafSESE uninitialized" );
+ }
+
+ return isLeafSESE == ISLEAF_TRUE;
+ }
+
}