X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FDisjoint%2FEffect.java;h=0565b6f092e18863aa88dd35137252647f21d78b;hp=5e59e005ba6ec650d6f462712df5ec5b3b91c592;hb=afd7a5aa1f2cb7b0d7110f61978502caa93ce5b6;hpb=6d26ad1d02cdc6937c61c34b3e06939217aba5bb diff --git a/Robust/src/Analysis/Disjoint/Effect.java b/Robust/src/Analysis/Disjoint/Effect.java index 5e59e005..0565b6f0 100644 --- a/Robust/src/Analysis/Disjoint/Effect.java +++ b/Robust/src/Analysis/Disjoint/Effect.java @@ -1,14 +1,16 @@ package Analysis.Disjoint; -import IR.FieldDescriptor; -import IR.Flat.TempDescriptor; +import java.util.*; + +import IR.*; +import IR.Flat.*; public class Effect { // 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; @@ -19,10 +21,82 @@ public class Effect { // identify a field protected FieldDescriptor field; - public Effect(Alloc affectedAS, int type, FieldDescriptor field) { + // for debugging purposes, keep the compilation + // unit and line number of this effect--only if state + // is non-null later + protected int lineNumber; + protected ClassDescriptor compilationUnit; + protected static Hashtable fn2cd = + new Hashtable(); + + + public Effect(Alloc affectedAS, int type, FieldDescriptor field, FlatNode currentProgramPoint) { this.affectedAllocSite = affectedAS; this.type = type; this.field = field; + + + // NOTE: this line number+compilation unit is collected for debugging, + // so we don't want to spend time on this unless OOODEBUG or some new + // option controls it. Disjoint and Pointer analysis use this currently. + lineNumber = -1; + compilationUnit = null; + + // find the class the current program point belongs to + if( currentProgramPoint == null ) { + return; + } + Set visited = new HashSet(); + Set toVisit = new HashSet(); + toVisit.add( currentProgramPoint ); + + while( !toVisit.isEmpty() ) { + FlatNode fn = toVisit.iterator().next(); + toVisit.remove( fn ); + visited.add( fn ); + + // when we find a flat method, remember every node we visited + // belongs to that compilation unit + if( fn instanceof FlatMethod ) { + MethodDescriptor md = ((FlatMethod)fn).getMethod(); + if( md != null ) { + ClassDescriptor cd = md.getClassDesc(); + if( cd != null ) { + fn2cd.put( fn, cd ); + } + } + } + + if( fn2cd.containsKey( fn ) ) { + compilationUnit = fn2cd.get( fn ); + + for( FlatNode fnKnown: visited ) { + fn2cd.put( fnKnown, compilationUnit ); + } + + lineNumber = currentProgramPoint.getNumLine(); + break; + } + + for( int i = 0; i < fn.numPrev(); ++i ) { + FlatNode prev = fn.getPrev( i ); + if( !visited.contains( prev ) ) { + toVisit.add( prev ); + } + } + } + } + + public static boolean isWrite(int effect) { + return (effect & Effect.write)==Effect.write; + } + + public boolean isWrite() { + return type==write; + } + + public boolean isRead() { + return type==read; } public Alloc getAffectedAllocSite() { @@ -60,11 +134,11 @@ public class Effect { } Effect in = (Effect) o; - - if (affectedAllocSite.equals(in.getAffectedAllocSite()) - && type == in.getType() + + if (affectedAllocSite.equals(in.getAffectedAllocSite()) + && type == in.getType() && ((field!=null&&field.equals(in.getField()))|| - (field==null&&in.getField()==null))) { + (field==null&&in.getField()==null))) { return true; } else { return false; @@ -103,6 +177,11 @@ public class Effect { } else { s += ", " + field.toStringBrief(); } + + if( compilationUnit != null ) { + s += ", "+compilationUnit.getSymbol()+":"+lineNumber; + } + return s + ")"; }