Search in sources :

Example 1 with Interpreter

use of com.jopdesign.dfa.framework.Interpreter in project jop by jop-devel.

the class DFATool method runLocalAnalysis.

public <K, V> Map runLocalAnalysis(Analysis<K, V> localAnalysis, ExecutionContext scope) {
    Interpreter<K, V> interpreter = new Interpreter<K, V>(localAnalysis, this);
    if (scope == null)
        throw new AssertionError("No such method: " + scope);
    Context context = new Context();
    MethodCode entryCode = scope.getMethodInfo().getCode();
    context.stackPtr = entryCode.getMaxLocals();
    context.setMethodInfo(scope.getMethodInfo());
    context.setCallString(scope.getCallString());
    localAnalysis.initialize(scope.getMethodInfo(), context);
    /* Here used to be a extremely-hard-to-trackdown bug!
         * Without the boolean parameters, getInstructionList() will dispose
         * the CFG, a very bad idea during WCET analysis which relies on
         * pointer equality for CFG edges :(
         */
    InstructionHandle entry = entryCode.getInstructionList(false, false).getStart();
    interpreter.interpret(context, entry, new LinkedHashMap<InstructionHandle, ContextMap<K, V>>(), true);
    return localAnalysis.getResult();
}
Also used : Context(com.jopdesign.dfa.framework.Context) ExecutionContext(com.jopdesign.common.code.ExecutionContext) Interpreter(com.jopdesign.dfa.framework.Interpreter) MethodCode(com.jopdesign.common.MethodCode) InstructionHandle(org.apache.bcel.generic.InstructionHandle) ContextMap(com.jopdesign.dfa.framework.ContextMap)

Example 2 with Interpreter

use of com.jopdesign.dfa.framework.Interpreter in project jop by jop-devel.

the class DFATool method runAnalysis.

@SuppressWarnings("unchecked")
public Map runAnalysis(Analysis analysis) {
    /* use cached results if possible */
    Map results;
    if ((results = getCachedResults(analysis)) != null) {
        logger.warn("Analysis " + analysis.getId() + ": Using cached DFA analysis results");
        return results;
    }
    Interpreter interpreter = new Interpreter(analysis, this);
    MethodInfo main = appInfo.getMainMethod();
    MethodInfo prologue = main.getClassInfo().getMethodInfo(prologueName + prologueSig);
    Context context = new Context();
    context.stackPtr = 0;
    context.syncLevel = 0;
    context.setMethodInfo(prologue);
    analysis.initialize(main, context);
    InstructionHandle entry = prologue.getCode().getInstructionList().getStart();
    interpreter.interpret(context, entry, new LinkedHashMap(), true);
    /* cache results if requested */
    writeCachedResults(analysis);
    return analysis.getResult();
}
Also used : Context(com.jopdesign.dfa.framework.Context) ExecutionContext(com.jopdesign.common.code.ExecutionContext) Interpreter(com.jopdesign.dfa.framework.Interpreter) MethodInfo(com.jopdesign.common.MethodInfo) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ContextMap(com.jopdesign.dfa.framework.ContextMap) InstructionHandle(org.apache.bcel.generic.InstructionHandle) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ExecutionContext (com.jopdesign.common.code.ExecutionContext)2 Context (com.jopdesign.dfa.framework.Context)2 ContextMap (com.jopdesign.dfa.framework.ContextMap)2 Interpreter (com.jopdesign.dfa.framework.Interpreter)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)2 MethodCode (com.jopdesign.common.MethodCode)1 MethodInfo (com.jopdesign.common.MethodInfo)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1