assert d != null;
- OwnershipGraph og = new OwnershipGraph( allocationDepth, typeUtil );
+ OwnershipGraph og = new OwnershipGraph();
assert mapDescriptorToAllMethodContexts.containsKey( d );
HashSet<MethodContext> contexts = mapDescriptorToAllMethodContexts.get( d );
this.writeDOTs = writeDOTs;
this.writeAllDOTs = writeAllDOTs;
+ // set some static configuration for OwnershipGraphs
+ OwnershipGraph.allocationDepth = allocationDepth;
+ OwnershipGraph.typeUtil = typeUtil;
+ OwnershipGraph.debugCallMapCount = state.OWNERSHIPDEBUGCALLCOUNT;
+ OwnershipGraph.debugCallee = state.OWNERSHIPDEBUGCALLEE;
+ OwnershipGraph.debugCaller = state.OWNERSHIPDEBUGCALLER;
+ if( OwnershipGraph.debugCallee != null &&
+ OwnershipGraph.debugCaller != null ) {
+ OwnershipGraph.debugCallMap = true;
+ }
+
descriptorsToAnalyze = new HashSet<Descriptor>();
mapMethodContextToInitialParamAllocGraph =
Iterator<Descriptor> dItr = descriptorsToAnalyze.iterator();
while( dItr.hasNext() ) {
Descriptor d = dItr.next();
- OwnershipGraph og = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph og = new OwnershipGraph();
FlatMethod fm;
if( d instanceof MethodDescriptor ) {
// perform this node's contributions to the ownership
// graph on a new copy, then compare it to the old graph
// at this node to see if anything was updated.
- OwnershipGraph og = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph og = new OwnershipGraph();
// start by merging all node's parents' graphs
for( int i = 0; i < fn.numPrev(); ++i ) {
// end by merging all return nodes into a complete
// ownership graph that represents all possible heap
// states after the flat method returns
- OwnershipGraph completeGraph = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph completeGraph = new OwnershipGraph();
Iterator retItr = returnNodesToCombineForCompleteOwnershipGraph.iterator();
while( retItr.hasNext() ) {
FlatReturnNode frn = (FlatReturnNode) retItr.next();
og.prepareParamTokenMaps( fm );
// cache the graph
- OwnershipGraph ogResult = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph ogResult = new OwnershipGraph();
ogResult.merge(og);
mapMethodContextToInitialParamAllocGraph.put(mc, ogResult);
FlatCall fc = (FlatCall) fn;
MethodDescriptor md = fc.getMethod();
FlatMethod flatm = state.getMethodFlat(md);
- OwnershipGraph ogMergeOfAllPossibleCalleeResults = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph ogMergeOfAllPossibleCalleeResults = new OwnershipGraph();
if( md.isStatic() ) {
// a static method is simply always the same, makes life easy
// don't alter the working graph (og) until we compute a result for every
// possible callee, merge them all together, then set og to that
- OwnershipGraph ogCopy = new OwnershipGraph(allocationDepth, typeUtil);
+ OwnershipGraph ogCopy = new OwnershipGraph();
ogCopy.merge(og);
Set<Integer> aliasedParamIndices =
Hashtable<FlatNode, OwnershipGraph> table=mapMethodContextToFlatNodeOwnershipGraph.get(callerMC);
// merge previous ownership graph to calculate corresponding method context
- OwnershipGraph mergeOG = new OwnershipGraph( allocationDepth, typeUtil );
+ OwnershipGraph mergeOG = new OwnershipGraph();
for(int i=0;i<fc.numPrev();i++){
FlatNode prevNode=fc.getPrev(i);
protected static final boolean DISABLE_STRONG_UPDATES = false;
protected static final boolean DISABLE_GLOBAL_SWEEP = false;
-
- private int allocationDepth;
- private TypeUtil typeUtil;
+ protected static int allocationDepth = -1;
+ protected static TypeUtil typeUtil = null;
+ protected static boolean debugCallMap = false;
+ protected static int debugCallMapCount = 0;
+ protected static String debugCallee = null;
+ protected static String debugCaller = null;
// there was already one other very similar reason
// for traversing heap nodes that is no longer needed
public Hashtable<Integer, TokenTuple> paramIndex2paramTokenSecondaryStar;
- public OwnershipGraph(int allocationDepth, TypeUtil typeUtil) {
- this.allocationDepth = allocationDepth;
- this.typeUtil = typeUtil;
+ public OwnershipGraph() {
id2hrn = new Hashtable<Integer, HeapRegionNode>();
td2ln = new Hashtable<TempDescriptor, LabelNode >();
ParameterDecomposition pd // if this is not null, we're calling after analysis
) {
-
- // this debug snippet is harmless for regular use and INVALUABLE at debug time
- // to see what potentially goes wrong when a specific method calls another
- String debugCaller = "foo";
- String debugCallee = "bar";
- //String debugCaller = "StandardEngine";
- //String debugCaller = "register_by_type";
- //String debugCaller = "register_by_type_front";
- //String debugCaller = "addFirst";
- //String debugCallee = "LinkedListElement";
-
- if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
- fm.getMethod().getSymbol().equals( debugCallee ) ) {
+ if( debugCallMap &&
+ mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+ fm.getMethod().getSymbol().equals( debugCallee )
+ ) {
try {
writeGraph("debug1BeforeCall",
}
- if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
- fm.getMethod().getSymbol().equals( debugCallee ) ) {
+ if( debugCallMap &&
+ mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+ fm.getMethod().getSymbol().equals( debugCallee )
+ ) {
+
try {
writeGraph("debug7JustBeforeMergeToKCapacity",
true, // write labels (variables)
}
- if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
- fm.getMethod().getSymbol().equals( debugCallee ) ) {
+ if( debugCallMap &&
+ mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+ fm.getMethod().getSymbol().equals( debugCallee )
+ ) {
+
try {
writeGraph( "debug8JustBeforeSweep",
true, // write labels (variables)
}
- if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
- fm.getMethod().getSymbol().equals( debugCallee ) ) {
+ if( debugCallMap &&
+ mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+ fm.getMethod().getSymbol().equals( debugCallee )
+ ) {
+
try {
writeGraph( "debug9endResolveCall",
true, // write labels (variables)
} catch( IOException e ) {}
System.out.println( " "+mc+" done calling "+fm );
++x;
- if( x > 2 ) {
+ if( x == debugCallMapCount ) {
System.exit( -1 );
}
}
// make copies of the graphs so that resolveMethodCall can
// destroy the graph while calculating the stuff we want
- this.ogCallee = new OwnershipGraph( oa.allocationDepth, oa.typeUtil );
+ this.ogCallee = new OwnershipGraph();
this.ogCallee.merge( cee );
- this.ogCaller = new OwnershipGraph( oa.allocationDepth, oa.typeUtil );
+ this.ogCaller = new OwnershipGraph();
this.ogCaller.merge( cer );
allocOutputStructs();
public boolean OWNERSHIPWRITEALL=false;
public String OWNERSHIPALIASFILE=null;
public boolean OWNERSHIPALIASTAB=false;
+ public int OWNERSHIPDEBUGCALLCOUNT=0;
+ public String OWNERSHIPDEBUGCALLEE=null;
+ public String OWNERSHIPDEBUGCALLER=null;
public boolean OPTIONAL=false;
public boolean ARRAYBOUNDARYCHECK=true;
public boolean RAW=false;
state.OWNERSHIPALIASFILE=args[++i];
} else if (option.equals("-ownaliasfiletab")) {
state.OWNERSHIPALIASFILE=args[++i];
- state.OWNERSHIPALIASTAB=true;
+ state.OWNERSHIPALIASTAB=true;
+ } else if (option.equals("-owndebugcallee")) {
+ state.OWNERSHIPDEBUGCALLEE=args[++i];
+ } else if (option.equals("-owndebugcaller")) {
+ state.OWNERSHIPDEBUGCALLER=args[++i];
+ } else if (option.equals("-owndebugcallcount")) {
+ state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
}
else if (option.equals("-optional"))
state.OPTIONAL=true;