// remember all the FlatNode/TempDescriptor pairs that have a state machines
// for easy retrieval of all machines
- protected Set<Pair> allMachineNamePairs;
+ protected Set<Pair<FlatNode, TempDescriptor>> allMachineNamePairs;
public BuildStateMachines() {
fn2var2smfe = new
Hashtable< FlatNode, Hashtable<TempDescriptor, StateMachineForEffects> >();
- allMachineNamePairs = new HashSet<Pair>();
+ allMachineNamePairs = new HashSet<Pair<FlatNode, TempDescriptor>>();
}
+ public StateMachineForEffects getStateMachine(Pair<FlatNode, TempDescriptor> fnpair) {
+ return getStateMachine(fnpair.getFirst(), fnpair.getSecond());
+ }
public StateMachineForEffects getStateMachine( FlatNode fn,
TempDescriptor var ) {
smfe = new StateMachineForEffects( fn );
var2smfe.put( var, smfe );
- allMachineNamePairs.add( new Pair( fn, var ) );
+ allMachineNamePairs.add( new Pair<FlatNode, TempDescriptor>( fn, var ) );
}
return smfe;
}
- public Set<Pair> getAllMachineNames() {
+ public Set<Pair<FlatNode, TempDescriptor>> getAllMachineNames() {
return allMachineNamePairs;
}
}
}
}
-
-
//TODO JIM! Give me the REAALL number here.
public int getTotalNumOfWeakGroups() {
// TODO Auto-generated method stub
// operation type
public static final int read = 1;
public static final int write = 2;
- public static final int strongupdate = 3;
+ public static final int strongupdate = 4;
// identify an allocation site of affected object
protected Alloc affectedAllocSite;
this.field = field;
}
+ public static boolean isWrite(int effect) {
+ return (effect & Effect.write)==Effect.write;
+ }
+
public Alloc getAffectedAllocSite() {
return affectedAllocSite;
}
e2states.put( effect, states );
}
states.add( stateTo );
-
- ++stateTo.refCount;
+ stateTo.refCount++;
}
return effects;
}
+ public void addConflict(Effect e) {
+ conflicts.add(e);
+ }
+
public Set<Effect> getConflicts() {
- //TODO JIM! Fix this when have a chance!
- conflicts.addAll(effects);
- return this.conflicts;
+ return conflicts;
}
public Set<Effect> getTransistionEffects() {
return statesOut;
}
+ // some subset of the above effects may transition to
+ // other states
+ public Set<SMFEState> transitionsTo() {
+ Set<SMFEState> statesOut = new HashSet<SMFEState>();
+ for(Map.Entry<Effect, Set<SMFEState>> entry:e2states.entrySet()) {
+ statesOut.addAll(entry.getValue());
+ }
+ return statesOut;
+ }
+
public int getRefCount() {
return refCount;
}
import IR.*;
import IR.Flat.*;
+import Util.Pair;
//////////////////////////////////////////////
//
public class StateMachineForEffects {
public final static FlatNode startNode=new FlatNop();
+ protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> effectsMap;
// states in the machine are uniquely identified
// by a flat node (program point)
protected Hashtable<FlatNode, Integer> fn2weaklyConnectedGroupID;
protected SMFEState initialState;
-
+ protected FlatNode fn;
public StateMachineForEffects( FlatNode fnInitial ) {
fn2state = new Hashtable<FlatNode, SMFEState>();
-
+ effectsMap = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
initialState = getState( fnInitial );
+ this.fn=fnInitial;
+ }
+
+ public Set<SMFEState> getStates() {
+ HashSet<SMFEState> set=new HashSet<SMFEState>();
+ set.addAll(fn2state.values());
+ return set;
+ }
+
+ public FlatNode getStallorSESE() {
+ return fn;
+ }
+
+ public int getEffects(Alloc affectedNode, FieldDescriptor fd) {
+ return effectsMap.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
}
public void addEffect( FlatNode fnState,
Effect e ) {
-
if (fnState==null)
fnState=startNode;
SMFEState state = getState( fnState );
state.addEffect( e );
+ Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
+ int type=e.getType();
+ if (!effectsMap.containsKey(p))
+ effectsMap.put(p, new Integer(type));
+ else
+ effectsMap.put(p, new Integer(type|effectsMap.get(p).intValue()));
}
public void addTransition( FlatNode fnFrom,
return 0;
}
-
public void writeAsDOT( String graphName ) {
//String graphName = initialState.getID().toString();
graphName = graphName.replaceAll( "[\\W]", "" );
protected Hashtable<String, ConflictNode> id2cn;
protected Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>> sese2te;
- protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> seseEffects;
- protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> stallEffects;
protected DisjointAnalysis da;
protected FlatMethod fmEnclosing;
this.state=state;
id2cn = new Hashtable<String, ConflictNode>();
sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
- seseEffects = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
- stallEffects = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
- }
-
- public int getStallEffects(Alloc affectedNode, FieldDescriptor fd) {
- return stallEffects.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
- }
-
- public int getSESEEffects(Alloc affectedNode, FieldDescriptor fd) {
- return seseEffects.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
}
public void setDisJointAnalysis(DisjointAnalysis da) {
node.addEffect(as, e);
node.addTaint(t);
id2cn.put(id, node);
-
- Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
- int type=e.getType();
- if (!stallEffects.containsKey(p))
- stallEffects.put(p, new Integer(type));
- else
- stallEffects.put(p, new Integer(type|stallEffects.get(p).intValue()));
}
public void addLiveInNodeEffect(Taint t, Effect e) {
id2cn.put(id, node);
- Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
- int type=e.getType();
- if (!seseEffects.containsKey(p))
- seseEffects.put(p, new Integer(type));
- else
- seseEffects.put(p, new Integer(type|seseEffects.get(p).intValue()));
}
public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
import IR.*;
import IR.Flat.*;
-
public class OoOJavaAnalysis {
// data from the compiler
// effects between heap roots, so it is smart to compute all of
// this together
public void pruneMachinesAndFindWeaklyConnectedExaminers() {
-
- /*
- // TODO, calcualte the set of taints that lead to conflicts (for which
- // traversers must be built...)
-
- EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis();
-
- // visit every conflict graph once, so iterate through the
- // the non-leaf tasks to find them all
- Set<FlatSESEEnterNode> allSESEs = rblockRel.getAllSESEs();
- for( Iterator allItr = allSESEs.iterator(); allItr.hasNext(); ) {
-
- FlatSESEEnterNode parent = (FlatSESEEnterNode) allItr.next();
- if( parent.getIsLeafSESE() ) {
- continue;
- }
-
- ConflictGraph conflictGraph = sese2conflictGraph.get( parent );
- assert conflictGraph != null;
-
- // from the conflict graph we want to extract all conflicting effects
- // and use them to identify (1) weakly connected heap examiners and
- // (2) states/examiner nodes with a conflicting effect that will later
- // support the examiner pruning process
- Hashtable<Taint, Set<Effect>> conflicts = conflictGraph.getConflictEffectSet( fsen ) );
-
- }
- */
+ ProcessStateMachines psm=new ProcessStateMachines(buildStateMachines, rblockRel);
+ psm.doProcess();
}
// node it will be in this set
protected Hashtable< FlatNode, Set<FlatSESEEnterNode> > fn2currentSESEs;
- // if you want to know which rblocks might be executing a given flat
- // node it will be in this set
+ // if you want to know which rblocks might be TRANSITIVELY executing
+ // a given flat node it will be in this set
protected Hashtable< FlatNode, Set<FlatSESEEnterNode> > fn2allSESEs;
// if you want to know the method-local, inner-most nested task that