Search in sources :

Example 6 with AppInfoError

use of com.jopdesign.common.misc.AppInfoError in project jop by jop-devel.

the class GreedyOptimizer method optimize.

public void optimize() {
    List<MethodInfo> rootMethods = config.getTargetMethods();
    // initialization
    resetCounters();
    boolean useWCAProvider = config.useWCA() && config.useWCAExecCount();
    GreedyOrder order = config.getOrder();
    if (order != GreedyOrder.WCAFirst) {
        //      updated as well.
        if (!config.getTargetMethodSet().equals(config.getWCATargetSet())) {
            logger.warn("Using the WCA for exec frequencies is currently only supported if order is WCAFirst " + "or if the target method is the WCA target method");
            useWCAProvider = false;
        }
    }
    AnalysisManager analyses = initializeAnalyses(config.useWCEP() || useWCAProvider);
    for (CodeOptimizer opt : optimizers) {
        opt.initialize(analyses, rootMethods);
    }
    CandidateSelector selector;
    if (config.useWCA()) {
        GainCalculator gc = new GainCalculator(analyses);
        if (config.useWCEP()) {
            logger.info("Using WCEP driven selector");
            selector = new WCEPRebateSelector(analyses, gc, config.getMaxCodesize());
        } else {
            logger.info("Using WCA driven selector");
            selector = new WCETRebateSelector(analyses, gc, config.getMaxCodesize());
        }
    } else {
        logger.info("WCA is disabled, not using WCA for optimization.");
        selector = new ACETRebateSelector(analyses, new GainCalculator(analyses), config.getMaxCodesize());
    }
    selector.initialize(config, true);
    ExecFrequencyProvider ecp = useWCAProvider ? analyses.getWCAInvoker() : analyses.getExecFrequencyAnalysis();
    if (config.useLocalExecCount()) {
        ecp = new LocalExecFrequencyProvider(ecp);
    }
    // dump initial callgraph
    logger.info("Initial number of methods in target callgraph: " + analyses.getTargetCallGraph().getMethodInfos().size());
    analyses.getTargetCallGraph().dumpCallgraph(jcopter.getJConfig().getConfig(), "greedy-target", config.getTargetCallgraphDumpType(), true);
    if (order == GreedyOrder.Global || (order == GreedyOrder.WCAFirst && !config.useWCA())) {
        optimizeMethods(analyses, ecp, selector, analyses.getTargetCallGraph().getMethodInfos());
    } else if (order == GreedyOrder.Targets) {
        for (MethodInfo target : config.getTargetMethods()) {
            optimizeMethods(analyses, ecp, selector, analyses.getTargetCallGraph().getReachableImplementationsSet(target));
        }
    } else if (order == GreedyOrder.WCAFirst) {
        logger.info("Optimizing WCA target");
        Set<MethodInfo> wcaMethods = analyses.getWCAMethods();
        optimizeMethods(analyses, ecp, selector, wcaMethods);
        selector.printStatistics();
        // We do not want to include the wca methods in the second pass because inlining there could have negative
        // effects on the WCET path due to the cache
        Set<MethodInfo> others = new LinkedHashSet<MethodInfo>(analyses.getTargetCallGraph().getMethodInfos());
        others.removeAll(wcaMethods);
        logger.info("Optimizing non-WCA code");
        //analyses.dumpTargetCallgraph("acet", true);
        selector = new ACETRebateSelector(analyses, new GainCalculator(analyses), config.getMaxCodesize());
        selector.initialize(config, false);
        ecp = analyses.getExecFrequencyAnalysis();
        if (config.useLocalExecCount()) {
            ecp = new LocalExecFrequencyProvider(ecp);
        }
        optimizeMethods(analyses, ecp, selector, others);
    } else if (order == GreedyOrder.TopDown || order == GreedyOrder.BottomUp) {
        if (config.useWCA() && !analyses.hasWCATargetsOnly()) {
            // TODO iterate over WCA and then non-wca graph or something in this case..
            throw new AppInfoError("Order " + order + " currently only works with WCA if the target method is the WCA target");
        }
        TopologicalOrderIterator<MethodNode, InvokeEdge> topOrder = new TopologicalOrderIterator<MethodNode, InvokeEdge>(analyses.getTargetCallGraph().getAcyclicMergedGraph(order == GreedyOrder.BottomUp));
        while (topOrder.hasNext()) {
            MethodNode node = topOrder.next();
            optimizeMethods(analyses, ecp, selector, Collections.singleton(node.getMethodInfo()));
        }
    } else {
        throw new AppInfoError("Order " + order + " not yet implemented.");
    }
    // dump final callgraph
    analyses.getTargetCallGraph().dumpCallgraph(jcopter.getJConfig().getConfig(), "greedy-target-opt", config.getTargetCallgraphDumpType(), true);
    selector.printStatistics();
    printStatistics();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) LocalExecFrequencyProvider(com.jopdesign.jcopter.analysis.LocalExecFrequencyProvider) TopologicalOrderIterator(org.jgrapht.traverse.TopologicalOrderIterator) InvokeEdge(com.jopdesign.common.code.CallGraph.InvokeEdge) ExecFrequencyProvider(com.jopdesign.jcopter.analysis.ExecFrequencyProvider) LocalExecFrequencyProvider(com.jopdesign.jcopter.analysis.LocalExecFrequencyProvider) AppInfoError(com.jopdesign.common.misc.AppInfoError) MethodNode(com.jopdesign.common.code.CallGraph.MethodNode) MethodInfo(com.jopdesign.common.MethodInfo) AnalysisManager(com.jopdesign.jcopter.analysis.AnalysisManager) GreedyOrder(com.jopdesign.jcopter.greedy.GreedyConfig.GreedyOrder)

Example 7 with AppInfoError

use of com.jopdesign.common.misc.AppInfoError in project jop by jop-devel.

the class RebateSelector method initialize.

@Override
public void initialize(GreedyConfig config, boolean dumpStats) {
    // calculate current global codesize
    globalCodesize = 0;
    if (usesCodeRemover) {
        for (MethodInfo method : AppInfo.getSingleton().getCallGraph().getMethodInfos()) {
            if (!method.hasCode())
                continue;
            globalCodesize += method.getCode().getNumberOfBytes();
        }
    } else {
        for (ClassInfo cls : AppInfo.getSingleton().getClassInfos()) {
            for (MethodInfo method : cls.getMethods()) {
                if (!method.hasCode())
                    continue;
                globalCodesize += method.getCode().getNumberOfBytes();
            }
        }
    }
    // we need a tie-breaker for the candidate selection, and to make the results deterministic
    // so we use a topological order of the (initial) callgraph
    DFSVisitor<ExecutionContext, ContextEdge> visitor = new EmptyDFSVisitor<ExecutionContext, ContextEdge>() {

        private int counter = 1;

        @Override
        public void postorder(ExecutionContext node) {
            depthMap.put(node.getMethodInfo(), counter++);
        }
    };
    DirectedGraph<ExecutionContext, ContextEdge> graph = analyses.getTargetCallGraph().getReversedGraph();
    DFSTraverser<ExecutionContext, ContextEdge> traverser = new DFSTraverser<ExecutionContext, ContextEdge>(visitor);
    traverser.traverse(graph);
    logger.info("Initial codesize: " + globalCodesize + " bytes");
    if (config.doDumpStats() && dumpStats) {
        try {
            File statsFile = config.getStatsFile();
            dump = new PrintWriter(statsFile);
            dump.print("total codesize, ");
            if (analyses.useWCAInvoker())
                dump.print("WCET, ");
            dump.println("candidate, ratio, gain, local gain, cache, local cache, delta codesize, frequency");
        } catch (FileNotFoundException e) {
            throw new AppInfoError("Could not initialize dump file", e);
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) EmptyDFSVisitor(com.jopdesign.common.graphutils.DFSTraverser.EmptyDFSVisitor) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge) AppInfoError(com.jopdesign.common.misc.AppInfoError) DFSTraverser(com.jopdesign.common.graphutils.DFSTraverser) ExecutionContext(com.jopdesign.common.code.ExecutionContext) MethodInfo(com.jopdesign.common.MethodInfo) File(java.io.File) ClassInfo(com.jopdesign.common.ClassInfo) PrintWriter(java.io.PrintWriter)

Example 8 with AppInfoError

use of com.jopdesign.common.misc.AppInfoError in project jop by jop-devel.

the class InlineHelper method prepareInlining.

/**
     * Prepare the invokee for inlining into the invokesite, by widening access restrictions or renaming
     * methods to prevent incorrect method resolving.
     * <p>
     * This may change the code of the invokee, so this needs to be done before inlining the code.
     * The CFG of the invokee will be removed.
     * </p><p>
     * This code assumes that {@link #canInline(CallString, InvokeSite, MethodInfo)} returned true for this invoke.
     * </p>
     *
     * @param invoker the method where the code will be inlined to.
     * @param invokee the method to inline.
     */
public void prepareInlining(MethodInfo invoker, MethodInfo invokee) {
    MethodCode code = invokee.getCode();
    InstructionList il = code.getInstructionList();
    for (InstructionHandle ih : il.getInstructionHandles()) {
        Instruction instr = ih.getInstruction();
        if (instr instanceof InvokeInstruction) {
            InvokeSite invokeSite = code.getInvokeSite(ih);
            MethodRef ref = invokeSite.getInvokeeRef();
            MethodInfo method = ref.getMethodInfo();
            // we already checked that everything can be resolved
            // nothing special to do for invokespecial here (checkInvokeSpecial only skips, no special return codes)
            // check what we need to do
            CheckResult rs = checkNeedsPublic(invoker, invokee, ref.getClassInfo(), method);
            if (rs == CheckResult.NEEDS_PUBLIC) {
                makePublic(method);
            }
            if (rs == CheckResult.NEEDS_PUBLIC_RENAME) {
                if (method.isPrivate()) {
                // TODO check the class for invokers, change to invokevirtual
                } else {
                // if the method is package visible, we need to rename all overriding methods
                // too (but not methods from subclasses in different packages which do not override this)
                // TODO update overriding methods
                // TODO need to update all possible call sites
                }
                makePublic(method);
                throw new AppInfoError("Implement me!");
            }
        } else if (instr instanceof FieldInstruction) {
            FieldRef ref = code.getFieldRef(ih);
            FieldInfo field = ref.getFieldInfo();
            // we already checked that everything can be resolved
            // check if fields need to be set to public
            CheckResult rs = checkNeedsPublic(invoker, invokee, ref.getClassInfo(), field);
            if (rs == CheckResult.NEEDS_PUBLIC) {
                makePublic(field);
            }
            if (rs == CheckResult.NEEDS_PUBLIC_RENAME) {
                throw new AppInfoError("Invalid returncode: renaming of fields not required");
            }
        }
    }
}
Also used : FieldRef(com.jopdesign.common.type.FieldRef) InstructionList(org.apache.bcel.generic.InstructionList) InvokeInstruction(org.apache.bcel.generic.InvokeInstruction) ConstantPushInstruction(org.apache.bcel.generic.ConstantPushInstruction) Instruction(org.apache.bcel.generic.Instruction) FieldInstruction(org.apache.bcel.generic.FieldInstruction) LocalVariableInstruction(org.apache.bcel.generic.LocalVariableInstruction) InstructionHandle(org.apache.bcel.generic.InstructionHandle) AppInfoError(com.jopdesign.common.misc.AppInfoError) InvokeInstruction(org.apache.bcel.generic.InvokeInstruction) MethodRef(com.jopdesign.common.type.MethodRef) MethodInfo(com.jopdesign.common.MethodInfo) InvokeSite(com.jopdesign.common.code.InvokeSite) FieldInstruction(org.apache.bcel.generic.FieldInstruction) MethodCode(com.jopdesign.common.MethodCode) FieldInfo(com.jopdesign.common.FieldInfo)

Example 9 with AppInfoError

use of com.jopdesign.common.misc.AppInfoError in project jop by jop-devel.

the class ValueMapAnalysis method transfer.

public void transfer(Instruction instruction) {
    switch(instruction.getOpcode()) {
        case Constants.NOP:
            break;
        case Constants.ACONST_NULL:
            values.push(new ValueInfo(Type.NULL));
            break;
        case Constants.ICONST_M1:
        case Constants.ICONST_0:
        case Constants.ICONST_1:
        case Constants.ICONST_2:
        case Constants.ICONST_3:
        case Constants.ICONST_4:
        case Constants.ICONST_5:
        case Constants.BIPUSH:
        case Constants.SIPUSH:
            {
                ConstantPushInstruction instr = (ConstantPushInstruction) instruction;
                int value = instr.getValue().intValue();
                values.push(new ValueInfo(instr.getType(cpg), new ConstantIntegerInfo(value)));
                break;
            }
        case Constants.LCONST_0:
        case Constants.LCONST_1:
            {
                ConstantPushInstruction instr = (ConstantPushInstruction) instruction;
                long value = instr.getValue().longValue();
                values.push(new ValueInfo(instr.getType(cpg), new ConstantLongInfo(value)));
                break;
            }
        case Constants.FCONST_0:
        case Constants.FCONST_1:
        case Constants.FCONST_2:
            {
                ConstantPushInstruction instr = (ConstantPushInstruction) instruction;
                float value = instr.getValue().floatValue();
                values.push(new ValueInfo(instr.getType(cpg), new ConstantFloatInfo(value)));
                break;
            }
        case Constants.DCONST_0:
        case Constants.DCONST_1:
            {
                ConstantPushInstruction instr = (ConstantPushInstruction) instruction;
                double value = instr.getValue().doubleValue();
                values.push(new ValueInfo(instr.getType(cpg), new ConstantDoubleInfo(value)));
                break;
            }
        case Constants.LDC:
        case Constants.LDC_W:
        case Constants.LDC2_W:
            {
                CPInstruction instr = (CPInstruction) instruction;
                values.push(new ValueInfo(methodInfo.getClassInfo().getConstantInfo(instr.getIndex())));
                break;
            }
        case Constants.ISTORE_0:
        case Constants.ISTORE_1:
        case Constants.ISTORE_2:
        case Constants.ISTORE_3:
        case Constants.ISTORE:
        case Constants.ASTORE_0:
        case Constants.ASTORE_1:
        case Constants.ASTORE_2:
        case Constants.ASTORE_3:
        case Constants.ASTORE:
        case Constants.LSTORE_0:
        case Constants.LSTORE_1:
        case Constants.LSTORE_2:
        case Constants.LSTORE_3:
        case Constants.LSTORE:
        case Constants.DSTORE_0:
        case Constants.DSTORE_1:
        case Constants.DSTORE_2:
        case Constants.DSTORE_3:
        case Constants.DSTORE:
        case Constants.FSTORE_0:
        case Constants.FSTORE_1:
        case Constants.FSTORE_2:
        case Constants.FSTORE_3:
        case Constants.FSTORE:
            {
                StoreInstruction instr = (StoreInstruction) instruction;
                int index = instr.getIndex();
                values.setLocalValue(index, values.popValue());
                break;
            }
        case Constants.ILOAD_0:
        case Constants.ILOAD_1:
        case Constants.ILOAD_2:
        case Constants.ILOAD_3:
        case Constants.ILOAD:
        case Constants.LLOAD_0:
        case Constants.LLOAD_1:
        case Constants.LLOAD_2:
        case Constants.LLOAD_3:
        case Constants.LLOAD:
        case Constants.FLOAD_0:
        case Constants.FLOAD_1:
        case Constants.FLOAD_2:
        case Constants.FLOAD_3:
        case Constants.FLOAD:
        case Constants.DLOAD_0:
        case Constants.DLOAD_1:
        case Constants.DLOAD_2:
        case Constants.DLOAD_3:
        case Constants.DLOAD:
        case Constants.ALOAD_0:
        case Constants.ALOAD_1:
        case Constants.ALOAD_2:
        case Constants.ALOAD_3:
        case Constants.ALOAD:
            {
                LoadInstruction instr = (LoadInstruction) instruction;
                int index = instr.getIndex();
                values.push(values.getLocalValue(index));
                break;
            }
        case Constants.DUP:
            values.push(values.top());
            break;
        case Constants.DUP_X1:
            values.insert(2, values.top());
            break;
        case Constants.DUP_X2:
            values.insert(3, values.top());
        case Constants.DUP2:
            values.push(values.top(1), false);
            values.push(values.top(1), false);
            break;
        case Constants.DUP2_X1:
            values.insert(3, values.top(1));
            values.insert(3, values.top(0));
            break;
        case Constants.DUP2_X2:
            values.insert(4, values.top(1));
            values.insert(4, values.top(0));
            break;
        case Constants.POP:
            values.pop();
            break;
        case Constants.POP2:
            values.pop();
            values.pop();
            break;
        case Constants.SWAP:
            values.insert(1, values.pop());
            break;
        case Constants.IASTORE:
        case Constants.LASTORE:
        case Constants.FASTORE:
        case Constants.DASTORE:
        case Constants.CASTORE:
        case Constants.SASTORE:
        case Constants.BASTORE:
        case Constants.AASTORE:
            values.popValue();
            values.pop();
            values.pop();
            break;
        case Constants.IALOAD:
        case Constants.LALOAD:
        case Constants.FALOAD:
        case Constants.DALOAD:
        case Constants.CALOAD:
        case Constants.SALOAD:
        case Constants.BALOAD:
        case Constants.AALOAD:
            {
                values.pop();
                values.pop();
                Type t = ((ArrayInstruction) instruction).getType(cpg);
                values.push(new ValueInfo(t));
                break;
            }
        case Constants.IINC:
            {
                int i = ((IINC) instruction).getIndex();
                ValueInfo old = values.getLocalValue(i);
                if (old.isConstantValue() && old.getConstantValue() instanceof ConstantIntegerInfo) {
                    ConstantIntegerInfo value = (ConstantIntegerInfo) old.getConstantValue();
                    int newval = value.getValue() + ((IINC) instruction).getIncrement();
                    values.setLocalValue(i, new ValueInfo(new ConstantIntegerInfo(newval)));
                } else {
                    values.setLocalValue(i, new ValueInfo(Type.INT));
                }
                break;
            }
        case Constants.IADD:
        case Constants.ISUB:
        case Constants.IMUL:
        case Constants.IDIV:
        case Constants.IREM:
        case Constants.IAND:
        case Constants.IOR:
        case Constants.IXOR:
        case Constants.ISHL:
        case Constants.ISHR:
        case Constants.IUSHR:
            values.pop();
        case Constants.INEG:
            values.pop();
            values.push(new ValueInfo(Type.INT));
            break;
        case Constants.FADD:
        case Constants.FSUB:
        case Constants.FMUL:
        case Constants.FDIV:
        case Constants.FREM:
            values.pop();
        case Constants.FNEG:
            values.pop();
            values.push(new ValueInfo(Type.FLOAT));
            break;
        case Constants.LADD:
        case Constants.LSUB:
        case Constants.LMUL:
        case Constants.LDIV:
        case Constants.LREM:
        case Constants.LAND:
        case Constants.LOR:
        case Constants.LXOR:
            values.pop();
            values.pop();
        case Constants.LNEG:
            values.pop();
            values.pop();
            values.push(new ValueInfo(Type.LONG));
            break;
        case Constants.DADD:
        case Constants.DSUB:
        case Constants.DMUL:
        case Constants.DDIV:
        case Constants.DREM:
            values.pop();
            values.pop();
        case Constants.DNEG:
            values.pop();
            values.pop();
            values.push(new ValueInfo(Type.DOUBLE));
            break;
        case Constants.LSHL:
        case Constants.LSHR:
        case Constants.LUSHR:
            values.pop();
            values.pop();
            values.pop();
            values.push(new ValueInfo(Type.LONG));
            break;
        case Constants.I2B:
        case Constants.I2C:
        case Constants.I2S:
        case Constants.I2L:
        case Constants.I2F:
        case Constants.I2D:
        case Constants.L2I:
        case Constants.L2F:
        case Constants.L2D:
        case Constants.F2I:
        case Constants.F2L:
        case Constants.F2D:
        case Constants.D2I:
        case Constants.D2L:
        case Constants.D2F:
            {
                values.popValue();
                values.push(new ValueInfo(((ConversionInstruction) instruction).getType(cpg)));
                break;
            }
        case Constants.LCMP:
        case Constants.DCMPL:
        case Constants.DCMPG:
            values.pop();
            values.pop();
        case Constants.FCMPL:
        case Constants.FCMPG:
            values.pop();
            values.pop();
            values.push(new ValueInfo(Type.INT));
            break;
        case Constants.IF_ICMPEQ:
        case Constants.IF_ICMPNE:
        case Constants.IF_ICMPLT:
        case Constants.IF_ICMPGE:
        case Constants.IF_ICMPGT:
        case Constants.IF_ICMPLE:
        case Constants.IF_ACMPEQ:
        case Constants.IF_ACMPNE:
            values.pop();
        case Constants.IFEQ:
        case Constants.IFNE:
        case Constants.IFLT:
        case Constants.IFGE:
        case Constants.IFLE:
        case Constants.IFGT:
        case Constants.IFNULL:
        case Constants.IFNONNULL:
            values.pop();
            break;
        case Constants.GOTO:
        case Constants.RET:
            break;
        case Constants.JSR:
            // This is of type 'returnAddress'
            values.push(new ValueInfo(Type.INT));
            break;
        case Constants.ARETURN:
        case Constants.IRETURN:
        case Constants.LRETURN:
        case Constants.FRETURN:
        case Constants.DRETURN:
        case Constants.RETURN:
            values.clearStack();
            break;
        case Constants.LOOKUPSWITCH:
        case Constants.TABLESWITCH:
            values.pop();
            break;
        case Constants.GETFIELD:
            values.pop();
        case Constants.GETSTATIC:
            {
                FieldInstruction f = (FieldInstruction) instruction;
                ConstantFieldInfo field = (ConstantFieldInfo) methodInfo.getClassInfo().getConstantInfo(f.getIndex());
                values.push(new ValueInfo(f.getFieldType(cpg), field.getValue()));
                break;
            }
        case Constants.PUTFIELD:
            values.pop();
        case Constants.PUTSTATIC:
            {
                FieldInstruction f = (FieldInstruction) instruction;
                values.pop(f.getFieldType(cpg).getSize());
                break;
            }
        case Constants.INVOKEVIRTUAL:
        case Constants.INVOKEINTERFACE:
        case Constants.INVOKESPECIAL:
            values.pop();
        case Constants.INVOKESTATIC:
            {
                InvokeInstruction invoke = (InvokeInstruction) instruction;
                values.pop(TypeHelper.getNumSlots(invoke.getArgumentTypes(cpg)));
                values.push(new ValueInfo(invoke.getReturnType(cpg)));
                break;
            }
        case Constants.MONITORENTER:
        case Constants.MONITOREXIT:
            values.pop();
            break;
        case Constants.ATHROW:
            ValueInfo ref = values.pop();
            values.clearStack();
            values.push(ref);
            break;
        case Constants.CHECKCAST:
            break;
        case Constants.INSTANCEOF:
            values.pop();
            values.push(new ValueInfo(Type.INT));
            break;
        case Constants.NEW:
            values.push(new ValueInfo(((NEW) instruction).getType(cpg)));
            break;
        case Constants.NEWARRAY:
            {
                Type t = ((NEWARRAY) instruction).getType();
                values.push(new ValueInfo(new ArrayType(t, 1)));
                break;
            }
        case Constants.ANEWARRAY:
            {
                Type t = ((ANEWARRAY) instruction).getType(cpg);
                values.push(new ValueInfo(new ArrayType(t, 1)));
                break;
            }
        case Constants.MULTIANEWARRAY:
            {
                MULTIANEWARRAY instr = (MULTIANEWARRAY) instruction;
                values.pop(instr.getDimensions());
                values.push(new ValueInfo(new ArrayType(instr.getType(cpg), instr.getDimensions())));
                break;
            }
        case Constants.ARRAYLENGTH:
            values.pop();
            values.push(new ValueInfo(Type.INT));
            break;
        default:
            throw new AppInfoError("Instruction not supported: " + instruction);
    }
}
Also used : NEW(org.apache.bcel.generic.NEW) ConstantDoubleInfo(com.jopdesign.common.type.ConstantDoubleInfo) MULTIANEWARRAY(org.apache.bcel.generic.MULTIANEWARRAY) ConstantIntegerInfo(com.jopdesign.common.type.ConstantIntegerInfo) ConstantFloatInfo(com.jopdesign.common.type.ConstantFloatInfo) ConstantFieldInfo(com.jopdesign.common.type.ConstantFieldInfo) ConstantLongInfo(com.jopdesign.common.type.ConstantLongInfo) AppInfoError(com.jopdesign.common.misc.AppInfoError) ArrayType(org.apache.bcel.generic.ArrayType) CPInstruction(org.apache.bcel.generic.CPInstruction) InvokeInstruction(org.apache.bcel.generic.InvokeInstruction) LoadInstruction(org.apache.bcel.generic.LoadInstruction) Type(org.apache.bcel.generic.Type) ArrayType(org.apache.bcel.generic.ArrayType) ValueInfo(com.jopdesign.common.type.ValueInfo) IINC(org.apache.bcel.generic.IINC) FieldInstruction(org.apache.bcel.generic.FieldInstruction) ConstantPushInstruction(org.apache.bcel.generic.ConstantPushInstruction) StoreInstruction(org.apache.bcel.generic.StoreInstruction)

Example 10 with AppInfoError

use of com.jopdesign.common.misc.AppInfoError in project jop by jop-devel.

the class Config method getOutDir.

/**
     * Get a subdirectory under the write path configured by {@link Config#WRITE_PATH} and create it
     * if it does not exist.
     *
     * @param sub name of a subdirectory
     * @return a file representing the directory.
     */
public File getOutDir(String sub) {
    File outDir = getOutDir();
    File subDir = new File(outDir, sub);
    if (!subDir.exists()) {
        if (!subDir.mkdirs()) {
            throw new AppInfoError("Failed to create subdirectory " + sub + " in outdir");
        }
    }
    return subDir;
}
Also used : File(java.io.File) AppInfoError(com.jopdesign.common.misc.AppInfoError)

Aggregations

AppInfoError (com.jopdesign.common.misc.AppInfoError)19 MethodInfo (com.jopdesign.common.MethodInfo)6 LinkedHashSet (java.util.LinkedHashSet)6 CallString (com.jopdesign.common.code.CallString)5 IOException (java.io.IOException)5 ExecutionContext (com.jopdesign.common.code.ExecutionContext)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 InvokeInstruction (org.apache.bcel.generic.InvokeInstruction)3 ClassInfo (com.jopdesign.common.ClassInfo)2 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)2 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)2 InvokeSite (com.jopdesign.common.code.InvokeSite)2 LoopBound (com.jopdesign.common.code.LoopBound)2 FieldRef (com.jopdesign.common.type.FieldRef)2 MethodRef (com.jopdesign.common.type.MethodRef)2 DFATool (com.jopdesign.dfa.DFATool)2 Context (com.jopdesign.dfa.framework.Context)2 ContextMap (com.jopdesign.dfa.framework.ContextMap)2 BufferedReader (java.io.BufferedReader)2