fix memory leak

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4504 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2012-02-17 20:25:06 +00:00
parent cafc761a7c
commit 5106842f30
2 changed files with 9 additions and 4 deletions

View File

@ -226,10 +226,11 @@ public class ForInContextSelector implements ContextSelector {
}
private final HashMap<MethodReference, Boolean> forInOnFirstArg_cache = HashMapFactory.make();
public static final HashMap<MethodReference, DefUse> du_cache = HashMapFactory.make();
public static final IRFactory<IMethod> factory = AstIRFactory.makeDefaultFactory();
private final HashMap<MethodReference, DefUse> du_cache = HashMapFactory.make();
private final IRFactory<IMethod> factory = AstIRFactory.makeDefaultFactory();
// determine whether the method performs a for-in loop over the properties of its index'th argument
@SuppressWarnings("unused")
private boolean forInOnFirstArg(IMethod method) {
MethodReference mref = method.getReference();
if(method.getNumberOfParameters() < index)
@ -248,7 +249,7 @@ public class ForInContextSelector implements ContextSelector {
return false;
}
public static DefUse getDefUse(IMethod method) {
private DefUse getDefUse(IMethod method) {
MethodReference mref = method.getReference();
DefUse du = du_cache.get(mref);
if(du == null) {

View File

@ -3,6 +3,7 @@ package com.ibm.wala.cast.js.ipa.callgraph;
import java.util.HashMap;
import com.ibm.wala.cast.ipa.callgraph.ArgumentInstanceContext;
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.CGNode;
@ -10,6 +11,7 @@ import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ssa.IRFactory;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAOptions;
import com.ibm.wala.ssa.SSAReturnInstruction;
@ -27,6 +29,8 @@ public class ObjectSensitivityContextSelector implements ContextSelector {
private final HashMap<MethodReference, Boolean> returnsThis_cache = HashMapFactory.make();
private final IRFactory<IMethod> factory = AstIRFactory.makeDefaultFactory();
// determine whether the method returns "this"
private boolean returnsThis(IMethod method) {
MethodReference mref = method.getReference();
@ -35,7 +39,7 @@ public class ObjectSensitivityContextSelector implements ContextSelector {
Boolean b = returnsThis_cache.get(mref);
if(b != null)
return b;
for(SSAInstruction inst : ForInContextSelector.factory.makeIR(method, Everywhere.EVERYWHERE, SSAOptions.defaultOptions()).getInstructions()) {
for(SSAInstruction inst : factory.makeIR(method, Everywhere.EVERYWHERE, SSAOptions.defaultOptions()).getInstructions()) {
if(inst instanceof SSAReturnInstruction) {
SSAReturnInstruction ret = (SSAReturnInstruction)inst;
if(ret.getResult() == 2) {