use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class UnusedCodeRemover method execute.
public void execute() {
ucf.resetMarks();
// This starts at all app roots and JVM roots, as well as all threads,
// <clinit> methods are marked in all reached classes
ucf.markUsedMembers();
// We also need to mark everything else we do not want to remove ..
AppInfo appInfo = AppInfo.getSingleton();
ProcessorModel pm = appInfo.getProcessorModel();
if (pm.keepJVMClasses()) {
for (String clName : pm.getJVMClasses()) {
ClassInfo cls = appInfo.getClassInfo(clName);
if (cls != null) {
ucf.markUsedMembers(cls, true);
}
}
}
removeUnusedMembers();
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class Report method generateInfoPages.
/**
* Dump the project's input (callgraph,cfgs)
*
* @throws IOException
*/
public void generateInfoPages() throws IOException {
this.addStat("#classes", project.getCallGraph().getClassInfos().size());
this.addStat("#methods", project.getCallGraph().getReachableImplementationsSet(project.getTargetMethod()).size());
this.addStat("max call stack ", project.getCallGraph().getMaximalCallStack());
this.addStat("largest method size (in bytes)", project.getCallGraph().getLargestMethod().getNumberOfBytes());
this.addStat("largest method size (in words)", project.getCallGraph().getLargestMethod().getNumberOfWords());
this.addStat("total size of task (in bytes)", project.getCallGraph().getTotalSizeInBytes());
generateInputOverview();
this.addPage("details", null);
for (MethodInfo m : project.getCallGraph().getReachableImplementationsSet(project.getTargetMethod())) {
for (LineNumber ln : m.getCode().getLineNumberTable().getLineNumberTable()) {
getClassReport(m.getClassInfo()).addLinePropertyIfNull(ln.getLineNumber(), "color", "lightgreen");
}
if (logger.isDebugEnabled()) {
logger.debug("Generating report for method: " + m);
}
ControlFlowGraph flowGraph = project.getFlowGraph(m);
Map<String, Object> stats = new TreeMap<String, Object>();
stats.put("#nodes", flowGraph.vertexSet().size() - 2);
stats.put("number of words", flowGraph.getNumberOfWords());
this.addDetailedReport(m, new DetailedMethodReport(config, project, m, "CFG", stats, null, null), true);
generateDetailedReport(m);
}
for (ClassInfo c : project.getCallGraph().getClassInfos()) {
ClassReport cr = getClassReport(c);
String page = pageOf(c);
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("classreport", cr);
try {
this.generateFile("class.vm", config.getReportFile(page), ctx);
} catch (Exception e) {
logger.error(e);
}
addPage("details/" + c.getClassName(), page);
}
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class HashTest method main.
public static void main(String[] args) {
TestFramework test = new TestFramework();
AppSetup setup = test.setupAppSetup();
AppInfo appInfo = test.setupAppInfo("common.code.HashTest", false);
ClassInfo testClass = appInfo.loadClass("common.TestFramework");
MethodInfo mainMethod = appInfo.getMainMethod();
MethodCode code = mainMethod.getCode();
InstructionHandle[] ih = code.getInstructionList().getInstructionHandles();
InvokeSite i1 = code.getInvokeSite(ih[1]);
InvokeSite i2 = code.getInvokeSite(ih[2]);
InvokeSite i3 = code.getInvokeSite(ih[3]);
InvokeSite i11 = code.getInvokeSite(ih[1]);
check(i1 == i11);
CallString c1 = new CallString(i1);
CallString c2 = new CallString(i2);
CallString c11 = new CallString(i1);
check(c1.equals(c11));
check(!c1.equals(c2));
ExecutionContext e1 = new ExecutionContext(mainMethod, c1);
ExecutionContext e2 = new ExecutionContext(mainMethod, c2);
ExecutionContext e11 = new ExecutionContext(mainMethod, c11);
check(e1.equals(e11));
check(!e1.equals(e2));
// TODO put stuff into maps, check contains() and get()
// modify instruction list, check if everything still works
InstructionList il = code.getInstructionList();
il.insert(new ILOAD(0));
il.insert(ih[2], new ILOAD(1));
ih = il.getInstructionHandles();
InvokeSite i12 = code.getInvokeSite(ih[2]);
InvokeSite i22 = code.getInvokeSite(ih[4]);
check(i12 == i1);
check(i22 == i2);
check(e1.equals(e11));
check(!e1.equals(e2));
il.setPositions();
check(c1.equals(c11));
check(!c1.equals(c2));
check(e1.equals(e11));
check(!e1.equals(e2));
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class WcetAppInfoTest method main.
/*
* DEMO
* ~~~~
*/
/* small demo using the class loader */
public static void main(String[] argv) {
AppSetup appSetup = new AppSetup();
WCETTool wcetTool = new WCETTool();
appSetup.registerTool("wcet", wcetTool);
Config config = appSetup.getConfig();
config.setOption(ProjectConfig.PROJECT_NAME, "typegraph");
AppInfo appInfo = appSetup.initAndLoad(argv, false, false, false);
ProjectConfig pConfig = wcetTool.getProjectConfig();
try {
System.out.println("Classloader Demo: " + pConfig.getAppClassName());
String rootClass = pConfig.getAppClassName();
String rootPkg = rootClass.substring(0, rootClass.lastIndexOf("."));
ClassInfo ci = appInfo.getClassInfo(pConfig.getAppClassName());
System.out.println("Source file: " + ci.getSourceFileName());
System.out.println("Root class: " + ci.toString());
{
System.out.println("Writing type graph to " + pConfig.getOutFile("typegraph.png"));
File dotFile = pConfig.getOutFile("typegraph.dot");
FileWriter dotWriter = new FileWriter(dotFile);
// FIXME TypeGraph is not used anymore, export ClassInfo/.. graph
TypeGraph typeGraph = new TypeGraph();
typeGraph.exportDOT(dotWriter, rootPkg);
dotWriter.close();
InvokeDot.invokeDot(wcetTool.getConfig(), dotFile, pConfig.getOutFile("typegraph.png"));
}
SuperGraph sg = new SuperGraph(appInfo, pConfig.getTargetMethodInfo().getCode().getControlFlowGraph(false), 0);
{
System.out.println("Writing supergraph graph to " + pConfig.getOutFile("supergraph.png"));
File dotFile = pConfig.getOutFile("callgraph.dot");
sg.exportDOT(dotFile);
InvokeDot.invokeDot(wcetTool.getConfig(), dotFile, pConfig.getOutFile("supergraph.png"));
}
CallGraph cg = appInfo.buildCallGraph(false);
{
System.out.println("Writing call graph to " + pConfig.getOutFile("callgraph.png"));
File dotFile = pConfig.getOutFile("callgraph.dot");
FileWriter dotWriter = new FileWriter(dotFile);
cg.exportDOT(dotWriter);
dotWriter.close();
InvokeDot.invokeDot(wcetTool.getConfig(), dotFile, pConfig.getOutFile("callgraph.png"));
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations