differentiate between analysis says something points-to nothing verus analysis doesn...
authorjjenista <jjenista>
Wed, 11 May 2011 21:29:50 +0000 (21:29 +0000)
committerjjenista <jjenista>
Wed, 11 May 2011 21:29:50 +0000 (21:29 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/HeapAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/IR/Flat/BCXPointsToCheckVRuntime.java

index 6f706d11481bd0bd6740951ac2a9702f2d8b9ee2..a2bf09fcb3dc146787c6745dd0e1591b24dd9394 100644 (file)
@@ -5,6 +5,7 @@ import Analysis.Liveness;
 import Analysis.ArrayReferencees;
 import Analysis.OoOJava.Accessible;
 import Analysis.OoOJava.RBlockRelationAnalysis;
+import Analysis.FlatIRGraph.*;
 import IR.*;
 import IR.Flat.*;
 import IR.Tree.Modifiers;
@@ -1994,16 +1995,51 @@ public class DisjointAnalysis implements HeapAnalysis {
                            );
 
     TempDescriptor cmdLineArgs =
-      new TempDescriptor("args",
+      new TempDescriptor("analysisEntryTemp_args",
                          mdSourceEntry.getParamType(0)
                          );
 
-    FlatNew fn =
+    FlatNew fnArgs =
       new FlatNew(mdSourceEntry.getParamType(0),
                   cmdLineArgs,
                   false  // is global
                   );
-    this.constructedCmdLineArgsNew = fn;
+    this.constructedCmdLineArgsNew = fnArgs;
+
+    
+    // jjenista - we might want to model more of the initial context
+    // someday, so keep this trickery in that case.  For now, this analysis
+    // ignores immutable types which includes String, so the following flat
+    // nodes will not add anything to the reach graph.
+    //
+    //TempDescriptor anArg =
+    //  new TempDescriptor("analysisEntryTemp_arg",
+    //                     mdSourceEntry.getParamType(0).dereference()
+    //                     );
+    //
+    //FlatNew fnArg =
+    //  new FlatNew(mdSourceEntry.getParamType(0).dereference(),
+    //              anArg,
+    //              false  // is global
+    //              );
+    //
+    //TempDescriptor index =
+    //  new TempDescriptor("analysisEntryTemp_index",
+    //                     new TypeDescriptor(TypeDescriptor.INT)
+    //                     );
+    //
+    //FlatLiteralNode fl =
+    //  new FlatLiteralNode(new TypeDescriptor(TypeDescriptor.INT),
+    //                      new Integer( 0 ),
+    //                      index
+    //                      );
+    //
+    //FlatSetElementNode fse =
+    //  new FlatSetElementNode(cmdLineArgs,
+    //                         index,
+    //                         anArg
+    //                         );
+
 
     TempDescriptor[] sourceEntryArgs = new TempDescriptor[1];
     sourceEntryArgs[0] = cmdLineArgs;
@@ -2024,8 +2060,8 @@ public class DisjointAnalysis implements HeapAnalysis {
                      fe
                      );
 
-    this.fmAnalysisEntry.addNext(fn);
-    fn.addNext(fc);
+    this.fmAnalysisEntry.addNext(fnArgs);
+    fnArgs.addNext(fc);
     fc.addNext(frn);
     frn.addNext(fe);
   }
@@ -2765,7 +2801,7 @@ public class DisjointAnalysis implements HeapAnalysis {
       return null; 
     }
     
-    return rgAtEnter.canPointTo( x, f.getSymbol() );
+    return rgAtEnter.canPointTo( x, f.getSymbol(), f.getType() );
   }
 
 
@@ -2780,6 +2816,6 @@ public class DisjointAnalysis implements HeapAnalysis {
     assert x.getType() != null;
     assert x.getType().isArray();
 
-    return rgAtEnter.canPointTo( x, arrayElementFieldName );
+    return rgAtEnter.canPointTo( x, arrayElementFieldName, x.getType().dereference() );
   }
 }
index aaee0c3f1acccd69bf7045fd3eff7e7ced251bf3..1228c9c63861cf755ad968d29d88de3b05163234 100644 (file)
@@ -19,6 +19,15 @@ public interface HeapAnalysis {
   // a field or element dereference you get a hashtable
   // where the keys are allocs for the variables and the
   // values are from following the second hop
+  // NOTE: if the set of Alloc's that something can point
+  // to is DONTCARE, this will mean "the analysis doesn't care
+  // what it points to" so the client shouldn't either, NOT
+  // interpreting it as "it can't point to anything."  The
+  // meaning "it can't point to anything" will be represented
+  // by an empty set of Alloc.
+  static public final Set<Alloc>                     DONTCARE_PTR  = new HashSet<Alloc>();
+  static public final Hashtable< Alloc, Set<Alloc> > DONTCARE_DREF = new Hashtable< Alloc, Set<Alloc> >();
+
   public Set<Alloc> canPointToAt( TempDescriptor x,
                                   FlatNode programPoint );
 
index 6cd946f9ccebef7649c6be7b0fa03a817ccb7ea2..ca2616e08098f2cf0cd478ac5c24787c6670827c 100644 (file)
@@ -5194,17 +5194,24 @@ public class ReachGraph {
 
 
   public Set<Alloc> canPointTo( TempDescriptor x ) {
-    VariableNode vn = getVariableNodeNoMutation( x );
-    if( vn == null ) {
-      return null;
+
+    if( !DisjointAnalysis.shouldAnalysisTrack( x.getType() ) ) {
+      // if we don't care to track it, return null which means
+      // "a client of this result shouldn't care either"
+      return HeapAnalysis.DONTCARE_PTR;
     }
 
     Set<Alloc> out = new HashSet<Alloc>();
 
+    VariableNode vn = getVariableNodeNoMutation( x );
+    if( vn == null ) {
+      // the empty set means "can't point to anything"
+      return out;
+    }
+
     Iterator<RefEdge> edgeItr = vn.iteratorToReferencees();
     while( edgeItr.hasNext() ) {
       HeapRegionNode hrn = edgeItr.next().getDst();
-
       out.add( hrn.getAllocSite() );
     }
 
@@ -5214,20 +5221,35 @@ public class ReachGraph {
 
 
   public Hashtable< Alloc, Set<Alloc> > canPointTo( TempDescriptor x,
-                                                    String         field ) {
+                                                    String         field,
+                                                    TypeDescriptor fieldType ) {
+
+    if( !DisjointAnalysis.shouldAnalysisTrack( x.getType() ) ) {
+      // if we don't care to track it, return null which means
+      // "a client of this result shouldn't care either"
+      return HeapAnalysis.DONTCARE_DREF;
+    }
+
+    Hashtable< Alloc, Set<Alloc> > out = new Hashtable< Alloc, Set<Alloc> >();
     
     VariableNode vn = getVariableNodeNoMutation( x );
     if( vn == null ) {
-      return null;
+      // the empty set means "can't point to anything"
+      return out;
     }
 
-    Hashtable< Alloc, Set<Alloc> > out = new Hashtable< Alloc, Set<Alloc> >();
 
     Iterator<RefEdge> edgeItr = vn.iteratorToReferencees();
     while( edgeItr.hasNext() ) {
       HeapRegionNode hrn = edgeItr.next().getDst();
+      Alloc          key = hrn.getAllocSite();
 
-      Alloc key = hrn.getAllocSite();
+      if( !DisjointAnalysis.shouldAnalysisTrack( fieldType ) ) {
+        // if we don't care to track it, put no entry which means
+        // "a client of this result shouldn't care either"
+        out.put( key, HeapAnalysis.DONTCARE_PTR );
+        continue;
+      }
 
       Set<Alloc> moreValues = new HashSet<Alloc>();
       Iterator<RefEdge> edgeItr2 = hrn.iteratorToReferencees();
index ce47b099b02346611dd83ee54525f3956b914f46..9cfca9975f01cb6c2e4ca4b58c615568d6ca74f4 100644 (file)
@@ -189,11 +189,20 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension {
                                       TempDescriptor x,
                                       Set<Alloc>     targetsByAnalysis ) {
 
+    assert targetsByAnalysis != null;
+
+
     output.println( "" );
     output.println( "// asserts vs. heap results (DEBUG)" );
     
-    if( targetsByAnalysis == null ||
-        targetsByAnalysis.isEmpty() ) {
+
+    if( targetsByAnalysis == HeapAnalysis.DONTCARE_PTR ) {
+      output.println( "// ANALYSIS DIDN'T CARE WHAT "+x+" POINTS-TO" );
+      return;
+    }
+
+    
+    if( targetsByAnalysis.isEmpty() ) {
       output.println( "assert( "+
                       buildCode.generateTemp( context, x )+
                       " == NULL );\n" );
@@ -228,13 +237,20 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension {
                                       FieldDescriptor                f, // this null OR
                                       TempDescriptor                 i, // this null
                                       Hashtable< Alloc, Set<Alloc> > targetsByAnalysis ) {
-
+    assert targetsByAnalysis != null;
+    
     assert f == null || i == null;
 
     output.println( "// asserts vs. heap results (DEBUG)" );
+
+
+    if( targetsByAnalysis == HeapAnalysis.DONTCARE_DREF ) {
+      output.println( "// ANALYSIS DIDN'T CARE WHAT "+x+" POINTS-TO" );
+      return;
+    }
+    
     
-    if( targetsByAnalysis == null ||
-        targetsByAnalysis.isEmpty() ) {
+    if( targetsByAnalysis.isEmpty() ) {
       output.println( "assert( "+
                       buildCode.generateTemp( context, x )+
                       " == NULL );\n" );
@@ -274,10 +290,14 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension {
         
         output.print( "case "+
                       k.getUniqueAllocSiteID()+
-                      ": assert( allocsiteOneHop == -1" );
-        
+                      ":" );
+
         Set<Alloc> hopTargets = targetsByAnalysis.get( k );
-        if( hopTargets != null ) {
+        if( hopTargets == HeapAnalysis.DONTCARE_PTR ) {
+          output.print( "/* ANALYSIS DOESN'T CARE */" );
+
+        } else {
+          output.print( "assert( allocsiteOneHop == -1" );
 
           if( !hopTargets.isEmpty() ) {
             output.print( " || " );
@@ -294,9 +314,11 @@ public class BCXPointsToCheckVRuntime implements BuildCodeExtension {
               output.print( " || " );
             }
           }
+     
+          output.print( " );" );
         }
 
-        output.println( " ); break;" );
+        output.println( " break;" );
       }
 
       output.println( "    default: assert( 0 ); break;" );