Search in sources :

Example 1 with Candidate

use of com.jopdesign.jcopter.greedy.Candidate in project jop by jop-devel.

the class InlineOptimizer method findCandidates.

@Override
public Collection<Candidate> findCandidates(MethodInfo method, AnalysisManager analyses, StacksizeAnalysis stacksize, int maxLocals, InstructionHandle start, InstructionHandle end) {
    List<Candidate> candidates = new LinkedList<Candidate>();
    MethodCode code = method.getCode();
    InstructionHandle next = end.getNext();
    for (InstructionHandle ih = start; ih != next; ih = ih.getNext()) {
        if (code.isInvokeSite(ih)) {
            InvokeSite site = code.getInvokeSite(ih);
            // since we update the appInfo callgraph, the callstring only contains the invokesite and no
            // inlined methods
            CallString cs = new CallString(site);
            countInvokeSites++;
            MethodInfo invokee = helper.devirtualize(cs);
            if (invokee == null)
                continue;
            countDevirtualized++;
            // for the initial check and the DFA lookup we need the old callstring
            cs = getInlineCallString(code, ih).push(site);
            Candidate candidate = checkInvoke(code, cs, site, invokee, maxLocals);
            if (candidate == null) {
                continue;
            }
            // initial check for locals and stack, calculate gain and codesize
            if (!candidate.recalculate(analyses, stacksize)) {
                continue;
            }
            candidates.add(candidate);
        }
    }
    return candidates;
}
Also used : Candidate(com.jopdesign.jcopter.greedy.Candidate) MethodInfo(com.jopdesign.common.MethodInfo) InvokeSite(com.jopdesign.common.code.InvokeSite) MethodCode(com.jopdesign.common.MethodCode) LinkedList(java.util.LinkedList) InstructionHandle(org.apache.bcel.generic.InstructionHandle) CallString(com.jopdesign.common.code.CallString)

Aggregations

MethodCode (com.jopdesign.common.MethodCode)1 MethodInfo (com.jopdesign.common.MethodInfo)1 CallString (com.jopdesign.common.code.CallString)1 InvokeSite (com.jopdesign.common.code.InvokeSite)1 Candidate (com.jopdesign.jcopter.greedy.Candidate)1 LinkedList (java.util.LinkedList)1 InstructionHandle (org.apache.bcel.generic.InstructionHandle)1