use of com.jopdesign.dfa.DFATool in project jop by jop-devel.
the class CallStringReceiverTypes method doInvokeVirtual.
private void doInvokeVirtual(String receiver, MethodInfo method, InstructionHandle stmt, Context context, ContextMap<CallString, Set<TypeMapping>> input, Interpreter<CallString, Set<TypeMapping>> interpreter, Map<InstructionHandle, ContextMap<CallString, Set<TypeMapping>>> state, ContextMap<CallString, Set<TypeMapping>> result) {
String methodImplName = method.getClassName() + "." + method.getMethodSignature();
recordReceiver(stmt, context, methodImplName);
// LineNumberTable lines = p.getMethods().get(context.method).getLineNumberTable(context.constPool);
// int sourceLine = lines.getSourceLine(stmt.getPosition());
// String invokeId = context.method+"\t"+":"+sourceLine+"."+stmt.getPosition();
// set up new context
int varPtr = context.stackPtr - MethodHelper.getArgSize(method);
Context c = new Context(context);
c.stackPtr = method.getCode().getMaxLocals();
if (method.isSynchronized()) {
c.syncLevel = context.syncLevel + 1;
}
c.setMethodInfo(method);
c.callString = c.callString.push(context.getMethodInfo(), stmt, callStringLength);
boolean threaded = false;
DFATool p = interpreter.getDFATool();
if (p.getAppInfo().getClassInfo(receiver).isSubclassOf(p.getAppInfo().getClassInfo("joprt.RtThread")) && "run()V".equals(method.getMethodSignature())) {
c.createThread();
threaded = true;
}
// carry only minimal information with call
Set<TypeMapping> in = input.get(context.callString);
Set<TypeMapping> out = new LinkedHashSet<TypeMapping>();
ContextMap<CallString, Set<TypeMapping>> tmpresult = new ContextMap<CallString, Set<TypeMapping>>(c, new LinkedHashMap<CallString, Set<TypeMapping>>());
tmpresult.put(c.callString, out);
for (TypeMapping m : in) {
if (m.stackLoc < 0) {
out.add(m);
}
if (m.stackLoc > varPtr) {
out.add(new TypeMapping(m.stackLoc - varPtr, m.type));
}
if (m.stackLoc == varPtr) {
// add "this"
ClassInfo staticClass = p.getAppInfo().getClassInfo(receiver);
ClassInfo dynamicClass = null;
try {
dynamicClass = p.getAppInfo().getClassInfo(m.type.split("@")[0]);
} catch (MissingClassError ex) {
logger.error("doInvokeVirtual - trying to improve type of " + staticClass + ": " + ex);
// TODO: maybe we should throw an exception/error instead?
}
if (dynamicClass != null && dynamicClass.isSubclassOf(staticClass)) {
out.add(new TypeMapping(0, m.type));
}
}
}
InstructionHandle entry = p.getEntryHandle(method);
state.put(entry, join(state.get(entry), tmpresult));
// interpret method
Map<InstructionHandle, ContextMap<CallString, Set<TypeMapping>>> r = interpreter.interpret(c, entry, state, false);
// pull out relevant information from call
InstructionHandle exit = p.getExitHandle(method);
if (r.get(exit) != null) {
Set<TypeMapping> returned = r.get(exit).get(c.callString);
if (returned != null) {
filterReturnSet(returned, result.get(context.callString), varPtr);
}
}
// update all threads
if (threaded) {
threads.put(methodImplName, new ContextMap<CallString, Set<TypeMapping>>(c, result));
updateThreads(result, interpreter, state);
}
}
use of com.jopdesign.dfa.DFATool in project jop by jop-devel.
the class PhaseExecutor method dataflowAnalysis.
/////////////////////////////////////////////////////////////////////////////////////
// Perform analyses
/////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
public void dataflowAnalysis(boolean loopBounds) {
int callstringLength = appInfo.getCallstringLength();
// TODO this code is the same as in WCETTool ..
DFATool dfaTool = jcopter.getDfaTool();
logger.info("Starting DFA analysis");
dfaTool.setAnalyzeBootMethod(true);
dfaTool.load();
logger.info("Receiver analysis");
dfaTool.runReceiverAnalysis(callstringLength);
if (loopBounds) {
logger.info("Loop bound analysis");
dfaTool.runLoopboundAnalysis(callstringLength);
// need to tell this to the WCA tool
if (jcopter.useWCA()) {
jcopter.getWcetTool().setHasDfaResults(true);
}
}
dfaTool.cleanup();
}
use of com.jopdesign.dfa.DFATool in project jop by jop-devel.
the class UppAalAnalysis method main.
public static void main(String[] args) {
// We set a different output path for this tool if invoked by cmdline
// Note that WCETTool could also override defaults, but we do not want to change the
// default value of outdir if WCETTool is invoked from another tool
Properties defaultProps = new Properties();
defaultProps.put("outdir", "java/target/wcet/${projectname}");
AppSetup setup = new AppSetup(defaultProps, false);
setup.setVersionInfo("1.0 [deprecated]");
// We do not load a config file automatically, user has to specify it explicitly to avoid
// unintentional misconfiguration
//setup.setConfigFilename(CONFIG_FILE_NAME);
setup.setUsageInfo("UppAllAnalysis", "UppAll WCET Analysis");
WCETTool wcetTool = new WCETTool();
DFATool dfaTool = new DFATool();
setup.registerTool("dfa", dfaTool, true, false);
setup.registerTool("wcet", wcetTool);
@SuppressWarnings("unused") AppInfo appInfo = setup.initAndLoad(args, true, false, false);
if (setup.useTool("dfa")) {
wcetTool.setDfaTool(dfaTool);
}
ExecHelper exec = new ExecHelper(setup.getConfig(), tlLogger);
exec.dumpConfig();
UppAalAnalysis inst = new UppAalAnalysis(wcetTool);
/* run */
if (!inst.run(exec))
exec.bail("UppAal translation failed");
tlLogger.info("UppAal translation finished");
}
Aggregations