Search in sources :

Example 1 with MustNotSynchronize

use of com.oracle.svm.core.annotate.MustNotSynchronize in project graal by oracle.

the class MustNotSynchronizeAnnotationChecker method checkMethods.

/**
 * Check methods with the {@link MustNotSynchronize} annotation.
 */
@SuppressWarnings("try")
public void checkMethods(DebugContext debug) {
    for (HostedMethod method : methods) {
        try (DebugContext.Scope s = debug.scope("MustNotSynchronizeAnnotationChecker", method.compilationInfo.graph, method, this)) {
            MustNotSynchronize annotation = method.getAnnotation(MustNotSynchronize.class);
            if ((annotation != null) && (annotation.list() == MustNotSynchronize.BLACKLIST)) {
                methodPath.clear();
                methodImplPath.clear();
                try {
                    checkMethod(method, method);
                } catch (WarningException we) {
                    // Clean up the recursive stack trace for Debug.scope.
                    throw new WarningException(we.getMessage());
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
}
Also used : MustNotSynchronize(com.oracle.svm.core.annotate.MustNotSynchronize) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 2 with MustNotSynchronize

use of com.oracle.svm.core.annotate.MustNotSynchronize in project graal by oracle.

the class MustNotSynchronizeAnnotationChecker method checkMethod.

/**
 * Check this method for direct synchronizations or calls to methods that synchronize.
 */
protected boolean checkMethod(HostedMethod method, HostedMethod methodImpl) throws WarningException {
    if (methodImplPath.contains(methodImpl)) {
        // If the method is already on the path then avoid recursion.
        return false;
    }
    MustNotSynchronize annotation = methodImpl.getAnnotation(MustNotSynchronize.class);
    if ((annotation != null) && (annotation.list() == MustNotSynchronize.WHITELIST)) {
        // The method is on the whitelist, so I do not care if it synchronizes.
        return false;
    }
    methodPath.push(method);
    methodImplPath.push(methodImpl);
    try {
        // Check for direct synchronizations.
        if (synchronizesDirectly(methodImpl)) {
            return true;
        }
        if (synchronizesIndirectly(methodImpl)) {
            return true;
        }
        return false;
    } finally {
        methodPath.pop();
        methodImplPath.pop();
    }
}
Also used : MustNotSynchronize(com.oracle.svm.core.annotate.MustNotSynchronize)

Aggregations

MustNotSynchronize (com.oracle.svm.core.annotate.MustNotSynchronize)2 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1