decouple IR caching from AnalysisOptions with a new AnalysisCache object

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1521 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-07-20 15:20:58 +00:00
parent 59368d41ac
commit 5dbfbda22c
9 changed files with 56 additions and 51 deletions

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -22,7 +23,7 @@ import com.ibm.wala.j2ee.J2EEAnalysisScope;
*
* @author sfink
*/
public interface CallGraphBuilderFactory extends com.ibm.wala.client.CallGraphBuilderFactory {
public interface J2EECallGraphBuilderFactory extends com.ibm.wala.client.CallGraphBuilderFactory {
public final static String IMPL_PROPERTY = "callGraphBuilderFactoryImplementation";
@ -55,6 +56,6 @@ public interface CallGraphBuilderFactory extends com.ibm.wala.client.CallGraphBu
* preserve PointsTo graph for posterity?
*
*/
CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
CallGraphBuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
boolean keepPointsTo);
}

View File

@ -12,7 +12,7 @@ package com.ibm.wala.j2ee.client.impl;
import java.util.Properties;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.util.debug.Assertions;
/**
@ -30,13 +30,13 @@ public class CallGraphBuilderFactoryFactory {
* @param props Optionally, influence the construction of the engine.
* @return A non-null AppAnalysisEngine instance.
*/
public static CallGraphBuilderFactory getCallGraphBuilderFactory(Properties props) {
public static J2EECallGraphBuilderFactory getCallGraphBuilderFactory(Properties props) {
try {
String klass = "com.ibm.wala.j2ee.client.impl.RTABuilderFactory";
if (props != null) {
klass = props.getProperty("analysis", "com.ibm.wala.j2ee.client.impl.RTABuilderFactory");
}
return (CallGraphBuilderFactory) Class.forName(klass).newInstance();
return (J2EECallGraphBuilderFactory) Class.forName(klass).newInstance();
} catch (Exception e) {
e.printStackTrace();
Assertions.UNREACHABLE();

View File

@ -23,7 +23,7 @@ import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EEAnalysisEngine;
import com.ibm.wala.j2ee.util.TopLevelArchiveModule;
import com.ibm.wala.j2ee.util.TopLevelArchiveModule.BloatedArchiveModule;
@ -44,7 +44,7 @@ public abstract class J2EEAbstractAnalysisEngine extends AbstractAnalysisEngine
private DeploymentMetaData dmd;
/**
* The J2EE libraries to analysze
* The J2EE libraries to analyze
*/
private Module[] j2eeLibs;
@ -57,7 +57,7 @@ public abstract class J2EEAbstractAnalysisEngine extends AbstractAnalysisEngine
}
protected CallGraphBuilder getCallGraphBuilder(ClassHierarchy cha, AnalysisOptions options) {
return ((CallGraphBuilderFactory) getCallGraphBuilderFactory()).make(options, cha, (J2EEAnalysisScope) getScope(), getDmd(),
return ((J2EECallGraphBuilderFactory) getCallGraphBuilderFactory()).make(options, getCache(), cha, (J2EEAnalysisScope) getScope(), getDmd(),
false);
}

View File

@ -10,12 +10,13 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client.impl;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.util.Util;
/**
@ -26,12 +27,12 @@ import com.ibm.wala.j2ee.util.Util;
*/
public class RTABuilderFactory
extends com.ibm.wala.client.impl.RTABuilderFactory
implements CallGraphBuilderFactory
implements J2EECallGraphBuilderFactory
{
public CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope,
public CallGraphBuilder make(AnalysisOptions options,AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope,
DeploymentMetaData dmd, boolean keepPointsTo) {
return Util.makeRTABuilder(options, cha, getClass().getClassLoader(), scope, dmd);
return Util.makeRTABuilder(options, cache,cha, getClass().getClassLoader(), scope, dmd);
}
}

View File

@ -10,12 +10,13 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client.impl;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.util.Util;
/**
@ -23,12 +24,12 @@ import com.ibm.wala.j2ee.util.Util;
*/
public class ZeroCFABuilderFactory
extends com.ibm.wala.client.impl.ZeroCFABuilderFactory
implements CallGraphBuilderFactory
implements J2EECallGraphBuilderFactory
{
public CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope,
public CallGraphBuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope,
DeploymentMetaData dmd, boolean keepPointsTo) {
return Util.makeZeroCFABuilder(options, cha, getClass().getClassLoader(), scope, dmd);
return Util.makeZeroCFABuilder(options, cache, cha, getClass().getClassLoader(), scope, dmd);
}
}

View File

@ -10,12 +10,13 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client.impl;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.util.Util;
/**
@ -26,12 +27,12 @@ import com.ibm.wala.j2ee.util.Util;
*/
public class ZeroContainerCFABuilderFactory
extends com.ibm.wala.client.impl.ZeroContainerCFABuilderFactory
implements CallGraphBuilderFactory
implements J2EECallGraphBuilderFactory
{
public CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
public CallGraphBuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
boolean keepPointsTo) {
return Util.makeZeroContainerCFABuilder(options, cha, getClass().getClassLoader(), scope, dmd);
return Util.makeZeroContainerCFABuilder(options, cache, cha, getClass().getClassLoader(), scope, dmd);
}
}

View File

@ -10,12 +10,13 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client.impl;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.util.Util;
/**
@ -25,12 +26,12 @@ import com.ibm.wala.j2ee.util.Util;
*/
public class ZeroOneCFABuilderFactory
extends com.ibm.wala.client.impl.ZeroOneCFABuilderFactory
implements CallGraphBuilderFactory
implements J2EECallGraphBuilderFactory
{
public CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope,
public CallGraphBuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope,
DeploymentMetaData dmd, boolean keepPointsTo) {
return Util.makeZeroOneCFABuilder(options, cha, getClass().getClassLoader(), scope, dmd);
return Util.makeZeroOneCFABuilder(options, cache, cha, getClass().getClassLoader(), scope, dmd);
}
}

View File

@ -10,12 +10,13 @@
*******************************************************************************/
package com.ibm.wala.j2ee.client.impl;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.j2ee.DeploymentMetaData;
import com.ibm.wala.j2ee.J2EEAnalysisScope;
import com.ibm.wala.j2ee.client.CallGraphBuilderFactory;
import com.ibm.wala.j2ee.client.J2EECallGraphBuilderFactory;
import com.ibm.wala.j2ee.util.Util;
/**
@ -25,13 +26,13 @@ import com.ibm.wala.j2ee.util.Util;
*/
public class ZeroOneContainerCFABuilderFactory
extends com.ibm.wala.client.impl.ZeroOneContainerCFABuilderFactory
implements CallGraphBuilderFactory
implements J2EECallGraphBuilderFactory
{
public CallGraphBuilder make(AnalysisOptions options, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
public CallGraphBuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, J2EEAnalysisScope scope, DeploymentMetaData dmd,
boolean keepPointsTo) {
return Util.makeZeroOneContainerCFABuilder(options, cha, getClass().getClassLoader(), scope, dmd);
return Util.makeZeroOneContainerCFABuilder(options, cache, cha, getClass().getClassLoader(), scope, dmd);
}
}

View File

@ -11,6 +11,7 @@ import java.util.Set;
import com.ibm.wala.analysis.typeInference.ReceiverTypeInferenceCache;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
@ -58,7 +59,7 @@ public class Util {
* @param dmd
* deployment descriptor abstraction
*/
public static CallGraphBuilder makeRTABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
public static CallGraphBuilder makeRTABuilder(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -66,13 +67,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new BasicRTABuilder(cha, options, appSelector, appInterpreter);
return new BasicRTABuilder(cha, options, cache, appSelector, appInterpreter);
}
/**
@ -86,11 +87,9 @@ public class Util {
* representation of the analysis scope
* @param dmd
* deployment descriptor abstraction
* @param warnings
* an object which tracks analysis warnings
* @return a 0-CFA Call Graph Builder.
*/
public static CFABuilder makeZeroCFABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
public static CFABuilder makeZeroCFABuilder(AnalysisOptions options, AnalysisCache cache,IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -98,13 +97,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new ZeroXCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec(), ZeroXInstanceKeys.NONE);
return new ZeroXCFABuilder(cha, options, cache, appSelector, appInterpreter, options.getReflectionSpec(), ZeroXInstanceKeys.NONE);
}
/**
@ -122,7 +121,7 @@ public class Util {
* an object which tracks analysis warnings
* @return a 1-CFA Call Graph Builder.
*/
public static CallGraphBuilder makeOneCFABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl,
public static CallGraphBuilder makeOneCFABuilder(AnalysisOptions options,AnalysisCache cache, IClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -130,13 +129,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
CallGraphBuilder builder = new OneCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec());
CallGraphBuilder builder = new OneCFABuilder(cha, options,cache, appSelector, appInterpreter, options.getReflectionSpec());
return builder;
}
@ -156,7 +155,7 @@ public class Util {
* This version uses the DEDUCED_PLUS_STRINGSTUFF policy to avoid
* disambiguating uninteresting types.
*/
public static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
public static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options, AnalysisCache cache,IClassHierarchy cha, ClassLoader cl, AnalysisScope scope,
DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -164,13 +163,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new ZeroXCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec(),
return new ZeroXCFABuilder(cha, options, cache,appSelector, appInterpreter, options.getReflectionSpec(),
ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS
| ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_THROWABLES);
}
@ -190,7 +189,7 @@ public class Util {
*
* This version uses the ALL policy to disambiguate all allocation sites
*/
public static CFABuilder makeZeroOneUnoptCFABuilder(AnalysisOptions options, ClassHierarchy cha, ClassLoader cl,
public static CFABuilder makeZeroOneUnoptCFABuilder(AnalysisOptions options, AnalysisCache cache,ClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -198,13 +197,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new ZeroXCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec(),
return new ZeroXCFABuilder(cha, options, cache,appSelector, appInterpreter, options.getReflectionSpec(),
ZeroXInstanceKeys.ALLOCATIONS);
}
@ -224,7 +223,7 @@ public class Util {
* @return a 0-CFA Call Graph Builder augmented with extra logic for
* containers
*/
public static CFABuilder makeZeroContainerCFABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl,
public static CFABuilder makeZeroContainerCFABuilder(AnalysisOptions options,AnalysisCache cache, IClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -232,13 +231,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new ZeroContainerCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec());
return new ZeroContainerCFABuilder(cha, options, cache,appSelector, appInterpreter, options.getReflectionSpec());
}
/**
@ -255,7 +254,7 @@ public class Util {
* @return a 0-1-CFA Call Graph Builder augmented with extra logic for
* containers
*/
public static CFABuilder makeZeroOneContainerCFABuilder(AnalysisOptions options, IClassHierarchy cha, ClassLoader cl,
public static CFABuilder makeZeroOneContainerCFABuilder(AnalysisOptions options,AnalysisCache cache, IClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, DeploymentMetaData dmd) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
@ -263,13 +262,13 @@ public class Util {
ContextSelector appSelector = null;
SSAContextInterpreter appInterpreter = null;
if (dmd != null) {
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(options);
ReceiverTypeInferenceCache typeInference = new ReceiverTypeInferenceCache(cache);
addJ2EEBypassLogic(options, scope, dmd, cha, typeInference);
appSelector = new J2EEContextSelector(typeInference);
appInterpreter = new CommandInterpreter(cha);
}
return new ZeroOneContainerCFABuilder(cha, options, appSelector, appInterpreter, options.getReflectionSpec());
return new ZeroOneContainerCFABuilder(cha, options,cache, appSelector, appInterpreter, options.getReflectionSpec());
}
public static void addJ2EEBypassLogic(AnalysisOptions options, AnalysisScope scope, DeploymentMetaData dmd, IClassHierarchy cha,