Search in sources :

Example 1 with VisitResult

use of com.oracle.svm.hosted.code.AnalysisMethodCalleeWalker.CallPathVisitor.VisitResult in project graal by oracle.

the class AnalysisMethodCalleeWalker method walkMethod.

/**
 * Walk a method by applying a visitor to the method and all of its callees. Returns true if all
 * the visits returned true, else returns false.
 */
@SuppressWarnings("try")
public boolean walkMethod(AnalysisMethod method, CallPathVisitor visitor) {
    if (visitor.prologue() != VisitResult.CONTINUE) {
        return false;
    }
    /* Initialize the path of callers. */
    path.clear();
    /* Walk the method and callees, but ignore the result. */
    walkMethodAndCallees(method, null, null, visitor);
    final VisitResult epilogueResult = visitor.epilogue();
    return (epilogueResult != VisitResult.CONTINUE);
}
Also used : VisitResult(com.oracle.svm.hosted.code.AnalysisMethodCalleeWalker.CallPathVisitor.VisitResult)

Example 2 with VisitResult

use of com.oracle.svm.hosted.code.AnalysisMethodCalleeWalker.CallPathVisitor.VisitResult in project graal by oracle.

the class AnalysisMethodCalleeWalker method walkMethodAndCallees.

/**
 * Visit this method, and the methods it calls.
 */
VisitResult walkMethodAndCallees(AnalysisMethod method, AnalysisMethod caller, Invoke invoke, CallPathVisitor visitor) {
    if (path.contains(method)) {
        /*
             * If the method is already on the path then I am in the middle of visiting it, so just
             * keep walking.
             */
        return VisitResult.CUT;
    }
    path.add(method);
    try {
        /* Visit the method directly. */
        final VisitResult directResult = visitor.visitMethod(method, caller, invoke, path.size());
        if (directResult != VisitResult.CONTINUE) {
            return directResult;
        }
        /* Visit the callees of this method. */
        final VisitResult calleeResult = walkCallees(method, visitor);
        if (calleeResult != VisitResult.CONTINUE) {
            return calleeResult;
        }
        /* Visit all the implementations of this method, ignoring if any of them says CUT. */
        for (AnalysisMethod impl : method.getImplementations()) {
            walkMethodAndCallees(impl, caller, invoke, visitor);
        }
        return VisitResult.CONTINUE;
    } finally {
        path.remove(method);
    }
}
Also used : AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) VisitResult(com.oracle.svm.hosted.code.AnalysisMethodCalleeWalker.CallPathVisitor.VisitResult)

Aggregations

VisitResult (com.oracle.svm.hosted.code.AnalysisMethodCalleeWalker.CallPathVisitor.VisitResult)2 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1