@SuppressWarnings("deprecation") public void init(Iterable<Entrypoint> entrypoints) throws CancelException { super.init(); CGNode root = getFakeRootNode(); int programCounter = 0; for(Entrypoint e : entrypoints) { root.addTarget(e.makeSite(programCounter++), null); } newNodes.push(root); closure(); isInitialized = true; }
@SuppressWarnings("deprecation") public void init(Iterable<Entrypoint> entrypoints) throws CancelException { super.init(); CGNode root = getFakeRootNode(); int programCounter = 0; for(Entrypoint e : entrypoints) { root.addTarget(e.makeSite(programCounter++), null); } newNodes.push(root); closure(); isInitialized = true; }
/** * Add constraints for a call site after we have computed a reachable target for the dispatch * * Side effect: add edge to the call graph. */ @SuppressWarnings("deprecation") void processResolvedCall(CGNode caller, CallSiteReference site, CGNode target) { if (DEBUG) { System.err.println(("processResolvedCall: " + caller + " ," + site + " , " + target)); } caller.addTarget(site, target); if (caller.equals(callGraph.getFakeRootNode())) { if (entrypointCallSites.contains(site)) { callGraph.registerEntrypoint(target); } } if (!haveAlreadyVisited(target)) { markDiscovered(target); } }
/** * Add constraints for a call site after we have computed a reachable target for the dispatch * * Side effect: add edge to the call graph. */ @SuppressWarnings("deprecation") void processResolvedCall(CGNode caller, CallSiteReference site, CGNode target) { if (DEBUG) { System.err.println(("processResolvedCall: " + caller + " ," + site + " , " + target)); } caller.addTarget(site, target); if (caller.equals(callGraph.getFakeRootNode())) { if (entrypointCallSites.contains(site)) { callGraph.registerEntrypoint(target); } } if (!haveAlreadyVisited(target)) { markDiscovered(target); } }
@SuppressWarnings("deprecation") private static boolean addCGEdgeWithContext(final JSCallGraph cg, CallSiteReference site, IMethod target, CGNode caller, Context targetContext) throws CancelException { boolean ret = false; if(target != null) { CGNode callee = cg.findOrCreateNode(target, targetContext); // add nodes first, to be on the safe side cg.addNode(caller); cg.addNode(callee); // add callee as successor of caller ret = !cg.getPossibleTargets(caller, site).contains(callee); if (ret) { cg.addEdge(caller, callee); caller.addTarget(site, callee); } } return ret; }
@SuppressWarnings("deprecation") private static boolean addCGEdgeWithContext(final JSCallGraph cg, CallSiteReference site, IMethod target, CGNode caller, Context targetContext) throws CancelException { boolean ret = false; if(target != null) { CGNode callee = cg.findOrCreateNode(target, targetContext); // add nodes first, to be on the safe side cg.addNode(caller); cg.addNode(callee); // add callee as successor of caller ret = !cg.getPossibleTargets(caller, site).contains(callee); if (ret) { cg.addEdge(caller, callee); caller.addTarget(site, callee); } } return ret; }
@SuppressWarnings("deprecation") public AbstractRootMethod getLanguageRoot(Atom language){ if (!languageRoots.containsKey(language)) { AbstractRootMethod languageRoot = roots.get(language, this); CGNode languageRootNode = null; try { languageRootNode = findOrCreateNode(languageRoot, Everywhere.EVERYWHERE); } catch (CancelException e) { e.printStackTrace(); Assertions.UNREACHABLE(); } languageRootNodes.add(languageRootNode); CallSiteReference site = CallSiteReference.make(1, languageRoot.getReference(), IInvokeInstruction.Dispatch.STATIC); CGNode fakeRootNode = getFakeRootNode(); CrossLanguageFakeRoot fakeRootMethod = (CrossLanguageFakeRoot) fakeRootNode.getMethod(); site = fakeRootMethod.addInvocationInternal(new int[0], site).getCallSite(); fakeRootNode.addTarget(site, languageRootNode); languageRoots.put(language, languageRoot); } return (AbstractRootMethod) languageRoots.get(language); }
@SuppressWarnings("deprecation") public AbstractRootMethod getLanguageRoot(Atom language){ if (!languageRoots.containsKey(language)) { AbstractRootMethod languageRoot = roots.get(language, this); CGNode languageRootNode = null; try { languageRootNode = findOrCreateNode(languageRoot, Everywhere.EVERYWHERE); } catch (CancelException e) { e.printStackTrace(); Assertions.UNREACHABLE(); } languageRootNodes.add(languageRootNode); CallSiteReference site = CallSiteReference.make(1, languageRoot.getReference(), IInvokeInstruction.Dispatch.STATIC); CGNode fakeRootNode = getFakeRootNode(); CrossLanguageFakeRoot fakeRootMethod = (CrossLanguageFakeRoot) fakeRootNode.getMethod(); site = fakeRootMethod.addInvocationInternal(new int[0], site).getCallSite(); fakeRootNode.addTarget(site, languageRootNode); languageRoots.put(language, languageRoot); } return (AbstractRootMethod) languageRoots.get(language); }
System.err.println("addTarget: " + caller + " ," + instruction + " , " + target); caller.addTarget(instruction.getCallSite(), target);
System.err.println("addTarget: " + caller + " ," + instruction + " , " + target); caller.addTarget(instruction.getCallSite(), target);
@Override @SuppressWarnings("deprecation") public CGNode findOrCreateNode(IMethod method, Context C) throws CancelException { assert C.equals(Everywhere.EVERYWHERE); assert !method.isAbstract(); CGNode n = getNode(method, C); if (n == null) { assert !isInitialized; n = makeNewNode(method, C); IMethod clinit = method.getDeclaringClass().getClassInitializer(); if (clinit != null && getNode(clinit, Everywhere.EVERYWHERE) == null) { CGNode cln = makeNewNode(clinit, Everywhere.EVERYWHERE); CGNode clinits = getFakeWorldClinitNode(); clinits.addTarget(CallSiteReference.make(clinitPC++, clinit.getReference(), IInvokeInstruction.Dispatch.STATIC), cln); } } return n; }
@Override @SuppressWarnings("deprecation") public CGNode findOrCreateNode(IMethod method, Context C) throws CancelException { assert C.equals(Everywhere.EVERYWHERE); assert !method.isAbstract(); CGNode n = getNode(method, C); if (n == null) { assert !isInitialized; n = makeNewNode(method, C); IMethod clinit = method.getDeclaringClass().getClassInitializer(); if (clinit != null && getNode(clinit, Everywhere.EVERYWHERE) == null) { CGNode cln = makeNewNode(clinit, Everywhere.EVERYWHERE); CGNode clinits = getFakeWorldClinitNode(); clinits.addTarget(CallSiteReference.make(clinitPC++, clinit.getReference(), IInvokeInstruction.Dispatch.STATIC), cln); } } return n; }
@SuppressWarnings("deprecation") public void init() throws CancelException { fakeRoot = makeFakeRootNode(); Key k = new Key(fakeRoot.getMethod(), fakeRoot.getContext()); registerNode(k, fakeRoot); fakeWorldClinit = makeFakeWorldClinitNode(); if (fakeWorldClinit != null) { k = new Key(fakeWorldClinit.getMethod(), fakeWorldClinit.getContext()); registerNode(k, fakeWorldClinit); // add a call from fakeRoot to fakeWorldClinit CallSiteReference site = CallSiteReference.make(1, fakeWorldClinit.getMethod().getReference(), IInvokeInstruction.Dispatch.STATIC); // note that the result of addInvocation is a different site, with a different program counter! site = ((AbstractRootMethod) fakeRoot.getMethod()).addInvocation(null, site).getCallSite(); fakeRoot.addTarget(site, fakeWorldClinit); } }
@SuppressWarnings("deprecation") public void init() throws CancelException { fakeRoot = makeFakeRootNode(); Key k = new Key(fakeRoot.getMethod(), fakeRoot.getContext()); registerNode(k, fakeRoot); fakeWorldClinit = makeFakeWorldClinitNode(); if (fakeWorldClinit != null) { k = new Key(fakeWorldClinit.getMethod(), fakeWorldClinit.getContext()); registerNode(k, fakeWorldClinit); // add a call from fakeRoot to fakeWorldClinit CallSiteReference site = CallSiteReference.make(1, fakeWorldClinit.getMethod().getReference(), IInvokeInstruction.Dispatch.STATIC); // note that the result of addInvocation is a different site, with a different program counter! site = ((AbstractRootMethod) fakeRoot.getMethod()).addInvocation(null, site).getCallSite(); fakeRoot.addTarget(site, fakeWorldClinit); } }
CGNode nd = cg.findOrCreateNode(ep.getMethod(), Everywhere.EVERYWHERE); SSAAbstractInvokeInstruction invk = ep.addCall(fakeRootMethod); fakeRootNode.addTarget(invk.getCallSite(), nd);
CGNode nd = cg.findOrCreateNode(ep.getMethod(), Everywhere.EVERYWHERE); SSAAbstractInvokeInstruction invk = ep.addCall(fakeRootMethod); fakeRootNode.addTarget(invk.getCallSite(), nd);