public Analyzer( AnalysisSpecification spec) { // Why is this here ?? There is not ref to it in the project this.specification = spec; if (specification.getTypeOfAnalysisPerformed() != AnalysisType.ALLOCATIONS) { this.stackAnalyzer = new StackAnalyzer(specification.getJvmModel()); } }
public void addReportData( final String sourceFilePath, final Set<Integer> lines, final CGNode cgNode, final ICostResult cost) { int startIndex = analysisSpecification.getSourceFilesRootDir().length(); int stopIndex = sourceFilePath.lastIndexOf('/'); final String packages = sourceFilePath.substring(startIndex, stopIndex).replace('/', '.'); for (ReportEntry entry : reportEntries) { if (entry.getSource().equals(sourceFilePath)) { entry.addEntry(cgNode, cost); entry.setPackages(packages); entry.setLineNumbers(lines, cgNode); return; } } reportEntries.add( new ReportEntry() { { setSource(sourceFilePath); addEntry(cgNode, cost); setPackages(packages); setLineNumbers(lines, cgNode); } }); }
private AnalysisResults() { this.nodesProcessed = new HashMap<CGNode, ICostResult>(); this.reportEntries = new ArrayList<ReportEntry>(); this.reportData = new ReportData(); this.worstCaseStackTraceNextNodeInStackByNode = new HashMap<CGNode, CGNode>(); this.analysisSpecification = AnalysisSpecification.getAnalysisSpecification(); }
public void start(Class<? extends ICostComputer<ICostResult>> costComputerType) throws InstantiationException, IllegalAccessException, IllegalArgumentException, WalaException, IOException, SecurityException, InvocationTargetException, NoSuchMethodException { this.costComputer = costComputerType .getDeclaredConstructor(JVMModel.class) .newInstance(specification.getJvmModel()); LinkedList<CGNode> entryCGNodes = specification.getEntryPointCGNodes(); for (CGNode entryNode : entryCGNodes) { // OutputPrinter.printInfo("Starting entry node " + entryNode.getMethod().toString()); ICostResult results = new CGNodeAnalyzer(entryNode, costComputer).analyzeNode(); // ICostResult results = new // CostComputerMemory(specification.getJvmModel()).dfsVisit(entryNode); // Test code CostResultMemory memRes = (CostResultMemory) results; OutputPrinter.printInfo( "Worst case allocation for " + entryNode.getMethod().toString() + ":\t" + results.getCostScalar()); for (Entry<TypeName, Integer> i : memRes.aggregatedCountByTypename.entrySet()) { OutputPrinter.printInfo( "\t TYPE_NAME\t" + i.getKey().toString() + "\tCOUNT " + i.getValue()); } } /* This is move to the program. if ( specification.getTypeOfAnalysisPerformed() != AnalysisType.ALLOCATIONS) { stackAnalyzer.analyze(); } if ( specification.getShouldGenerateAnalysisReports() == true) { ReportGenerator gen = new ReportGenerator(); gen.Generate(AnalysisResults.getAnalysisResults().getReportEntries()); }*/ }
private Analyzer() { this.specification = AnalysisSpecification.getAnalysisSpecification(); this.stackAnalyzer = new StackAnalyzer(specification.getJvmModel()); }