IMethod resolved = this.parent.getCalleeTarget(caller, site, receiver); if (resolved != null) { return resolved; IMethod resolved = this.child.getCalleeTarget(caller, site, receiver); if (resolved != null) { return resolved;
IMethod resolved = this.parent.getCalleeTarget(caller, site, receiver); if (resolved != null) { return resolved; IMethod resolved = this.child.getCalleeTarget(caller, site, receiver); if (resolved != null) { return resolved;
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { MethodReference target = site.getDeclaredTarget(); if (isInvokeExact(target)) { if (! impls.containsKey(target)) { SyntheticMethod invokeExactTrampoline = new SyntheticMethod(target, receiver.getClassHierarchy().lookupClass(TypeReference.JavaLangInvokeMethodHandle), false, false); impls.put(target, invokeExactTrampoline); } return impls.get(target); } return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { MethodReference target = site.getDeclaredTarget(); if (isInvokeExact(target)) { if (! impls.containsKey(target)) { SyntheticMethod invokeExactTrampoline = new SyntheticMethod(target, receiver.getClassHierarchy().lookupClass(TypeReference.JavaLangInvokeMethodHandle), false, false); impls.put(target, invokeExactTrampoline); } return impls.get(target); } return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { assert getSelector(site) != null: "no selector for " + getLanguage(site) + " method " + site; return getSelector(site).getCalleeTarget(caller, site, receiver); }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { assert getSelector(site) != null: "no selector for " + getLanguage(site) + " method " + site; return getSelector(site).getCalleeTarget(caller, site, receiver); }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { if (site.getDeclaredTarget().equals(JavaScriptMethods.ctorReference)) { IR callerIR = caller.getIR(); SSAAbstractInvokeInstruction callStmts[] = callerIR.getCalls(site); assert callStmts.length == 1; int nargs = callStmts[0].getNumberOfPositionalParameters(); return constructors.findOrCreateConstructorMethod(callerIR, callStmts[0], receiver, nargs - 1); } else { return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { if (site.getDeclaredTarget().equals(JavaScriptMethods.ctorReference)) { IR callerIR = caller.getIR(); SSAAbstractInvokeInstruction callStmts[] = callerIR.getCalls(site); assert callStmts.length == 1; int nargs = callStmts[0].getNumberOfPositionalParameters(); return constructors.findOrCreateConstructorMethod(callerIR, callStmts[0], receiver, nargs - 1); } else { return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { IMethod method = receiver.getMethod(AstMethodReference.fnSelector); if (method != null) { TypeName tn = method.getReference().getDeclaringClass().getName(); if (tn.equals(APPLY_TYPE_NAME)) { if (applyMethod == null) { applyMethod = createApplyDummyMethod(receiver); } return applyMethod; } } return base.getCalleeTarget(caller, site, receiver); }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { IMethod method = receiver.getMethod(AstMethodReference.fnSelector); if (method != null) { TypeName tn = method.getReference().getDeclaringClass().getName(); if (tn.equals(APPLY_TYPE_NAME)) { if (applyMethod == null) { applyMethod = createApplyDummyMethod(receiver); } return applyMethod; } } return base.getCalleeTarget(caller, site, receiver); }
JavaScriptLoader jsLoader = (JavaScriptLoader) builder.getClassHierarchy().getLoader(JavaScriptTypes.jsLoader); IMethod calledMethod = base.getCalleeTarget(caller, site, receiver);
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { IMethod target = base.getCalleeTarget(caller, site, receiver); if (target != null && target.getReference().equals(loadFileFunRef)) {
/** * @param caller the caller node * @param iKey an abstraction of the receiver of the call (or null if not applicable) * @return the CGNode to which this particular call should dispatch. */ protected CGNode getTargetForCall(CGNode caller, CallSiteReference site, IClass recv, InstanceKey iKey[]) { IMethod targetMethod = options.getMethodTargetSelector().getCalleeTarget(caller, site, recv); // this most likely indicates an exclusion at work; the target selector // should have issued a warning if (targetMethod == null || targetMethod.isAbstract()) { return null; } Context targetContext = contextSelector.getCalleeTarget(caller, site, targetMethod, iKey); if (targetContext.isA(IllegalArgumentExceptionContext.class)) { return null; } try { return getCallGraph().findOrCreateNode(targetMethod, targetContext); } catch (CancelException e) { return null; } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { IMethod target = base.getCalleeTarget(caller, site, receiver); if (target != null && target.getReference().equals(loadFileFunRef)) {
public boolean handleFunctionCallOrApplyInvocation(FlowGraph flowgraph, IProgressMonitor monitor, final JSCallGraph cg, CallVertex callVertex, CGNode caller, CallSiteReference site, IMethod target) throws CancelException { // use to get 1-level of call string for Function.prototype.call, to // preserve the precision of the field-based call graph final nCFAContextSelector functionPrototypeCallSelector = new nCFAContextSelector(1, new ContextInsensitiveSelector()); Context calleeContext = functionPrototypeCallSelector.getCalleeTarget(caller, site, target, null); boolean ret = addCGEdgeWithContext(cg, site, target, caller, calleeContext); CGNode functionPrototypeCallNode = cg.findOrCreateNode(target, calleeContext); // need to create nodes for reflective targets of call, and then add them // as callees of the synthetic method OrdinalSet<FuncVertex> reflectiveTargets = getReflectiveTargets(flowgraph, callVertex, monitor); System.err.println("adding callees " + reflectiveTargets + " for " + caller); // there should only be one call site in the synthetic method // CallSiteReference reflectiveCallSite = cache.getIRFactory().makeIR(functionPrototypeCallNode.getMethod(), Everywhere.EVERYWHERE, options.getSSAOptions()).iterateCallSites().next(); CallSiteReference reflectiveCallSite = functionPrototypeCallNode.getIR().iterateCallSites().next(); for (FuncVertex f : reflectiveTargets) { IMethod reflectiveTgtMethod = targetSelector.getCalleeTarget(functionPrototypeCallNode, reflectiveCallSite, f.getConcreteType()); ret |= addEdgeToJSCallGraph(cg, reflectiveCallSite, reflectiveTgtMethod, functionPrototypeCallNode); } return ret; }
/** * @param caller the caller node * @param iKey an abstraction of the receiver of the call (or null if not applicable) * @return the CGNode to which this particular call should dispatch. */ protected CGNode getTargetForCall(CGNode caller, CallSiteReference site, IClass recv, InstanceKey iKey[]) { IMethod targetMethod = options.getMethodTargetSelector().getCalleeTarget(caller, site, recv); // this most likely indicates an exclusion at work; the target selector // should have issued a warning if (targetMethod == null || targetMethod.isAbstract()) { return null; } Context targetContext = contextSelector.getCalleeTarget(caller, site, targetMethod, iKey); if (targetContext.isA(IllegalArgumentExceptionContext.class)) { return null; } try { return getCallGraph().findOrCreateNode(targetMethod, targetContext); } catch (CancelException e) { return null; } }
public boolean handleFunctionCallOrApplyInvocation(FlowGraph flowgraph, IProgressMonitor monitor, final JSCallGraph cg, CallVertex callVertex, CGNode caller, CallSiteReference site, IMethod target) throws CancelException { // use to get 1-level of call string for Function.prototype.call, to // preserve the precision of the field-based call graph final nCFAContextSelector functionPrototypeCallSelector = new nCFAContextSelector(1, new ContextInsensitiveSelector()); Context calleeContext = functionPrototypeCallSelector.getCalleeTarget(caller, site, target, null); boolean ret = addCGEdgeWithContext(cg, site, target, caller, calleeContext); CGNode functionPrototypeCallNode = cg.findOrCreateNode(target, calleeContext); // need to create nodes for reflective targets of call, and then add them // as callees of the synthetic method OrdinalSet<FuncVertex> reflectiveTargets = getReflectiveTargets(flowgraph, callVertex, monitor); System.err.println("adding callees " + reflectiveTargets + " for " + caller); // there should only be one call site in the synthetic method // CallSiteReference reflectiveCallSite = cache.getIRFactory().makeIR(functionPrototypeCallNode.getMethod(), Everywhere.EVERYWHERE, options.getSSAOptions()).iterateCallSites().next(); CallSiteReference reflectiveCallSite = functionPrototypeCallNode.getIR().iterateCallSites().next(); for (FuncVertex f : reflectiveTargets) { IMethod reflectiveTgtMethod = targetSelector.getCalleeTarget(functionPrototypeCallNode, reflectiveCallSite, f.getConcreteType()); ret |= addEdgeToJSCallGraph(cg, reflectiveCallSite, reflectiveTgtMethod, functionPrototypeCallNode); } return ret; }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { ClassLoaderReference loader = (site.isStatic() || receiver==null)? site.getDeclaredTarget().getDeclaringClass().getClassLoader(): receiver.getClassLoader().getReference(); TypeReference functionTypeRef = TypeReference.findOrCreate(loader, AstTypeReference.functionTypeName); IClass declarer = site.isStatic()? cha.lookupClass(site.getDeclaredTarget().getDeclaringClass()): receiver; if (declarer == null) { System.err.println(("cannot find declarer for " + site + ", " + receiver + " in " + caller)); } IClass fun = cha.lookupClass(functionTypeRef); if (fun == null) { System.err.println(("cannot find function " + functionTypeRef + " for " + site + ", " + receiver + " in " + caller)); } if (fun != null && declarer != null && cha.isSubclassOf(declarer, fun)) { return declarer.getMethod(AstMethodReference.fnSelector); } else { return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { ClassLoaderReference loader = (site.isStatic() || receiver==null)? site.getDeclaredTarget().getDeclaringClass().getClassLoader(): receiver.getClassLoader().getReference(); TypeReference functionTypeRef = TypeReference.findOrCreate(loader, AstTypeReference.functionTypeName); IClass declarer = site.isStatic()? cha.lookupClass(site.getDeclaredTarget().getDeclaringClass()): receiver; if (declarer == null) { System.err.println(("cannot find declarer for " + site + ", " + receiver + " in " + caller)); } IClass fun = cha.lookupClass(functionTypeRef); if (fun == null) { System.err.println(("cannot find function " + functionTypeRef + " for " + site + ", " + receiver + " in " + caller)); } if (fun != null && declarer != null && cha.isSubclassOf(declarer, fun)) { return declarer.getMethod(AstMethodReference.fnSelector); } else { return base.getCalleeTarget(caller, site, receiver); } }
@Override public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass receiver) { IMethod method = receiver.getMethod(AstMethodReference.fnSelector); if (method != null) { 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 * specified" */ if(!site.getDeclaredTarget().equals(JavaScriptMethods.ctorReference)) { IMethod target = getFunctionCallTarget(caller, site, receiver); if(target != null) return target; } // if we get here, we either saw an invocation of "call" as a constructor, or an invocation // without receiver object; in either case, this is likely due to bad call graph info if(WARN_ABOUT_IMPRECISE_CALLGRAPH) warnAboutImpreciseCallGraph(caller, site); } } return base.getCalleeTarget(caller, site, receiver); }