@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } assert understands(node); // Should already have been checked before { final IR ir = getIR(node); // Speeeed return ir.iterateCallSites(); } }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } assert understands(node); // Should already have been checked before { final IR ir = getIR(node); // Speeeed return ir.iterateCallSites(); } }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode N) { IR ir = getIR(N); if (ir == null) { return EmptyIterator.instance(); } else { return ir.iterateCallSites(); } }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { assert understands(node); return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode node) { assert understands(node); return getIR(node).iterateCallSites(); }
@Override public Iterator<CallSiteReference> iterateCallSites(CGNode N) { IR ir = getIR(N); if (ir == null) { return EmptyIterator.instance(); } else { return ir.iterateCallSites(); } }
public Iterator<PointerKeyAndCallSite> getParamSuccs(LocalPointerKey pk) { // TODO cache this result // TODO take some cgnode as parameter if we have calling context? CGNode cgNode = params.get(pk); if (cgNode == null) { return EmptyIterator.instance(); } int paramPos = pk.getValueNumber() - 1; ArrayList<PointerKeyAndCallSite> paramSuccs = new ArrayList<>(); // iterate over callers for (CGNode caller : cg) { // TODO optimization: we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(cgNode)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos)); assert containsNode(actualPk); assert containsNode(pk); paramSuccs.add(new PointerKeyAndCallSite(actualPk, call)); } } } } return paramSuccs.iterator(); }
public Iterator<PointerKeyAndCallSite> getParamSuccs(LocalPointerKey pk) { // TODO cache this result // TODO take some cgnode as parameter if we have calling context? CGNode cgNode = params.get(pk); if (cgNode == null) { return EmptyIterator.instance(); } int paramPos = pk.getValueNumber() - 1; ArrayList<PointerKeyAndCallSite> paramSuccs = new ArrayList<>(); // iterate over callers for (CGNode caller : cg) { // TODO optimization: we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(cgNode)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos)); assert containsNode(actualPk); assert containsNode(pk); paramSuccs.add(new PointerKeyAndCallSite(actualPk, call)); } } } } return paramSuccs.iterator(); }
public Iterator<PointerKeyAndCallSite> getReturnPreds(LocalPointerKey pk) { CGNode cgNode = returns.get(pk); if (cgNode == null) { return EmptyIterator.instance(); } boolean isExceptional = pk == heapModel.getPointerKeyForExceptionalReturnValue(cgNode); ArrayList<PointerKeyAndCallSite> returnPreds = new ArrayList<>(); // iterate over callers for (CGNode caller : cg) { // TODO we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(cgNode)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey returnPk = heapModel.getPointerKeyForLocal(caller, isExceptional ? callInstr.getException() : callInstr .getDef()); assert containsNode(returnPk); assert containsNode(pk); returnPreds.add(new PointerKeyAndCallSite(returnPk, call)); } } } } return returnPreds.iterator(); }
public Iterator<PointerKeyAndCallSite> getReturnPreds(LocalPointerKey pk) { CGNode cgNode = returns.get(pk); if (cgNode == null) { return EmptyIterator.instance(); } boolean isExceptional = pk == heapModel.getPointerKeyForExceptionalReturnValue(cgNode); ArrayList<PointerKeyAndCallSite> returnPreds = new ArrayList<>(); // iterate over callers for (CGNode caller : cg) { // TODO we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(cgNode)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey returnPk = heapModel.getPointerKeyForLocal(caller, isExceptional ? callInstr.getException() : callInstr .getDef()); assert containsNode(returnPk); assert containsNode(pk); returnPreds.add(new PointerKeyAndCallSite(returnPk, call)); } } } } return returnPreds.iterator(); }
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; }
/** * For each invocation in the method, add nodes for actual parameters and return values */ protected void addNodesForInvocations(CGNode node, IR ir) { for (CallSiteReference site : Iterator2Iterable.make(ir.iterateCallSites())) { SSAAbstractInvokeInstruction[] calls = ir.getCalls(site); for (SSAAbstractInvokeInstruction invokeInstr : calls) { for (int i = 0; i < invokeInstr.getNumberOfUses(); i++) { // just make nodes for parameters; we'll get to them when // traversing // from the callee PointerKey use = heapModel.getPointerKeyForLocal(node, invokeInstr.getUse(i)); addNode(use); Set<SSAAbstractInvokeInstruction> s = MapUtil.findOrCreateSet(callParams, use); s.add(invokeInstr); } // for any def'd values, keep track of the fact that they are def'd // by a call if (invokeInstr.hasDef()) { PointerKey def = heapModel.getPointerKeyForLocal(node, invokeInstr.getDef()); addNode(def); callDefs.put(def, invokeInstr); } PointerKey exc = heapModel.getPointerKeyForLocal(node, invokeInstr.getException()); addNode(exc); callDefs.put(exc, invokeInstr); } } }
/** * For each invocation in the method, add nodes for actual parameters and return values */ protected void addNodesForInvocations(CGNode node, IR ir) { for (CallSiteReference site : Iterator2Iterable.make(ir.iterateCallSites())) { SSAAbstractInvokeInstruction[] calls = ir.getCalls(site); for (SSAAbstractInvokeInstruction invokeInstr : calls) { for (int i = 0; i < invokeInstr.getNumberOfUses(); i++) { // just make nodes for parameters; we'll get to them when // traversing // from the callee PointerKey use = heapModel.getPointerKeyForLocal(node, invokeInstr.getUse(i)); addNode(use); Set<SSAAbstractInvokeInstruction> s = MapUtil.findOrCreateSet(callParams, use); s.add(invokeInstr); } // for any def'd values, keep track of the fact that they are def'd // by a call if (invokeInstr.hasDef()) { PointerKey def = heapModel.getPointerKeyForLocal(node, invokeInstr.getDef()); addNode(def); callDefs.put(def, invokeInstr); } PointerKey exc = heapModel.getPointerKeyForLocal(node, invokeInstr.getException()); addNode(exc); callDefs.put(exc, invokeInstr); } } }
private void addParamEdges(LocalPointerKey pk, CGNode node) { // get parameter position: value number - 1? int paramPos = pk.getValueNumber() - 1; // iterate over callers for (CGNode caller : cg) { // TODO we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(node)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos)); assert containsNode(actualPk); assert containsNode(pk); addEdge(pk, actualPk); } } } } }
private void addParamEdges(LocalPointerKey pk, CGNode node) { // get parameter position: value number - 1? int paramPos = pk.getValueNumber() - 1; // iterate over callers for (CGNode caller : cg) { // TODO we don't need to add the graph if null is passed // as the argument addSubgraphForNode(caller); IR ir = caller.getIR(); for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) { if (cg.getPossibleTargets(caller, call).contains(node)) { SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call); for (SSAAbstractInvokeInstruction callInstr : callInstrs) { PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos)); assert containsNode(actualPk); assert containsNode(pk); addEdge(pk, actualPk); } } } } }