Search in sources :

Example 1 with BadConfigurationError

use of com.jopdesign.common.config.Config.BadConfigurationError in project jop by jop-devel.

the class AppSetup method initProcessorModel.

private void initProcessorModel(Model model) {
    ProcessorModel pm;
    switch(model) {
        case JOP:
            pm = new JOPModel(config);
            break;
        case jamuth:
            pm = new JamuthModel(config);
            break;
        case allocation:
            pm = new AllocationModel(config);
            break;
        case JVM:
            pm = new JVMModel();
            break;
        default:
            throw new BadConfigurationError("Unknown processor model " + model);
    }
    appInfo.setProcessorModel(pm);
    // load referenced classes as roots
    for (String jvmClass : pm.getJVMClasses()) {
        ClassInfo rootInfo = appInfo.loadClass(jvmClass.replaceAll("/", "."));
        if (rootInfo == null) {
            System.err.println("Error loading JVM class '" + jvmClass + "'.");
            System.exit(4);
        }
    }
    if (appInfo.doLoadNatives()) {
        for (String nativeClass : pm.getNativeClasses()) {
            ClassInfo rootInfo = appInfo.loadClass(nativeClass.replaceAll("/", "."));
            if (rootInfo == null) {
                System.err.println("Error loading Native class '" + nativeClass + "'.");
                System.exit(4);
            }
        }
    }
    // we do not set the JVM and native classes as root anymore, instead we let the PM decide which roots we need
    for (String root : pm.getJVMRoots()) {
        MemberID mID = MemberID.parse(root);
        // make sure the class exists..
        ClassInfo cls = appInfo.loadClass(mID.getClassName());
        // Get the member and add it as root
        if (mID.hasMemberName()) {
            MethodInfo methodInfo = cls.getMethodInfo(mID);
            if (methodInfo == null) {
                System.err.println("Could not find JVM root " + root);
                System.exit(5);
            }
            appInfo.addRoot(methodInfo);
        } else {
            appInfo.addRoot(cls);
        }
    }
}
Also used : MemberID(com.jopdesign.common.type.MemberID) BadConfigurationError(com.jopdesign.common.config.Config.BadConfigurationError) JOPModel(com.jopdesign.common.processormodel.JOPModel) AllocationModel(com.jopdesign.common.processormodel.AllocationModel) ProcessorModel(com.jopdesign.common.processormodel.ProcessorModel) JVMModel(com.jopdesign.common.processormodel.JVMModel) JamuthModel(com.jopdesign.common.processormodel.JamuthModel)

Example 2 with BadConfigurationError

use of com.jopdesign.common.config.Config.BadConfigurationError in project jop by jop-devel.

the class CallGraph method dumpCallgraph.

/**
 * Dump this callgraph or a subgraph to a file and create a png image.
 * If you use this method, add {@link #CALLGRAPH_DIR} to the options.
 *
 * @param config the config containing options for InvokeDot and {@link #CALLGRAPH_DIR}
 * @param graphName the name of the graph, will be used to construct the file name.
 * @param suffix a suffix for the graph name, e.g. to distinguish between various subgraphs
 * @param roots The roots of the subgraph to dump. If null, dump the whole graph. If roots is empty, do nothing.
 * @param type dump the complete graph, dump only the merged graph, or dump both or nothing.
 * @param skipNoim if true, do not include methods which have a single edge to the JVM.noim method.
 * @throws IOException if exporting the file fails.
 */
public void dumpCallgraph(Config config, String graphName, String suffix, Set<ExecutionContext> roots, DUMPTYPE type, boolean skipNoim) throws IOException {
    if (type == DUMPTYPE.off)
        return;
    if (roots != null && roots.isEmpty())
        return;
    File outDir;
    try {
        outDir = config.getOutDir(config.getDebugGroup(), CallGraph.CALLGRAPH_DIR);
    } catch (BadConfigurationException e) {
        throw new BadConfigurationError("Could not create output dir " + config.getDebugGroup().getOption(CallGraph.CALLGRAPH_DIR), e);
    }
    CallGraph subGraph = roots == null ? this : getSubGraph(roots);
    if (type == CallGraph.DUMPTYPE.merged || type == CallGraph.DUMPTYPE.both) {
        dumpCallgraph(config, outDir, graphName, suffix, subGraph, true, skipNoim);
    }
    if (type == CallGraph.DUMPTYPE.full || type == CallGraph.DUMPTYPE.both) {
        dumpCallgraph(config, outDir, graphName, suffix, subGraph, false, skipNoim);
    }
    if (roots != null) {
        removeSubGraph(subGraph);
    }
}
Also used : BadConfigurationError(com.jopdesign.common.config.Config.BadConfigurationError) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) File(java.io.File)

Example 3 with BadConfigurationError

use of com.jopdesign.common.config.Config.BadConfigurationError in project jop by jop-devel.

the class AnalysisManager method initAnalyses.

/**
 * Quick'n'dirty initialization of all analyses.
 * If the analyses get more options or get more complex in the future, this will need some work.
 *
 * @param targets the root methods to use for all analyses and the callgraph.
 * @param cacheAnalysisType cache analysis type
 * @param wcaRoots if not null, initialize the WCA invoker with these roots.
 * @param updateWCEP if true, let the wcaInvoker provide a global WCET path and keep it up-to-date
 */
public void initAnalyses(Set<MethodInfo> targets, AnalysisType cacheAnalysisType, CacheCostCalculationMethod cacheApproximation, boolean useMethodCacheStrategy, Set<MethodInfo> wcaRoots, boolean updateWCEP) {
    logger.info("Initializing analyses..");
    Set<MethodInfo> allTargets = new LinkedHashSet<MethodInfo>(targets);
    if (wcaRoots != null) {
        // Just make sure the WCA callgraph is contained in the target graph..
        allTargets.addAll(wcaRoots);
        wcaInvoker = new WCAInvoker(this, wcaRoots, cacheApproximation);
        wcaInvoker.setProvideWCAExecCount(updateWCEP);
        try {
            // need to initialize the WCA Tool before the other analyses since we need the WCA callgraph
            wcaInvoker.initTool();
        } catch (BadConfigurationException e) {
            // TODO or maybe just throw the exception up a few levels more?
            throw new BadConfigurationError(e.getMessage(), e);
        }
    }
    if (wcaRoots != null && wcaRoots.equals(allTargets) && wcaInvoker.getWCACallGraphs().size() == 1) {
        targetCallGraph = wcaInvoker.getWCACallGraphs().iterator().next();
    } else {
        logger.info("Initializing Target Callgraph");
        targetCallGraph = CallGraph.buildCallGraph(allTargets, new DefaultCallgraphBuilder(AppInfo.getSingleton().getCallstringLength()));
    }
    // TODO we might want to classify methods depending on whether they are reachable from the wcaRoots
    // for all non-wca-methods we might want to use different initial analysis data, e.g.
    // if we use the WCA, we might want to use the IPET WCA to initialize the execCountAnalysis for
    // wca-methods
    // We can do this as first step (after the callgraph has been created) since it does not use the ExecFrequencyAnalysis
    logger.info("Initializing MethodCacheAnalysis");
    methodCacheAnalysis = new MethodCacheAnalysis(jcopter, cacheAnalysisType, targetCallGraph);
    methodCacheAnalysis.initialize();
    if (wcaRoots != null) {
        logger.info("Initializing WCAInvoker");
        wcaInvoker.initAnalysis(useMethodCacheStrategy);
    }
    // TODO in fact, we might not even need this if we only use the wcaInvoker as provider or some other provider
    logger.info("Initializing ExecFrequencyAnalysis");
    execFreqAnalysis = new ExecFrequencyAnalysis(this, targetCallGraph);
    execFreqAnalysis.initialize();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) BadConfigurationError(com.jopdesign.common.config.Config.BadConfigurationError) DefaultCallgraphBuilder(com.jopdesign.common.code.DefaultCallgraphBuilder) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) MethodInfo(com.jopdesign.common.MethodInfo)

Aggregations

BadConfigurationError (com.jopdesign.common.config.Config.BadConfigurationError)3 BadConfigurationException (com.jopdesign.common.config.Config.BadConfigurationException)2 MethodInfo (com.jopdesign.common.MethodInfo)1 DefaultCallgraphBuilder (com.jopdesign.common.code.DefaultCallgraphBuilder)1 AllocationModel (com.jopdesign.common.processormodel.AllocationModel)1 JOPModel (com.jopdesign.common.processormodel.JOPModel)1 JVMModel (com.jopdesign.common.processormodel.JVMModel)1 JamuthModel (com.jopdesign.common.processormodel.JamuthModel)1 ProcessorModel (com.jopdesign.common.processormodel.ProcessorModel)1 MemberID (com.jopdesign.common.type.MemberID)1 File (java.io.File)1 LinkedHashSet (java.util.LinkedHashSet)1