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 <= 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;
}
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;
}
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());
}
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);
}
}
}
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());
}
Aggregations