public JavaScriptConstructorContextSelector(ContextSelector base) { this.base = base; this.oneLevelCallStrings = new nCFAContextSelector(1, base); this.oneLevelCallerSite = new OneLevelSiteContextSelector(base); }
@Override public Context getCalleeTarget(final CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (callee instanceof JavaScriptConstructor) { final Context oneLevelCallStringContext = oneLevelCallStrings.getCalleeTarget(caller, site, callee, receiver); if (AstLexicalInformation.hasExposedUses(caller, site)) { // use a caller-site context, to enable lexical scoping lookups (via caller CGNode) return oneLevelCallerSite.getCalleeTarget(caller, site, callee, receiver); } else { // use at least one-level of call-string sensitivity for constructors // always return oneLevelCallStringContext; } } else { return base.getCalleeTarget(caller, site, callee, receiver); } }
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; }
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; }
public JavaScriptConstructorContextSelector(ContextSelector base) { this.base = base; this.oneLevelCallStrings = new nCFAContextSelector(1, base); this.oneLevelCallerSite = new OneLevelSiteContextSelector(base); }
@Override public Context getCalleeTarget(final CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (callee instanceof JavaScriptConstructor) { final Context oneLevelCallStringContext = oneLevelCallStrings.getCalleeTarget(caller, site, callee, receiver); if (AstLexicalInformation.hasExposedUses(caller, site)) { // use a caller-site context, to enable lexical scoping lookups (via caller CGNode) return oneLevelCallerSite.getCalleeTarget(caller, site, callee, receiver); } else { // use at least one-level of call-string sensitivity for constructors // always return oneLevelCallStringContext; } } else { return base.getCalleeTarget(caller, site, callee, receiver); } }
private void setupContextSelector(JSAnalysisOptions options, ContextSelector appContextSelector, boolean doOneCFA) { // baseline selector ContextSelector def = new ContextInsensitiveSelector(); ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def); // JavaScriptConstructorContextSelector ensures at least a 0-1-CFA (i.e., // Andersen's-style) heap abstraction. This level of heap abstraction is // _necessary_ for correctness (we rely on it when handling lexical scoping) contextSelector = new JavaScriptConstructorContextSelector(contextSelector); //contextSelector = new OneLevelForLexicalAccessFunctions(contextSelector); if (USE_OBJECT_SENSITIVITY) { contextSelector = new ObjectSensitivityContextSelector(contextSelector); } if (options.handleCallApply()) { contextSelector = new JavaScriptFunctionApplyContextSelector(contextSelector); } if (doOneCFA) { contextSelector = new nCFAContextSelector(1, contextSelector); } setContextSelector(contextSelector); }
private void setupContextSelector(JSAnalysisOptions options, ContextSelector appContextSelector, boolean doOneCFA) { // baseline selector ContextSelector def = new ContextInsensitiveSelector(); ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def); // JavaScriptConstructorContextSelector ensures at least a 0-1-CFA (i.e., // Andersen's-style) heap abstraction. This level of heap abstraction is // _necessary_ for correctness (we rely on it when handling lexical scoping) contextSelector = new JavaScriptConstructorContextSelector(contextSelector); //contextSelector = new OneLevelForLexicalAccessFunctions(contextSelector); if (USE_OBJECT_SENSITIVITY) { contextSelector = new ObjectSensitivityContextSelector(contextSelector); } if (options.handleCallApply()) { contextSelector = new JavaScriptFunctionApplyContextSelector(contextSelector); } if (doOneCFA) { contextSelector = new nCFAContextSelector(1, contextSelector); } setContextSelector(contextSelector); }
public nCFABuilder(int n, IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) { super(abstractRootMethod, options, cache, new DefaultPointerKeyFactory()); if (options == null) { throw new IllegalArgumentException("options is null"); } setInstanceKeys(new ClassBasedInstanceKeys(options, cha)); ContextSelector def = new DefaultContextSelector(options, cha); ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def); contextSelector = new nCFAContextSelector(n, contextSelector); setContextSelector(contextSelector); SSAContextInterpreter defI = new DefaultSSAInterpreter(options, cache); defI = new DelegatingSSAContextInterpreter(ReflectionContextInterpreter.createReflectionContextInterpreter(cha, options, getAnalysisCache()), defI); SSAContextInterpreter contextInterpreter = appContextInterpreter == null ? defI : new DelegatingSSAContextInterpreter(appContextInterpreter, defI); setContextInterpreter(contextInterpreter); }
public nCFABuilder(int n, IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) { super(abstractRootMethod, options, cache, new DefaultPointerKeyFactory()); if (options == null) { throw new IllegalArgumentException("options is null"); } setInstanceKeys(new ClassBasedInstanceKeys(options, cha)); ContextSelector def = new DefaultContextSelector(options, cha); ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def); contextSelector = new nCFAContextSelector(n, contextSelector); setContextSelector(contextSelector); SSAContextInterpreter defI = new DefaultSSAInterpreter(options, cache); defI = new DelegatingSSAContextInterpreter(ReflectionContextInterpreter.createReflectionContextInterpreter(cha, options, getAnalysisCache()), defI); SSAContextInterpreter contextInterpreter = appContextInterpreter == null ? defI : new DelegatingSSAContextInterpreter(appContextInterpreter, defI); setContextInterpreter(contextInterpreter); }