Search in sources :

Example 11 with AppInfoError

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

the class GlobalAnalysis method getLoopBounds.

/**
	 * <p>Get all loop bounds for the given segment.</p>
	 * <p>For each loop bound B for loop H relative to marker M:</p>
	 * <p>sum(M) * B &lt;= sum(continue-edges-of(H))</p>
     *
	 * @param segment
	 * @return
	 * @throws InvalidFlowFactException 
	 */
private static Iterable<LinearConstraint<SuperGraphEdge>> getLoopBounds(WCETTool wcetTool, Segment segment) throws InvalidFlowFactException {
    List<LinearConstraint<SuperGraphEdge>> constraints = new ArrayList<LinearConstraint<SuperGraphEdge>>();
    // For all CFG instances
    for (ContextCFG ccfg : segment.getCallGraphNodes()) {
        ControlFlowGraph cfg = ccfg.getCfg();
        // for all loops in the method
        LoopColoring<CFGNode, ControlFlowGraph.CFGEdge> loops = cfg.getLoopColoring();
        for (CFGNode hol : loops.getHeadOfLoops()) {
            LoopBound loopBound = wcetTool.getLoopBound(hol, ccfg.getContext().getCallString());
            if (loopBound == null) {
                throw new AppInfoError("No loop bound record for head of loop: " + hol + " : " + cfg.buildLoopBoundMap());
            }
            addLoopConstraints(constraints, segment, ccfg, hol, loops, loopBound);
        }
    }
    return constraints;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ContextCFG(com.jopdesign.common.code.SuperGraph.ContextCFG) LoopBound(com.jopdesign.common.code.LoopBound) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) ArrayList(java.util.ArrayList) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) LinearConstraint(com.jopdesign.wcet.ipet.LinearConstraint) AppInfoError(com.jopdesign.common.misc.AppInfoError) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 12 with AppInfoError

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

the class IPETUtils method loopBoundConstraints.

/**
     * Compute flow constraints: Loop Bound constraints (Control Flow Graph only)
     *
     * @param g   the flow graph
     * @param ctx the invocation context
     * @return A list of flow constraints
     */
public static <C extends CallStringProvider> List<LinearConstraint<IPETBuilder.ExecutionEdge>> loopBoundConstraints(ControlFlowGraph g, IPETBuilder<C> ctx) {
    List<LinearConstraint<IPETBuilder.ExecutionEdge>> constraints = new ArrayList<LinearConstraint<IPETBuilder.ExecutionEdge>>();
    // - for each loop with bound B
    // -- sum(exit_loop_edges) * B <= sum(continue_loop_edges)
    LoopColoring<CFGNode, ControlFlowGraph.CFGEdge> loops = g.getLoopColoring();
    for (CFGNode hol : loops.getHeadOfLoops()) {
        //LoopBound loopBound = g.getLoopBound(hol, ctx.getCallString());
        LoopBound loopBound = ctx.getWCETTool().getLoopBound(hol, ctx.getCallString());
        if (loopBound == null) {
            throw new AppInfoError("No loop bound record for head of loop: " + hol + " : " + g.buildLoopBoundMap());
        }
        for (LinearConstraint<IPETBuilder.ExecutionEdge> loopConstraint : constraintsForLoop(loops, hol, loopBound, ctx)) {
            constraints.add(loopConstraint);
        }
    }
    return constraints;
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) LoopBound(com.jopdesign.common.code.LoopBound) ArrayList(java.util.ArrayList) ExecutionEdge(com.jopdesign.wcet.ipet.IPETBuilder.ExecutionEdge) AppInfoError(com.jopdesign.common.misc.AppInfoError) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge)

Example 13 with AppInfoError

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

the class AppInfo method updateChecksum.

private static void updateChecksum(MethodInfo mi, MessageDigest md) {
    if (md == null)
        return;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(bos);
    try {
        writer.append(mi.getFQMethodName());
        writer.close();
    } catch (IOException e) {
        throw new AppInfoError(e);
    }
    md.update(bos.toByteArray());
    // finally, also add the code
    md.update(mi.getCode().getInstructionList().getByteCode());
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) AppInfoError(com.jopdesign.common.misc.AppInfoError)

Example 14 with AppInfoError

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

the class MethodCode method copyLineNumbers.

private void copyLineNumbers(MethodInfo sourceInfo, InstructionHandle to, InstructionHandle from) {
    // TODO should we make this public?
    MethodCode srcCode = sourceInfo != null ? sourceInfo.getCode() : this;
    if (srcCode == null) {
        throw new AppInfoError("Invalid operation: cannot copy line numbers from method without code");
    }
    String source = (String) from.getAttribute(KEY_SOURCECLASS);
    if (source != null) {
        int line = (Integer) from.getAttribute(KEY_LINENUMBER);
        if (source.equals(getClassInfo().getClassName())) {
            setLineNumber(to, line);
        } else {
            to.addAttribute(KEY_SOURCECLASS, source);
            to.addAttribute(KEY_LINENUMBER, line);
        }
        return;
    }
    LineNumberGen entry = srcCode.getLineNumberEntry(from, false);
    if (entry != null) {
        int line = entry.getSourceLine();
        source = srcCode.getClassInfo().getClassName();
        if (source.equals(getClassInfo().getClassName())) {
            setLineNumber(to, line);
        } else {
            to.addAttribute(KEY_SOURCECLASS, source);
            to.addAttribute(KEY_LINENUMBER, line);
        }
    }
}
Also used : LineNumberGen(org.apache.bcel.generic.LineNumberGen) HashedString(com.jopdesign.common.misc.HashedString) CallString(com.jopdesign.common.code.CallString) AppInfoError(com.jopdesign.common.misc.AppInfoError)

Example 15 with AppInfoError

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

the class AppInfo method updateCheckSum.

private void updateCheckSum(ConstantPool cp, MessageDigest md) {
    if (md == null)
        return;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    try {
        cp.dump(dos);
    } catch (IOException e) {
        logger.error("Dumping the constant pool (checksum calculation) failed: " + e.getMessage());
        throw new AppInfoError(e);
    }
    md.update(bos.toByteArray());
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) 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