From 9b0b0cb289d33ee10cf60c2e09239062384c9ab6 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 16 Oct 2009 17:57:13 +0000 Subject: [PATCH] compiler options for call map debugging --- .../OwnershipAnalysis/OwnershipAnalysis.java | 27 +++++++--- .../OwnershipAnalysis/OwnershipGraph.java | 53 ++++++++++--------- .../ParameterDecomposition.java | 4 +- Robust/src/IR/State.java | 3 ++ Robust/src/Main/Main.java | 8 ++- 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index c28f264c..87d53ba8 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -76,7 +76,7 @@ public class OwnershipAnalysis { assert d != null; - OwnershipGraph og = new OwnershipGraph( allocationDepth, typeUtil ); + OwnershipGraph og = new OwnershipGraph(); assert mapDescriptorToAllMethodContexts.containsKey( d ); HashSet contexts = mapDescriptorToAllMethodContexts.get( d ); @@ -454,6 +454,17 @@ public class OwnershipAnalysis { 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(); mapMethodContextToInitialParamAllocGraph = @@ -517,7 +528,7 @@ public class OwnershipAnalysis { Iterator 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 ) { @@ -709,7 +720,7 @@ public class OwnershipAnalysis { // 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 ) { @@ -756,7 +767,7 @@ public class OwnershipAnalysis { // 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(); @@ -844,7 +855,7 @@ public class OwnershipAnalysis { og.prepareParamTokenMaps( fm ); // cache the graph - OwnershipGraph ogResult = new OwnershipGraph(allocationDepth, typeUtil); + OwnershipGraph ogResult = new OwnershipGraph(); ogResult.merge(og); mapMethodContextToInitialParamAllocGraph.put(mc, ogResult); @@ -960,7 +971,7 @@ public class OwnershipAnalysis { 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 @@ -1009,7 +1020,7 @@ public class OwnershipAnalysis { // 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 aliasedParamIndices = @@ -1494,7 +1505,7 @@ public class OwnershipAnalysis { Hashtable 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 paramIndex2paramTokenSecondaryStar; - public OwnershipGraph(int allocationDepth, TypeUtil typeUtil) { - this.allocationDepth = allocationDepth; - this.typeUtil = typeUtil; + public OwnershipGraph() { id2hrn = new Hashtable(); td2ln = new Hashtable(); @@ -1891,19 +1892,10 @@ public class OwnershipGraph { 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", @@ -2965,8 +2957,11 @@ public class OwnershipGraph { } - 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) @@ -3048,8 +3043,11 @@ public class OwnershipGraph { } - 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) @@ -3069,8 +3067,11 @@ public class OwnershipGraph { } - 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) @@ -3083,7 +3084,7 @@ public class OwnershipGraph { } catch( IOException e ) {} System.out.println( " "+mc+" done calling "+fm ); ++x; - if( x > 2 ) { + if( x == debugCallMapCount ) { System.exit( -1 ); } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/ParameterDecomposition.java b/Robust/src/Analysis/OwnershipAnalysis/ParameterDecomposition.java index 2015f367..5707abab 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ParameterDecomposition.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ParameterDecomposition.java @@ -58,10 +58,10 @@ public class ParameterDecomposition { // 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(); diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 6eadf3ed..2e4c037c 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -66,6 +66,9 @@ public class State { 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; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index c5f14656..4ee1bcd2 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -145,7 +145,13 @@ public class Main { 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; -- 2.34.1