From 5d17a9b6f7eaa8718abbf219821dc7c0f34ee0ec Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 25 Mar 2010 20:14:08 +0000 Subject: [PATCH] bug fixes for task initial heaps and making all new edges have true predicates attached to reach states on the edge --- Robust/src/Analysis/Disjoint/Canonical.java | 64 +++++++++++++++++++ Robust/src/Analysis/Disjoint/CanonicalOp.java | 3 + .../Analysis/Disjoint/DisjointAnalysis.java | 34 +++++----- Robust/src/Analysis/Disjoint/ReachGraph.java | 46 +++++++------ Robust/src/Analysis/Disjoint/ReachState.java | 3 +- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java index 7f380b58..bd4b8ee1 100644 --- a/Robust/src/Analysis/Disjoint/Canonical.java +++ b/Robust/src/Analysis/Disjoint/Canonical.java @@ -1278,4 +1278,68 @@ abstract public class Canonical { return out; } + + + public static ReachState makePredsTrue( ReachState rs ) { + assert rs != null; + assert rs.isCanonical(); + + // ops require two canonicals, in this case always supply + // the empty reach state as the second, it's never used, + // but makes the hashing happy + CanonicalOp op = + new CanonicalOp( CanonicalOp.REACHSTATE_MAKEPREDSTRUE, + rs, + ReachState.factory() ); + + Canonical result = op2result.get( op ); + if( result != null ) { + return (ReachState) result; + } + + // otherwise, no cached result... + ReachState out = new ReachState(); + + // just remake state with the true predicate attached + out.reachTuples.addAll( rs.reachTuples ); + out.preds = ExistPredSet.factory( ExistPred.factory() ); + + out = (ReachState) makeCanonical( out ); + op2result.put( op, out ); + return out; + } + + + public static ReachSet makePredsTrue( ReachSet rs ) { + assert rs != null; + assert rs.isCanonical(); + + // ops require two canonicals, in this case always supply + // the empty reach set as the second, it's never used, + // but makes the hashing happy + CanonicalOp op = + new CanonicalOp( CanonicalOp.REACHSET_MAKEPREDSTRUE, + rs, + ReachSet.factory() ); + + Canonical result = op2result.get( op ); + if( result != null ) { + return (ReachSet) result; + } + + // otherwise, no cached result... + ReachSet out = ReachSet.factory(); + Iterator itr = rs.iterator(); + while( itr.hasNext() ) { + ReachState state = itr.next(); + out = Canonical.add( out, + Canonical.makePredsTrue( state ) + ); + } + + out = (ReachSet) makeCanonical( out ); + op2result.put( op, out ); + return out; + } + } diff --git a/Robust/src/Analysis/Disjoint/CanonicalOp.java b/Robust/src/Analysis/Disjoint/CanonicalOp.java index 73caa309..59b72f0d 100644 --- a/Robust/src/Analysis/Disjoint/CanonicalOp.java +++ b/Robust/src/Analysis/Disjoint/CanonicalOp.java @@ -32,6 +32,9 @@ public class CanonicalOp { public static final int REACHSTATE_TOCALLERCONTEXT_ALLOCSITE = 0xb2b1; public static final int REACHSET_UNSHADOW_ALLOCSITE = 0x1049; public static final int REACHSTATE_UNSHADOW_ALLOCSITE = 0x08ef; + public static final int REACHSTATE_MAKEPREDSTRUE = 0x0b9c; + public static final int REACHSET_MAKEPREDSTRUE = 0xdead; + protected int opCode; protected Canonical operand1; diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 8b946378..021446d5 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -1094,8 +1094,8 @@ public class DisjointAnalysis { rg.writeGraph( "IHMPARTFOR"+d+"FROM"+fc, true, // write labels (variables) - false, // selectively hide intermediate temp vars - false, // prune unreachable heap regions + true, // selectively hide intermediate temp vars + true, // prune unreachable heap regions false, // hide subset reachability states true ); // hide edge taints } @@ -1124,7 +1124,7 @@ public class DisjointAnalysis { rg.writeGraph( d+"COMPLETE"+String.format( "%05d", n ), true, // write labels (variables) true, // selectively hide intermediate temp vars - false, // prune unreachable heap regions + true, // prune unreachable heap regions false, // hide subset reachability states true ); // hide edge taints @@ -1590,7 +1590,7 @@ private Set getFieldSetTobeAnalyzed(TypeDescriptor typeDesc){ } -private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite alloc, HeapRegionNode srcHRN, FieldDescriptor fd, Hashtable map, Hashtable mapToExistingNode ){ + private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite alloc, HeapRegionNode srcHRN, FieldDescriptor fd, Hashtable map, Hashtable mapToExistingNode, ReachSet alpha ){ int dimCount=fd.getType().getArrayCount(); HeapRegionNode prevNode=null; @@ -1617,8 +1617,8 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite as.getType(), // type as, // allocation site null, // inherent reach - null, // current reach - ExistPredSet.factory(), // predicates + alpha, // current reach + ExistPredSet.factory(rg.predTrue), // predicates tempDesc.toString() // description ); rg.id2hrn.put(as.getSummary(),hrnSummary); @@ -1634,7 +1634,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite hrnSummary, // dest typeDesc, // type fd.getSymbol(), // field name - srcHRN.getAlpha(), // beta + alpha, // beta ExistPredSet.factory(rg.predTrue) // predicates ); @@ -1647,7 +1647,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite hrnSummary, // dest typeDesc, // type arrayElementFieldName, // field name - srcHRN.getAlpha(), // beta + alpha, // beta ExistPredSet.factory(rg.predTrue) // predicates ); @@ -1675,8 +1675,8 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite typeDesc, // type as, // allocation site null, // inherent reach - null, // current reach - ExistPredSet.factory(), // predicates + alpha, // current reach + ExistPredSet.factory(rg.predTrue), // predicates tempDesc.toString() // description ); rg.id2hrn.put(as.getSummary(),hrnSummary); @@ -1685,7 +1685,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite hrnSummary, // dest typeDesc, // type arrayElementFieldName, // field name - null, // beta + alpha, // beta ExistPredSet.factory(rg.predTrue) // predicates ); rg.addRefEdge(prevNode, hrnSummary, edgeToSummary); @@ -1697,7 +1697,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite hrnSummary, // dest typeDesc, // type arrayElementFieldName, // field name - null, // beta + alpha, // beta ExistPredSet.factory(rg.predTrue) // predicates ); rg.addRefEdge(prevNode, hrnSummary, edgeToSummary); @@ -1787,7 +1787,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) { HeapRegionNode hrnSummary; if(allocType.isArray() && allocType.getArrayCount()>0){ - hrnSummary=createMultiDeimensionalArrayHRN(rg,allocSite,srcHRN,fd,mapToFirstDimensionArrayNode,mapTypeToExistingSummaryNode); + hrnSummary=createMultiDeimensionalArrayHRN(rg,allocSite,srcHRN,fd,mapToFirstDimensionArrayNode,mapTypeToExistingSummaryNode,hrnNewest.getAlpha()); }else{ hrnSummary = rg.createNewHeapRegionNode(allocSite.getSummary(), // id or null to generate a new one @@ -1798,8 +1798,8 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) { allocSite.getType(), // type allocSite, // allocation site null, // inherent reach - srcHRN.getAlpha(), // current reach - ExistPredSet.factory(), // predicates + hrnNewest.getAlpha(), // current reach + ExistPredSet.factory(rg.predTrue), // predicates strDesc // description ); rg.id2hrn.put(allocSite.getSummary(),hrnSummary); @@ -1809,7 +1809,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) { hrnSummary, // dest type, // type fd.getSymbol(), // field name - srcHRN.getAlpha(), // beta + hrnNewest.getAlpha(), // beta ExistPredSet.factory(rg.predTrue) // predicates ); @@ -2043,7 +2043,7 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) { rg.writeGraph( graphName, true, // write labels (variables) true, // selectively hide intermediate temp vars - false, // prune unreachable heap regions + true, // prune unreachable heap regions false, // hide subset reachability states true );// hide edge taints } diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index d1259c14..f67efa91 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -123,15 +123,17 @@ public class ReachGraph { if( inherent == null ) { if( markForAnalysis ) { inherent = - ReachSet.factory( - ReachState.factory( - ReachTuple.factory( id, - !isSingleObject, - ReachTuple.ARITY_ONE, - false // out-of-context - ) - ) - ); + Canonical.makePredsTrue( + ReachSet.factory( + ReachState.factory( + ReachTuple.factory( id, + !isSingleObject, + ReachTuple.ARITY_ONE, + false // out-of-context + ) + ) + ) + ); } else { inherent = rsetWithEmptyState; } @@ -592,15 +594,18 @@ public class ReachGraph { hrnY.getType() ); - RefEdge edgeNew = new RefEdge( hrnX, - hrnY, - tdNewEdge, - f.getSymbol(), - Canonical.pruneBy( edgeY.getBeta(), - hrnX.getAlpha() - ), - predsTrue - ); + RefEdge edgeNew = + new RefEdge( hrnX, + hrnY, + tdNewEdge, + f.getSymbol(), + Canonical.makePredsTrue( + Canonical.pruneBy( edgeY.getBeta(), + hrnX.getAlpha() + ) + ), + predsTrue + ); addEdgeOrMergeWithExisting( edgeNew ); } @@ -1895,7 +1900,8 @@ public class ReachGraph { if( writeDebugDOTs ) { - rg.writeGraph( "calleeview", + debugGraphPrefix = String.format( "call%02d", debugCallSiteVisits ); + rg.writeGraph( debugGraphPrefix+"calleeview", resolveMethodDebugDOTwriteLabels, resolveMethodDebugDOTselectTemps, resolveMethodDebugDOTpruneGarbage, @@ -1913,7 +1919,7 @@ public class ReachGraph { // useful since many graphs writes in the method call debug code private static boolean resolveMethodDebugDOTwriteLabels = true; private static boolean resolveMethodDebugDOTselectTemps = true; - private static boolean resolveMethodDebugDOTpruneGarbage = false; + private static boolean resolveMethodDebugDOTpruneGarbage = true; private static boolean resolveMethodDebugDOThideSubsetReach = false; private static boolean resolveMethodDebugDOThideEdgeTaints = true; diff --git a/Robust/src/Analysis/Disjoint/ReachState.java b/Robust/src/Analysis/Disjoint/ReachState.java index a1052a6f..aacd7aac 100644 --- a/Robust/src/Analysis/Disjoint/ReachState.java +++ b/Robust/src/Analysis/Disjoint/ReachState.java @@ -152,7 +152,8 @@ public class ReachState extends Canonical { public String toString() { - return reachTuples.toString(); + //return reachTuples.toString(); + return reachTuples+":"+preds; } public String toStringPreds() { -- 2.34.1