public class BuildStateMachines {
+ // map a task or stall site (both a FlatNode) to a variable
+ // and then finally to a state machine
protected
Hashtable< FlatNode, Hashtable<TempDescriptor, StateMachineForEffects> >
fn2var2smfe;
e );
}
}
+
+
+ public void writeStateMachines() {
+
+ Iterator<FlatNode> fnItr = fn2var2smfe.keySet().iterator();
+ while( fnItr.hasNext() ) {
+ FlatNode fn = fnItr.next();
+
+ Hashtable<TempDescriptor, StateMachineForEffects>
+ var2smfe = fn2var2smfe.get( fn );
+
+ Iterator<TempDescriptor> varItr = var2smfe.keySet().iterator();
+ while( varItr.hasNext() ) {
+ TempDescriptor var = varItr.next();
+
+ StateMachineForEffects smfe = var2smfe.get( var );
+
+ smfe.writeAsDOT( "statemachine_"+fn.toString()+var.toString() );
+ }
+ }
+ }
}
op2result.put( op, out );
return out;
}
+
+
+
+ // BOO, HISS! FlatNode operand does NOT extend
+ // Canonical, so we can't cache this op by its
+ // canonical arguments--THINK ABOUT A BETTER WAY!
+ public static Taint changeWhereDefined( Taint t,
+ FlatNode pp ) {
+ assert t != null;
+ assert t.isCanonical();
+
+ // never a cached result...
+ Taint out = new Taint( t.sese,
+ t.stallSite,
+ t.var,
+ t.allocSite,
+ pp,
+ t.preds
+ );
+
+ out = (Taint) makeCanonical( out );
+ //op2result.put( op, out ); CRY CRY
+ return out;
+ }
+
+ // BOO, HISS! FlatNode operand does NOT extend
+ // Canonical, so we can't cache this op by its
+ // canonical arguments--THINK ABOUT A BETTER WAY!
+ public static TaintSet changeWhereDefined( TaintSet ts,
+ FlatNode pp ) {
+ assert ts != null;
+ assert ts.isCanonical();
+
+ // never a cached result...
+ TaintSet out = TaintSet.factory();
+ Iterator<Taint> itr = ts.iterator();
+ while( itr.hasNext() ) {
+ Taint t = itr.next();
+ out = Canonical.add( out,
+ Canonical.changeWhereDefined( t, pp )
+ );
+ }
+
+ out = (TaintSet) makeCanonical( out );
+ //op2result.put( op, out ); CRY CRY
+ return out;
+ }
+
}
analysisComplete=true;
-
double timeEndAnalysis = (double) System.nanoTime();
double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
);
}
}
+
+ if( state.RCR ) {
+ buildStateMachines.writeStateMachines();
+ }
+
} catch( IOException e ) {
throw new Error( "IO Exception while writing disjointness analysis output." );
}
-
}
if( shouldAnalysisTrack( fld.getType() ) ) {
// transfer func
- rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld );
+ rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld, fn );
}
// after transfer, use updated graph to
if( shouldAnalysisTrack( fld.getType() ) ) {
// transfer func
- strongUpdate = rg.assignTempXFieldFEqualToTempY( lhs, fld, rhs );
+ strongUpdate = rg.assignTempXFieldFEqualToTempY( lhs, fld, rhs, fn );
}
// use transformed graph to do effects analysis
if( shouldAnalysisTrack( lhs.getType() ) ) {
// transfer func
- rg.assignTempXEqualToTempYFieldF( lhs, rhs, fdElement );
+ rg.assignTempXEqualToTempYFieldF( lhs, rhs, fdElement, fn );
}
// use transformed graph to do effects analysis
// transfer func, BUT
// skip this node if it cannot create new reachability paths
if( !arrayReferencees.doesNotCreateNewReaching( fsen ) ) {
- rg.assignTempXFieldFEqualToTempY( lhs, fdElement, rhs );
+ rg.assignTempXFieldFEqualToTempY( lhs, fdElement, rhs, fn );
}
}
public void assignTempXEqualToTempYFieldF( TempDescriptor x,
TempDescriptor y,
- FieldDescriptor f ) {
+ FieldDescriptor f,
+ FlatNode currentProgramPoint
+ ) {
+
VariableNode lnX = getVariableNodeFromTemp( x );
VariableNode lnY = getVariableNodeFromTemp( y );
mostSpecificType( edgeHrn.getType(),
hrnHrn.getType()
);
+
+ TaintSet taints = Canonical.unionORpreds( edgeHrn.getTaints(),
+ edgeY.getTaints()
+ );
+ if( state.RCR ) {
+ // the DFJ way to generate taints changes for field statements
+ taints = Canonical.changeWhereDefined( taints,
+ currentProgramPoint );
+ }
RefEdge edgeNew = new RefEdge( lnX,
hrnHrn,
null,
Canonical.intersection( betaY, betaHrn ),
predsTrue,
- Canonical.unionORpreds(edgeHrn.getTaints(),edgeY.getTaints())
+ taints
);
addEdgeOrMergeWithExisting( edgeNew );
// return whether a strong update was actually effected
public boolean assignTempXFieldFEqualToTempY( TempDescriptor x,
FieldDescriptor f,
- TempDescriptor y ) {
+ TempDescriptor y,
+ FlatNode currentProgramPoint
+ ) {
VariableNode lnX = getVariableNodeFromTemp( x );
VariableNode lnY = getVariableNodeFromTemp( y );
hrnY.getType()
);
+ TaintSet taints = edgeY.getTaints();
+
+ if( state.RCR ) {
+ // the DFJ way to generate taints changes for field statements
+ taints = Canonical.changeWhereDefined( taints,
+ currentProgramPoint );
+ }
+
RefEdge edgeNew =
new RefEdge( hrnX,
hrnY,
predsTrue
),
predsTrue,
- edgeY.getTaints()
+ taints
);
addEdgeOrMergeWithExisting( edgeNew );
Set<SMFEState> states = e2states.get( effect );
if( states == null ) {
states = new HashSet<SMFEState>();
+ e2states.put( effect, states );
}
states.add( stateTo );
}
public void addEffect( FlatNode fnState,
Effect e ) {
- assert fn2state.containsKey( fnState );
SMFEState state = getState( fnState );
state.addEffect( e );
}
SMFEState state = fn2state.get( fn );
if( state == null ) {
state = new SMFEState( fn );
+ fn2state.put( fn, state );
}
return state;
}
- public void writeAsDOT() {
- String graphName = initialState.getID().toString();
+ public void writeAsDOT( String graphName ) {
+ //String graphName = initialState.getID().toString();
graphName = graphName.replaceAll( "[\\W]", "" );
try {
t.f = a;
}
- genreach p1;
-
rblock T {
Foo x = a.f;
Foo y = x.f;
y.z = 1;
+
+ genreach pT;
}
rblock S {
w = w.f;
}
w.z = 5;
+
+ genreach pS;
}
int total = 0;