small optimization: avoid calling TypeName.toString() in some cases

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4478 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2012-02-17 20:18:07 +00:00
parent 19bd95238a
commit 197ec11f35
4 changed files with 15 additions and 8 deletions

View File

@ -353,6 +353,7 @@ public class ForInContextSelector implements ContextSelector {
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
if (USE_CPA_IN_BODIES && FORIN_MARKER.equals(caller.getContext().get(FORIN_KEY))) {
// what about base.getRelevantParameters() here?
return identifyDependentParameters(caller, site);
} else if (caller.getIR().getCalls(site)[0].getNumberOfUses() > index) {
return IntSetUtil.make(new int[]{index}).union(base.getRelevantParameters(caller, site));

View File

@ -12,6 +12,7 @@ import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.cfa.nCFAContextSelector;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.util.intset.IntSet;
import com.ibm.wala.util.intset.IntSetUtil;
@ -25,6 +26,8 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
/* whether to use a one-level callstring context in addition to the apply context */
private static final boolean USE_ONE_LEVEL = true;
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionApply");
public static final ContextKey APPLY_NON_NULL_ARGS = new ContextKey() {
};
@ -134,8 +137,6 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
public String toString() {
return "ApplyContext [delegate=" + delegate + ", isNonNullArray=" + isNonNullArray + "]";
}
}
@ -144,8 +145,8 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
IMethod method = declaringClass.getMethod(AstMethodReference.fnSelector);
Context baseCtxt = base.getCalleeTarget(caller, site, callee, receiver);
if (method != null) {
String s = method.getReference().getDeclaringClass().getName().toString();
if (s.equals("Lprologue.js/functionApply")) {
TypeName tn = method.getReference().getDeclaringClass().getName();
if (tn.equals(APPLY_TYPE_NAME)) {
boolean isNonNullArray = false;
if (receiver.length >= 4) {
InstanceKey argsList = receiver[3];

View File

@ -11,6 +11,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.MethodTargetSelector;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.util.strings.Atom;
/**
@ -24,6 +25,8 @@ public class JavaScriptFunctionApplyTargetSelector implements MethodTargetSelect
private final MethodTargetSelector base;
private static final TypeName APPLY_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionApply");
private IMethod applyMethod;
public JavaScriptFunctionApplyTargetSelector(MethodTargetSelector base) {
this.base = base;
@ -49,8 +52,8 @@ public class JavaScriptFunctionApplyTargetSelector implements MethodTargetSelect
public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) {
IMethod method = receiver.getMethod(AstMethodReference.fnSelector);
if (method != null) {
String s = method.getReference().getDeclaringClass().getName().toString();
if (s.equals("Lprologue.js/functionApply")) {
TypeName tn = method.getReference().getDeclaringClass().getName();
if (tn.equals(APPLY_TYPE_NAME)) {
if (applyMethod == null) {
applyMethod = createApplyDummyMethod(receiver);
}

View File

@ -20,6 +20,7 @@ import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.intset.IntIterator;
import com.ibm.wala.util.strings.Atom;
@ -47,6 +48,7 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele
public static final boolean DEBUG_SYNTHETIC_CALL_METHODS = false;
private static final TypeName CALL_TYPE_NAME = TypeName.findOrCreate("Lprologue.js/functionCall");
private final MethodTargetSelector base;
public JavaScriptFunctionDotCallTargetSelector(MethodTargetSelector base) {
@ -65,8 +67,8 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele
public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) {
IMethod method = receiver.getMethod(AstMethodReference.fnSelector);
if (method != null) {
String s = method.getReference().getDeclaringClass().getName().toString();
if (s.equals("Lprologue.js/functionCall")) {
TypeName tn = method.getReference().getDeclaringClass().getName();
if (tn.equals(CALL_TYPE_NAME)) {
/* invoking Function.prototype.call as a constructor results in a TypeError
* see ECMA-262 5.1, 15: "None of the built-in functions described in this clause that
* are not constructors shall implement the [[Construct]] internal method unless otherwise