From: jjenista Date: Thu, 17 Jun 2010 21:15:23 +0000 (+0000) Subject: get partially set up new version of disjoint analysis with OoOJava analysis checked... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=08c38efb7c75d8153e9de4cef6207cd7d403adb7;p=IRC.git get partially set up new version of disjoint analysis with OoOJava analysis checked in to properly fix compiler and get yong hun in on the workspace --- diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java new file mode 100644 index 00000000..eaef2a76 --- /dev/null +++ b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java @@ -0,0 +1,167 @@ +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 mapMethodContextToMethodEffects; + // boolean methodeffects = false; + + public EffectsAnalysis( boolean methodeffects ) { + //this.methodeffects = methodeffects; + //mapMethodContextToMethodEffects = new Hashtable(); + } + + /* + 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 mcSet = mapMethodContextToMethodEffects.keySet(); + Iterator 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 effectSet = effectsSet.getReadingSet(i); + String keyStr = "{"; + if (effectSet != null) { + Iterator 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 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); + } + + } + */ +} diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index f8c62b2b..46afd6f4 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -1652,11 +1652,12 @@ public class ReachGraph { 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, diff --git a/Robust/src/Analysis/Disjoint/Taint.java b/Robust/src/Analysis/Disjoint/Taint.java new file mode 100644 index 00000000..067c9e1e --- /dev/null +++ b/Robust/src/Analysis/Disjoint/Taint.java @@ -0,0 +1,147 @@ +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 ""; + } +} diff --git a/Robust/src/Analysis/Disjoint/TaintSet.java b/Robust/src/Analysis/Disjoint/TaintSet.java new file mode 100644 index 00000000..1b7b4be2 --- /dev/null +++ b/Robust/src/Analysis/Disjoint/TaintSet.java @@ -0,0 +1,87 @@ +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 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(); + } + + 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(); + } +} diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java new file mode 100644 index 00000000..95941e6e --- /dev/null +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -0,0 +1,61 @@ +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 + ) { + } +} diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index c29b0aa8..ce99bd95 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -100,6 +100,8 @@ public class State { public boolean DISJOINTDEBUGSCHEDULING=false; + public boolean OOOJAVA=false; + public boolean OPTIONAL=false; public boolean ARRAYPAD=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 04fb7540..51ebbeb6 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -41,8 +41,9 @@ import Analysis.Locality.GenerateConversions; 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; @@ -319,6 +320,11 @@ public class Main { } 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"); @@ -495,12 +501,20 @@ public class Main { 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); diff --git a/Robust/src/Makefile b/Robust/src/Makefile index e5185d39..d3fbb1b7 100644 --- a/Robust/src/Makefile +++ b/Robust/src/Makefile @@ -97,6 +97,7 @@ Analysis/MLP/VSTWrapper.class \ 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 \