Search in sources :

Example 1 with AppInfo

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

the class AppLoader method processClassName.

private int processClassName(String className) {
    AppInfo appInfo = AppInfo.getSingleton();
    int cnt = 0;
    ClassInfo cls;
    if (appInfo.hasClassInfo(className)) {
        cls = appInfo.getClassInfo(className);
    } else {
        cls = appInfo.loadClass(className);
        if (cls != null) {
            newClasses.add(cls);
            cnt++;
        }
    }
    if (cls != null) {
        enqueue(cls);
    }
    return cnt;
}
Also used : AppInfo(com.jopdesign.common.AppInfo) ClassInfo(com.jopdesign.common.ClassInfo)

Example 2 with AppInfo

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

the class TypeGraphTool method main.

public static void main(String[] args) {
    // setup some defaults, initialize without any per-program defaults
    AppSetup setup = new AppSetup();
    setup.setUsageInfo("typegraph", "This is tool to examine the type graph.");
    setup.setVersionInfo("The version of this whole application is 0.1");
    // set the name of the (optional) user-provided config file
    setup.setConfigFilename("typegraph.properties");
    TypeGraphTool typeGraph = new TypeGraphTool();
    setup.registerTool("typegraph", typeGraph);
    AppInfo appInfo = setup.initAndLoad(args, false, true, true);
    typeGraph.run(setup.getConfig());
}
Also used : AppSetup(com.jopdesign.common.AppSetup) AppInfo(com.jopdesign.common.AppInfo)

Example 3 with AppInfo

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

the class SuperGraphTest method main.

public static void main(String[] args) {
    TestFramework testFramework = new TestFramework();
    AppSetup setup = testFramework.setupAppSetup("java/tools/test/test/cg1.zip", null);
    AppInfo appInfo = testFramework.setupAppInfo("wcet.devel.CallGraph1.run", true);
    SuperGraphTest testInst = new SuperGraphTest();
    testInst.appInfo = appInfo;
    MethodInfo mainMethod = appInfo.getMainMethod();
    SuperGraph sg0 = new SuperGraph(testInst, testInst.getFlowGraph(mainMethod), 0);
    try {
        testInst.getFlowGraph(mainMethod).exportDOT(new File("/tmp/cg1-run.dot"));
        sg0.exportDOT(new File("/tmp/cg1-super0.dot"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    SuperGraph sg2 = new SuperGraph(testInst, testInst.getFlowGraph(mainMethod), 2);
    try {
        FileWriter fw = new FileWriter("/tmp/cg1-super2.dot");
        sg2.exportDOT(new File("/tmp/cg1-super2.dot"));
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : TestFramework(com.jopdesign.common.TestFramework) FileWriter(java.io.FileWriter) AppSetup(com.jopdesign.common.AppSetup) MethodInfo(com.jopdesign.common.MethodInfo) IOException(java.io.IOException) File(java.io.File) AppInfo(com.jopdesign.common.AppInfo)

Example 4 with AppInfo

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

the class ConstantCache method addStaticFieldAddress.

private void addStaticFieldAddress(ControlFlowGraph cfg, FieldInstruction fii) {
    AppInfo appInfo = cfg.getAppInfo();
    ConstantPoolGen cpg = cfg.getMethodInfo().getConstantPoolGen();
    String fieldName = fii.getFieldName(cpg) + fii.getSignature(cpg);
    Integer address = project.getLinkerInfo().getStaticFieldAddress(((ObjectType) fii.getReferenceType(cpg)).getClassName(), fieldName);
    addAddress(staticAddressMap, cfg.getMethodInfo(), address);
}
Also used : ConstantPoolGen(org.apache.bcel.generic.ConstantPoolGen) AppInfo(com.jopdesign.common.AppInfo)

Example 5 with AppInfo

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

the class InvokeSite method getInvokeeRef.

/**
 * Get the MethodRef to the referenced method. If the instruction is handled in java, return a reference
 * to the method which implements the instruction.
 * <p>
 * The MethodRef refers to the actual reference. {@link MethodRef#getMethodInfo()} resolves the actual
 * MethodInfo, which might be defined in a super class of the referenced method, if the method is inherited.
 * For invokespecial, the implementing method might even be defined in a subclass of the referenced method,
 * if resolveSuper is set to false, see {@link #isInvokeSuper()} for details.
 * </p>
 * <p>To find all possible implementations if the invocation is a virtual invoke (see {@link #isVirtual()}),
 * use {@link AppInfo#findImplementations(InvokeSite)}.</p>
 *
 * @see #isInvokeSuper()
 * @see AppInfo#findImplementations(InvokeSite)
 * @param resolveSuper if true, try to resolve the super method reference (see {@link #isInvokeSuper()}),
 *                     else return a reference to the method as it is defined by the instruction.
 * @return a method reference to the invokee method.
 */
public MethodRef getInvokeeRef(boolean resolveSuper) {
    Instruction instr = instruction.getInstruction();
    AppInfo appInfo = AppInfo.getSingleton();
    if (instr instanceof InvokeInstruction) {
        MethodRef ref = getReferencedMethod(invoker, (InvokeInstruction) instr);
        // need to check isInvokeSpecial here, since it is not checked by isSuperMethod!
        if (resolveSuper && isInvokeSpecial() && isSuperMethod(ref)) {
            ref = resolveInvokeSuper(ref);
        }
        return ref;
    }
    if (appInfo.getProcessorModel().isImplementedInJava(invoker, instr)) {
        return appInfo.getProcessorModel().getJavaImplementation(appInfo, invoker, instr).getMethodRef();
    }
    throw new JavaClassFormatError("InvokeSite handle does not refer to an invoke instruction: " + toString());
}
Also used : InvokeInstruction(org.apache.bcel.generic.InvokeInstruction) MethodRef(com.jopdesign.common.type.MethodRef) JavaClassFormatError(com.jopdesign.common.misc.JavaClassFormatError) InvokeInstruction(org.apache.bcel.generic.InvokeInstruction) Instruction(org.apache.bcel.generic.Instruction) AppInfo(com.jopdesign.common.AppInfo)

Aggregations

AppInfo (com.jopdesign.common.AppInfo)21 AppSetup (com.jopdesign.common.AppSetup)7 ClassInfo (com.jopdesign.common.ClassInfo)7 MethodInfo (com.jopdesign.common.MethodInfo)7 File (java.io.File)4 IOException (java.io.IOException)4 TestFramework (com.jopdesign.common.TestFramework)3 JavaClassFormatError (com.jopdesign.common.misc.JavaClassFormatError)2 FileWriter (java.io.FileWriter)2 LinkedHashSet (java.util.LinkedHashSet)2 FieldInfo (com.jopdesign.common.FieldInfo)1 MethodCode (com.jopdesign.common.MethodCode)1 CallGraph (com.jopdesign.common.code.CallGraph)1 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)1 InvokeNode (com.jopdesign.common.code.ControlFlowGraph.InvokeNode)1 ExecutionContext (com.jopdesign.common.code.ExecutionContext)1 InvokeSite (com.jopdesign.common.code.InvokeSite)1 SuperGraph (com.jopdesign.common.code.SuperGraph)1 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)1 SuperEdge (com.jopdesign.common.code.SuperGraph.SuperEdge)1