2012-09-04 22:56:05 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2007 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.ibm.wala.ipa.callgraph;
|
|
|
|
|
|
|
|
import com.ibm.wala.classLoader.IMethod;
|
|
|
|
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
|
|
|
import com.ibm.wala.ssa.DefUse;
|
|
|
|
import com.ibm.wala.ssa.IR;
|
|
|
|
import com.ibm.wala.ssa.IRFactory;
|
|
|
|
import com.ibm.wala.ssa.SSACache;
|
|
|
|
import com.ibm.wala.ssa.SSAOptions;
|
|
|
|
import com.ibm.wala.util.ref.ReferenceCleanser;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A place to hold onto caches of various analysis artifacts.
|
|
|
|
*
|
|
|
|
* Someday this should maybe go away?
|
|
|
|
*/
|
2017-06-24 16:51:27 +00:00
|
|
|
public class AnalysisCache implements IAnalysisCacheView {
|
2012-09-04 22:56:05 +00:00
|
|
|
private final IRFactory<IMethod> irFactory;
|
|
|
|
|
|
|
|
private final SSACache ssaCache;
|
|
|
|
|
2017-01-17 18:14:56 +00:00
|
|
|
private final SSAOptions ssaOptions;
|
|
|
|
|
2017-02-03 01:33:27 +00:00
|
|
|
public AnalysisCache(IRFactory<IMethod> irFactory, SSAOptions ssaOptions, SSACache cache) {
|
2012-09-04 22:56:05 +00:00
|
|
|
super();
|
2017-01-17 18:14:56 +00:00
|
|
|
this.ssaOptions = ssaOptions;
|
2012-09-04 22:56:05 +00:00
|
|
|
this.irFactory = irFactory;
|
2017-02-03 01:33:27 +00:00
|
|
|
this.ssaCache = cache;
|
2012-09-04 22:56:05 +00:00
|
|
|
ReferenceCleanser.registerCache(this);
|
|
|
|
}
|
|
|
|
|
2017-02-03 01:33:27 +00:00
|
|
|
/*
|
|
|
|
* @see com.ibm.wala.ipa.callgraph.IAnalysisCacheView#invalidate(com.ibm.wala.classLoader.IMethod, com.ibm.wala.ipa.callgraph.Context)
|
|
|
|
*/
|
|
|
|
@Override
|
2012-09-04 22:56:05 +00:00
|
|
|
public void invalidate(IMethod method, Context C) {
|
|
|
|
ssaCache.invalidate(method, C);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SSACache getSSACache() {
|
|
|
|
return ssaCache;
|
|
|
|
}
|
|
|
|
|
2017-01-17 18:14:56 +00:00
|
|
|
public SSAOptions getSSAOptions() {
|
|
|
|
return ssaOptions;
|
|
|
|
}
|
|
|
|
|
2017-02-03 01:33:27 +00:00
|
|
|
/*
|
|
|
|
* @see com.ibm.wala.ipa.callgraph.IAnalysisCacheView#getIRFactory()
|
|
|
|
*/
|
|
|
|
@Override
|
2012-09-04 22:56:05 +00:00
|
|
|
public IRFactory<IMethod> getIRFactory() {
|
|
|
|
return irFactory;
|
|
|
|
}
|
|
|
|
|
2017-02-03 01:33:27 +00:00
|
|
|
/*
|
|
|
|
* @see com.ibm.wala.ipa.callgraph.IAnalysisCacheView#getIR(com.ibm.wala.classLoader.IMethod)
|
2012-09-04 22:56:05 +00:00
|
|
|
*/
|
2017-02-03 01:33:27 +00:00
|
|
|
@Override
|
|
|
|
public IR getIR(IMethod method, Context context) {
|
2012-09-04 22:56:05 +00:00
|
|
|
if (method == null) {
|
|
|
|
throw new IllegalArgumentException("method is null");
|
|
|
|
}
|
2017-02-03 01:33:27 +00:00
|
|
|
return ssaCache.findOrCreateIR(method, context, ssaOptions);
|
2012-09-04 22:56:05 +00:00
|
|
|
}
|
|
|
|
|
2017-02-03 01:33:27 +00:00
|
|
|
@Override
|
|
|
|
public IR getIR(IMethod m) {
|
|
|
|
return getIR(m, Everywhere.EVERYWHERE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @see com.ibm.wala.ipa.callgraph.IAnalysisCacheView#getDefUse(com.ibm.wala.ssa.IR)
|
2012-09-04 22:56:05 +00:00
|
|
|
*/
|
2017-02-03 01:33:27 +00:00
|
|
|
@Override
|
2012-09-04 22:56:05 +00:00
|
|
|
public DefUse getDefUse(IR ir) {
|
|
|
|
if (ir == null) {
|
|
|
|
throw new IllegalArgumentException("ir is null");
|
|
|
|
}
|
|
|
|
return ssaCache.findOrCreateDU(ir, Everywhere.EVERYWHERE);
|
|
|
|
}
|
2017-03-16 02:06:19 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clear() {
|
|
|
|
ssaCache.wipe();
|
|
|
|
}
|
2012-09-04 22:56:05 +00:00
|
|
|
}
|