--- /dev/null
+package Analysis.Disjoint;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+
+import IR.FieldDescriptor;
+import IR.MethodDescriptor;
+import IR.TypeDescriptor;
+import IR.Flat.FlatCall;
+import IR.Flat.FlatSetElementNode;
+import IR.Flat.TempDescriptor;
+
+/////////////////////////////////////////////
+//
+// Effects analysis computes read/write/strong
+// update and other sorts of effects for the
+// scope of a method or rblock. The effects
+// are associated with the heap roots through
+// which a reference to the effect target was
+// obtained.
+//
+// The effects analysis piggy-backs
+// on the disjoint reachability analysis,
+// if requested, to support OoOJava and
+// potentially other analysis clients.
+//
+/////////////////////////////////////////////
+
+public class EffectsAnalysis {
+
+ //private Hashtable<MethodContext, MethodEffects> mapMethodContextToMethodEffects;
+ // boolean methodeffects = false;
+
+ public EffectsAnalysis( boolean methodeffects ) {
+ //this.methodeffects = methodeffects;
+ //mapMethodContextToMethodEffects = new Hashtable<MethodContext, MethodEffects>();
+ }
+
+ /*
+ public MethodEffects getMethodEffectsByMethodContext(MethodContext mc){
+ return mapMethodContextToMethodEffects.get(mc);
+ }
+
+ public void createNewMapping(MethodContext mcNew) {
+ if(!methodeffects) return;
+ if (!mapMethodContextToMethodEffects.containsKey(mcNew)) {
+ MethodEffects meNew = new MethodEffects();
+ mapMethodContextToMethodEffects.put(mcNew, meNew);
+ }
+ }
+ */
+
+ /*
+ public void analyzeFlatCall(OwnershipGraph calleeOG,
+ MethodContext calleeMC, MethodContext callerMC, FlatCall fc) {
+ if(!methodeffects) return;
+ MethodEffects me = mapMethodContextToMethodEffects.get(callerMC);
+ MethodEffects meFlatCall = mapMethodContextToMethodEffects
+ .get(calleeMC);
+ me.analyzeFlatCall(calleeOG, fc, callerMC, meFlatCall);
+ mapMethodContextToMethodEffects.put(callerMC, me);
+ }
+ */
+
+ /*
+ public void analyzeFlatFieldNode(MethodContext mc, OwnershipGraph og,
+ TempDescriptor srcDesc, FieldDescriptor fieldDesc) {
+ if(!methodeffects) return;
+ MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+ me.analyzeFlatFieldNode(og, srcDesc, fieldDesc);
+ mapMethodContextToMethodEffects.put(mc, me);
+ }
+
+ public void analyzeFlatSetFieldNode(MethodContext mc, OwnershipGraph og,
+ TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+ if(!methodeffects) return;
+ MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+ me.analyzeFlatSetFieldNode(og, dstDesc, fieldDesc);
+ mapMethodContextToMethodEffects.put(mc, me);
+ }
+
+ public void analyzeFlatSetElementNode(MethodContext mc, OwnershipGraph og,
+ TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+ if(!methodeffects) return;
+ MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+ me.analyzeFlatSetElementNode(og, dstDesc, fieldDesc);
+ mapMethodContextToMethodEffects.put(mc, me);
+ }
+
+ public void analyzeFlatElementNode(MethodContext mc, OwnershipGraph og,
+ TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+ if(!methodeffects) return;
+ MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+ me.analyzeFlatElementNode(og, dstDesc, fieldDesc);
+ mapMethodContextToMethodEffects.put(mc, me);
+ }
+
+
+ public void writeMethodEffectsResult() throws IOException {
+
+ try {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(
+ "MethodEffects_report.txt"));
+
+ Set<MethodContext> mcSet = mapMethodContextToMethodEffects.keySet();
+ Iterator<MethodContext> mcIter = mcSet.iterator();
+ while (mcIter.hasNext()) {
+ MethodContext mc = mcIter.next();
+ MethodDescriptor md = (MethodDescriptor) mc.getDescriptor();
+
+ int startIdx = 0;
+ if (!md.isStatic()) {
+ startIdx = 1;
+ }
+
+ MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+ EffectsSet effectsSet = me.getEffects();
+
+ bw.write("Method " + mc + " :\n");
+ for (int i = startIdx; i < md.numParameters() + startIdx; i++) {
+
+ String paramName = md.getParamName(i - startIdx);
+
+ Set<EffectsKey> effectSet = effectsSet.getReadingSet(i);
+ String keyStr = "{";
+ if (effectSet != null) {
+ Iterator<EffectsKey> effectIter = effectSet.iterator();
+ while (effectIter.hasNext()) {
+ EffectsKey key = effectIter.next();
+ keyStr += " " + key;
+ }
+ }
+ keyStr += " }";
+ bw.write(" Paramter " + paramName + " ReadingSet="
+ + keyStr + "\n");
+
+ effectSet = effectsSet.getWritingSet(new Integer(i));
+ keyStr = "{";
+ if (effectSet != null) {
+ Iterator<EffectsKey> effectIter = effectSet.iterator();
+ while (effectIter.hasNext()) {
+ EffectsKey key = effectIter.next();
+ keyStr += " " + key;
+ }
+ }
+
+ keyStr += " }";
+ bw.write(" Paramter " + paramName + " WritingngSet="
+ + keyStr + "\n");
+
+ }
+ bw.write("\n");
+
+ }
+
+ bw.close();
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+
+ }
+ */
+}
ExistPredSet preds =
ExistPredSet.factory( pred );
- Taint paramTaint =
- Taint.factory( index, paramCallee.toString() );
+ //Taint paramTaint =
+ // Taint.factory( 0, null, null, );
TaintSet paramTaints =
- TaintSet.factory( paramTaint );
+ //TaintSet.factory( paramTaint );
+ TaintSet.factory();
RefEdge reCallee =
new RefEdge( vnCallee,
--- /dev/null
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+///////////////////////////////////////////
+// IMPORTANT
+// This class is an immutable Canonical, so
+//
+// 0) construct them with a factory pattern
+// to ensure only canonical versions escape
+//
+// 1) any operation that modifies a Canonical
+// is a static method in the Canonical class
+//
+// 2) operations that just read this object
+// should be defined here
+//
+// 3) every Canonical subclass hashCode should
+// throw an error if the hash ever changes
+//
+///////////////////////////////////////////
+
+// a taint is applied to a reference edge, and
+// is used to associate an effect with a heap root
+
+public class Taint extends Canonical {
+
+ // taints can either be associated with
+ // parameters or seses (rblocks),
+ // only one set of identifying objects
+ // will be non-null
+
+ // identify a parameter index
+ protected Integer paramIndex;
+
+ // identify an sese (rblock) + inset var
+ protected FlatSESEEnterNode sese;
+ protected TempDescriptor insetVar;
+
+ // either type of taint also includes
+ // an allocation site
+ protected AllocSite allocSite;
+
+
+ public static Taint factory( Integer pi,
+ FlatSESEEnterNode s,
+ TempDescriptor iv,
+ AllocSite as ) {
+ Taint out = new Taint( pi, s, iv, as );
+ out = (Taint) Canonical.makeCanonical( out );
+ return out;
+ }
+
+ protected Taint( Integer pi,
+ FlatSESEEnterNode s,
+ TempDescriptor iv,
+ AllocSite as ) {
+ assert
+ (pi != null && s == null && iv == null) ||
+ (pi == null && s != null && iv != null);
+
+ assert as != null;
+
+ paramIndex = pi;
+ sese = s;
+ insetVar = iv;
+ allocSite = as;
+ }
+
+ public Integer getParamIndex() {
+ return paramIndex;
+ }
+
+ public FlatSESEEnterNode getSESE() {
+ return sese;
+ }
+
+ public TempDescriptor getInSetVar() {
+ return insetVar;
+ }
+
+ public AllocSite getAllocSite() {
+ return allocSite;
+ }
+
+
+ public boolean equalsSpecific( Object o ) {
+ if( o == null ) {
+ return false;
+ }
+
+ if( !(o instanceof Taint) ) {
+ return false;
+ }
+
+ Taint t = (Taint) o;
+
+ boolean piMatches = true;
+ if( paramIndex == null ) {
+ piMatches = t.paramIndex == null;
+ } else {
+ piMatches = paramIndex.equals( t.paramIndex );
+ }
+
+ boolean sMatches = true;
+ if( sese == null ) {
+ sMatches = t.sese == null;
+ } else {
+ sMatches = sese.equals( t.sese );
+ }
+
+ boolean ivMatches = true;
+ if( insetVar == null ) {
+ ivMatches = t.insetVar == null;
+ } else {
+ ivMatches = insetVar.equals( t.insetVar );
+ }
+
+ return allocSite.equals( t.allocSite ) &&
+ piMatches && sMatches && ivMatches;
+ }
+
+ public int hashCodeSpecific() {
+ int hash = allocSite.hashCode();
+
+ if( paramIndex != null ) {
+ hash = hash ^ paramIndex.hashCode();
+ }
+
+ if( sese != null ) {
+ hash = hash ^ sese.hashCode();
+ }
+
+ if( insetVar != null ) {
+ hash = hash ^ insetVar.hashCode();
+ }
+
+ return hash;
+ }
+
+ public String toString() {
+ return "";
+ }
+}
--- /dev/null
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+///////////////////////////////////////////
+// IMPORTANT
+// This class is an immutable Canonical, so
+//
+// 0) construct them with a factory pattern
+// to ensure only canonical versions escape
+//
+// 1) any operation that modifies a Canonical
+// is a static method in the Canonical class
+//
+// 2) operations that just read this object
+// should be defined here
+//
+// 3) every Canonical subclass hashCode should
+// throw an error if the hash ever changes
+//
+///////////////////////////////////////////
+
+// a taint set is simply the union of possible
+// taints for an abstract reference edge--in a
+// concrete heap each reference would have
+// exactly one taint
+
+public class TaintSet extends Canonical {
+
+ protected HashSet<Taint> taints;
+
+ public static TaintSet factory() {
+ TaintSet out = new TaintSet();
+ out = (TaintSet) Canonical.makeCanonical( out );
+ return out;
+ }
+
+ public static TaintSet factory( Taint t ) {
+ assert t != null;
+ assert t.isCanonical();
+ TaintSet out = new TaintSet();
+ out.taints.add( t );
+ out = (TaintSet) Canonical.makeCanonical( out );
+ return out;
+ }
+
+ protected TaintSet() {
+ taints = new HashSet<Taint>();
+ }
+
+ public Iterator iterator() {
+ return taints.iterator();
+ }
+
+ public boolean isEmpty() {
+ return taints.isEmpty();
+ }
+
+ public boolean containsTaint( Taint t ) {
+ assert t != null;
+ return taints.contains( t );
+ }
+
+ public boolean equalsSpecific( Object o ) {
+ if( o == null ) {
+ return false;
+ }
+
+ if( !(o instanceof TaintSet) ) {
+ return false;
+ }
+
+ TaintSet ts = (TaintSet) o;
+ return taints.equals( ts.taints );
+ }
+
+ public int hashCodeSpecific() {
+ return taints.hashCode();
+ }
+
+ public String toString() {
+ return taints.toString();
+ }
+}
--- /dev/null
+package Analysis.OoOJava;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.Map.Entry;
+import Analysis.Liveness;
+import Analysis.ArrayReferencees;
+import Analysis.CallGraph.CallGraph;
+import IR.Descriptor;
+import IR.FieldDescriptor;
+import IR.MethodDescriptor;
+import IR.Operation;
+import IR.State;
+import IR.TypeDescriptor;
+import IR.TypeUtil;
+import IR.Flat.FKind;
+import IR.Flat.FlatCall;
+import IR.Flat.FlatCondBranch;
+import IR.Flat.FlatEdge;
+import IR.Flat.FlatElementNode;
+import IR.Flat.FlatFieldNode;
+import IR.Flat.FlatMethod;
+import IR.Flat.FlatNew;
+import IR.Flat.FlatNode;
+import IR.Flat.FlatOpNode;
+import IR.Flat.FlatReturnNode;
+import IR.Flat.FlatSESEEnterNode;
+import IR.Flat.FlatSESEExitNode;
+import IR.Flat.FlatSetElementNode;
+import IR.Flat.FlatSetFieldNode;
+import IR.Flat.FlatWriteDynamicVarNode;
+import IR.Flat.TempDescriptor;
+
+
+public class OoOJavaAnalysis {
+
+ // data from the compiler
+ private State state;
+ private TypeUtil typeUtil;
+ private CallGraph callGraph;
+
+
+
+ public OoOJavaAnalysis( State state,
+ TypeUtil tu,
+ CallGraph callGraph,
+ Liveness liveness,
+ ArrayReferencees arrayReferencees
+ ) {
+ }
+}
public boolean DISJOINTDEBUGSCHEDULING=false;
+ public boolean OOOJAVA=false;
+
public boolean OPTIONAL=false;
public boolean ARRAYPAD=false;
import Analysis.Prefetch.PrefetchAnalysis;
import Analysis.FlatIRGraph.FlatIRGraph;
import Analysis.OwnershipAnalysis.OwnershipAnalysis;
-//import Analysis.Disjoint.DisjointAnalysis;
import Analysis.MLP.MLPAnalysis;
+import Analysis.Disjoint.DisjointAnalysis;
+import Analysis.OoOJava.OoOJavaAnalysis;
import Analysis.Loops.*;
import Analysis.Liveness;
import Analysis.ArrayReferencees;
} else if (option.equals("-methodeffects")) {
state.METHODEFFECTS=true;
+
+ } else if (option.equals("-ooojava")) {
+ state.OOOJAVA = true;
+ state.DISJOINT = true;
+
}else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
oa);
}
- /* if (state.DISJOINT) {
+ if (state.DISJOINT && !state.OOOJAVA) {
CallGraph cg = new CallGraph(state);
Liveness l = new Liveness();
ArrayReferencees ar = new ArrayReferencees(state);
- DisjointAnalysis oa = new DisjointAnalysis(state, tu, cg, l, ar);
- }*/
+ DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar);
+ }
+
+ if (state.OOOJAVA) {
+ CallGraph cg = new CallGraph(state);
+ Liveness l = new Liveness();
+ ArrayReferencees ar = new ArrayReferencees(state);
+ OoOJavaAnalysis oa = new OoOJavaAnalysis(state, tu, cg, l, ar);
+ }
+
if (state.TAGSTATE) {
CallGraph callgraph=new CallGraph(state);
Analysis/MLP/SVKey.class \
Analysis/MLP/VarSrcTokTable.class \
Analysis/MLP/CodePlan.class \
+Analysis/OoOJava/OoOJavaAnalysis.class \
Util/GraphNode.class Util/Namer.class Util/Relation.class \
Util/UtilAlgorithms.class \
Interface/HTTPHeader.class Interface/HTTPResponse.class \