@Override public IR getIR() { return cache.getIR(method); }
@Override public IR getIR() { return cache.getIR(method); }
@Override public DefUse getDU() { return cache.getDefUse(cache.getIR(method)); }
@Override public DefUse getDU() { return cache.getDefUse(cache.getIR(method)); }
@Override public IR getIR(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } // Note: since this is context-insensitive, we cache an IR based on the // EVERYWHERE context return getAnalysisCache().getIR(node.getMethod(), Everywhere.EVERYWHERE); }
@Override public IR getIR(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (DEBUG) { System.err.println("generating IR for " + node); } SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node); return cache.getIR(m, node.getContext()); }
@Override public IR getIR(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (DEBUG) { System.err.println("generating IR for " + node); } SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node); return cache.getIR(m, node.getContext()); }
@Override public IR getIR(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } // Note: since this is context-insensitive, we cache an IR based on the // EVERYWHERE context return getAnalysisCache().getIR(node.getMethod(), Everywhere.EVERYWHERE); }
@Override public IR getIR(CGNode node) { // new Exception("getting IR for method "+node.getMethod().getReference().toString()).printStackTrace(); return cache.getIR(node.getMethod(), node.getContext()); }
@Override public IR getIR(CGNode node) { // new Exception("getting IR for method "+node.getMethod().getReference().toString()).printStackTrace(); return cache.getIR(node.getMethod(), node.getContext()); }
@Override public DefUse getDU(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } // Note: since this is context-insensitive, we cache an IR based on the // EVERYWHERE context return getAnalysisCache().getDefUse(getAnalysisCache().getIR(node.getMethod(), Everywhere.EVERYWHERE)); } }
@Override public DefUse getDU(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } // Note: since this is context-insensitive, we cache an IR based on the // EVERYWHERE context return getAnalysisCache().getDefUse(getAnalysisCache().getIR(node.getMethod(), Everywhere.EVERYWHERE)); } }
@Override public IR getIR(CGNode node) { if (node.getMethod() instanceof Retranslatable) { return getAnalysisCache().getIR(node.getMethod(), node.getContext()); } else { return super.getIR(node); } }
@Override public IR getIR(CGNode node) { if (node.getMethod() instanceof Retranslatable) { return getAnalysisCache().getIR(node.getMethod(), node.getContext()); } else { return super.getIR(node); } }
private void resolveLocalCalls(FlowGraph flowgraph) { for(IClass klass : cha) { for(IMethod method : klass.getDeclaredMethods()) { if (filterFunction(method)) { IR ir = cache.getIR(method); ir.visitAllInstructions(new LocalCallSSAVisitor(method, ir.getSymbolTable(), cache.getDefUse(ir), flowgraph)); } } } }
private void resolveLocalCalls(FlowGraph flowgraph) { for(IClass klass : cha) { for(IMethod method : klass.getDeclaredMethods()) { if (filterFunction(method)) { IR ir = cache.getIR(method); ir.visitAllInstructions(new LocalCallSSAVisitor(method, ir.getSymbolTable(), cache.getDefUse(ir), flowgraph)); } } } }
@Test public void testIRCacheIdempotence() { MethodReference mr = StringStuff.makeMethodReference("hello.Hello.main([Ljava/lang/String;)V"); IMethod m = cha.resolveMethod(mr); IAnalysisCacheView cache = makeAnalysisCache(); IR irBefore = cache.getIR(m); cache.clear(); IR irAfter = cache.getIR(m); for (int i = 0; i < irBefore.getInstructions().length; i++) { System.out.println(irBefore.getInstructions()[i]); System.out.println(irAfter.getInstructions()[i]); Assert.assertEquals(irAfter.getInstructions()[i], irBefore.getInstructions()[i]); } }
@Test public void testSync1() { MethodReference mr = StringStuff.makeMethodReference("cfg.MonitorTest.sync1()V"); IMethod m = cha.resolveMethod(mr); IAnalysisCacheView cache = makeAnalysisCache(); IR ir = cache.getIR(m); System.out.println(ir); SSACFG controlFlowGraph = ir.getControlFlowGraph(); Assert.assertEquals(1, controlFlowGraph.getSuccNodeCount(controlFlowGraph.getBlockForInstruction(21))); }
@Test public void testSync3() { MethodReference mr = StringStuff.makeMethodReference("cfg.MonitorTest.sync3()V"); IMethod m = cha.resolveMethod(mr); IAnalysisCacheView cache = makeAnalysisCache(); IR ir = cache.getIR(m); SSACFG controlFlowGraph = ir.getControlFlowGraph(); Assert.assertEquals(1, controlFlowGraph.getSuccNodeCount(controlFlowGraph.getBlockForInstruction(33))); }
@Test public void testSync2() { MethodReference mr = StringStuff.makeMethodReference("cfg.MonitorTest.sync2()V"); IMethod m = cha.resolveMethod(mr); IAnalysisCacheView cache = makeAnalysisCache(); IR ir = cache.getIR(m); System.out.println(ir); SSACFG controlFlowGraph = ir.getControlFlowGraph(); IntSet succs = controlFlowGraph.getSuccNodeNumbers(controlFlowGraph.getBlockForInstruction(13)); Assert.assertEquals(2, succs.size()); Assert.assertTrue(succs.contains(6)); Assert.assertTrue(succs.contains(7)); }