use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class ObjectCacheAnalysis method getSaturatedTypes.
/**
* Traverse vertex set. Collect those types where we could not resolve
* the symbolic object names. (Not too useful in the analysis, but useful
* for debugging)
*/
public HashSet<String> getSaturatedTypes(Segment segment, LocalPointsToResult usedRefs) {
HashSet<String> topTypes = new HashSet<String>();
for (SuperGraphNode n : segment.getNodes()) {
BasicBlock bb = n.getCFGNode().getBasicBlock();
if (bb == null)
continue;
CallString cs = n.getContextCFG().getCallString();
for (InstructionHandle ih : bb.getInstructions()) {
BoundedSet<SymbolicAddress> refs;
if (usedRefs.containsKey(ih)) {
refs = usedRefs.get(ih, cs);
String handleType = getHandleType(project, n.getCfg(), ih);
if (handleType == null)
continue;
if (refs.isSaturated()) {
topTypes.add(handleType);
}
}
}
}
return topTypes;
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class WCETTool method getInfeasibleEdges.
/**
* Get infeasible edges for certain call string
*
* @param cfg the controlflowgraph of the method
* @param cs the callstring of the method
* @return The infeasible edges
*/
public List<CFGEdge> getInfeasibleEdges(ControlFlowGraph cfg, CallString cs) {
List<CFGEdge> edges = new ArrayList<CFGEdge>();
for (BasicBlock b : cfg.getBlocks()) {
List<CFGEdge> edge = dfaInfeasibleEdge(cfg, b, cs);
edges.addAll(edge);
}
return edges;
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class WCETNodeLabeller method addNodeLabel.
@Override
protected void addNodeLabel(BasicBlockNode n, StringBuilder nodeInfo) {
BasicBlock codeBlock = n.getBasicBlock();
nodeInfo.append(project.getWCETProcessorModel().basicBlockWCET(new ExecutionContext(codeBlock.getMethodInfo()), codeBlock) + " Cyc, ");
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class ConstantCache method build.
public ConstantCache build() {
List<MethodInfo> methods = project.getCallGraph().getReachableImplementations(project.getTargetMethod());
for (int i = methods.size() - 1; i >= 0; i--) {
MethodInfo mi = methods.get(i);
ControlFlowGraph cfg = project.getFlowGraph(mi);
for (CFGNode n : cfg.vertexSet()) {
BasicBlock bb = n.getBasicBlock();
if (bb == null)
continue;
for (InstructionHandle ii : bb.getInstructions()) {
extractConstantAddresses(cfg, ii);
}
}
}
return this;
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class ObjectCacheAnalysis method extractAccessesAndCosts.
/**
* Traverse vertex set.
* <p>Add vertex to access set of referenced addresses
* For references whose type cannot be fully resolved, add a
* cost of 1.</p>
* <p>FIXME: We should deal with subtyping (or better use storage based alias-analysis)</p>
*
* @param nodes
* @param usedRefs the results of the local points-to analysis, or {@code null} for always miss costs
* @param costModel
*/
private AccessCostInfo extractAccessesAndCosts(Iterable<SuperGraphNode> nodes, LocalPointsToResult usedRefs, ObjectCacheCostModel costModel) {
AccessCostInfo aci = new AccessCostInfo();
for (SuperGraphNode node : nodes) {
/* Compute cost for basic block */
BasicBlock bb = node.getCFGNode().getBasicBlock();
if (bb == null)
continue;
long bypassCost = 0;
long alwaysMissCost = 0;
CallString cs = node.getContextCFG().getCallString();
for (InstructionHandle ih : bb.getInstructions()) {
String handleType = getHandleType(project, node.getCfg(), ih);
if (handleType == null)
continue;
/* No getfield/handle access */
int fieldIndex = getFieldIndex(project, node.getCfg(), ih);
int blockIndex = getBlockIndex(fieldIndex);
if (fieldIndex > this.maxCachedFieldIndex) {
bypassCost += costModel.getFieldAccessCostBypass();
continue;
}
BoundedSet<SymbolicAddress> refs = null;
if (usedRefs != null) {
if (!usedRefs.containsKey(ih)) {
usedRefs = null;
WCETTool.logger.error("No DFA results for: " + ih.getInstruction() + " with field " + ((FieldInstruction) ih.getInstruction()).getFieldName(bb.cpg()));
} else {
refs = usedRefs.get(ih, cs);
if (refs.isSaturated())
refs = null;
}
}
if (refs == null) {
alwaysMissCost += costModel.getReplaceLineCost() + costModel.getLoadCacheBlockCost();
} else {
for (SymbolicAddress ref : refs.getSet()) {
aci.addRefAccess(ref, node);
aci.addBlockAccess(ref.accessArray(blockIndex), node);
// Handle getfield_long / getfield_double
if (getCachedType(project, node.getCfg(), ih) == Type.LONG || getCachedType(project, node.getCfg(), ih) == Type.DOUBLE) {
if (blockIndex + 1 > this.maxCachedFieldIndex) {
bypassCost += costModel.getFieldAccessCostBypass();
} else {
aci.addBlockAccess(ref.accessArray(blockIndex + 1), node);
}
}
}
}
}
aci.putBypassCost(node, bypassCost);
aci.putStaticCost(node, bypassCost + alwaysMissCost);
}
return aci;
}
Aggregations