Search in sources :

Example 21 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod 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 22 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class MustNotSynchronizeAnnotationChecker method postMustNotSynchronizeWarning.

private void postMustNotSynchronizeWarning() throws WarningException {
    final HostedMethod blacklistMethod = methodPath.getLast();
    String message = "@MustNotSynchronize warning: ";
    if (methodPath.size() == 1) {
        message += "Blacklisted method: " + blacklistMethod.format("%h.%n(%p)") + " synchronizes.";
    } else {
        final HostedMethod witness = methodPath.getFirst();
        message += "Blacklisted method: " + blacklistMethod.format("%h.%n(%p)") + " calls " + witness.format("%h.%n(%p)") + " that synchronizes.";
    }
    if (Options.PrintMustNotSynchronizeWarnings.getValue()) {
        System.err.println(message);
        if (Options.PrintMustNotSynchronizePath.getValue() && (1 < methodPath.size())) {
            printPath();
        }
    }
    if (Options.MustNotSynchronizeWarningsAreFatal.getValue()) {
        throw new WarningException(message);
    }
}
Also used : HostedMethod(com.oracle.svm.hosted.meta.HostedMethod)

Example 23 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class NativeBootImage method writeHeaderFile.

void writeHeaderFile(Path outFile, String imageName, boolean dynamic) {
    List<HostedMethod> methodsWithHeader = uniqueEntryPoints.stream().filter(this::shouldWriteHeader).collect(Collectors.toList());
    methodsWithHeader.sort(NativeBootImage::sortMethodsByFileNameAndPosition);
    if (methodsWithHeader.size() > 0) {
        CSourceCodeWriter writer = new CSourceCodeWriter(outFile.getParent());
        String imageHeaderGuard = "__" + imageName.toUpperCase().replaceAll("[^A-Z0-9]", "_") + "_H";
        writer.appendln("#ifndef " + imageHeaderGuard);
        writer.appendln("#define " + imageHeaderGuard);
        String preamblePath = NativeImageOptions.PreamblePath.getValue();
        if (preamblePath != null) {
            NativeImageHeaderPreamble.read(preamblePath).forEach(writer::appendln);
        } else {
            writer.appendln("#include <" + DEFAULT_HEADER_FILE_NAME + ">");
        }
        if (NativeImageOptions.getCStandard() != CStandards.C89) {
            writer.appendln("#include <stdbool.h>");
        }
        writer.appendln("#if defined(__cplusplus)");
        writer.appendln("extern \"C\" {");
        writer.appendln("#endif");
        methodsWithHeader.forEach(m -> writeMethodHeader(m, writer, dynamic));
        writer.appendln("#if defined(__cplusplus)");
        writer.appendln("}");
        writer.appendln("#endif");
        writer.appendln("#endif");
        writer.writeFile(outFile.getFileName().toString(), false);
    }
}
Also used : HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) CSourceCodeWriter(com.oracle.svm.hosted.c.codegen.CSourceCodeWriter)

Example 24 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class NativeBootImage method markFunctionRelocationSite.

private static void markFunctionRelocationSite(final ProgbitsSectionImpl sectionImpl, final int offset, final RelocatableBuffer.Info info) {
    assert info.getTargetObject() instanceof CFunctionPointer : "Wrong type for FunctionPointer relocation: " + info.getTargetObject().toString();
    final int functionPointerRelocationSize = 8;
    assert info.getRelocationSize() == functionPointerRelocationSize : "Function relocation: " + info.getRelocationSize() + " should be " + functionPointerRelocationSize + " bytes.";
    // References to functions are via relocations to the symbol for the function.
    HostedMethod method = ((MethodPointer) info.getTargetObject()).getMethod();
    // A reference to a method. Mark the relocation site using the symbol name.
    sectionImpl.markRelocationSite(offset, functionPointerRelocationSize, RelocationKind.DIRECT, localSymbolNameForMethod(method), false, 0L);
}
Also used : MethodPointer(com.oracle.svm.hosted.meta.MethodPointer) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer)

Example 25 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class NativeImageCodeCache method verifyDeoptEntries.

private void verifyDeoptEntries(ImageCodeInfo imageCodeInfo) {
    boolean hasError = false;
    List<Entry<AnalysisMethod, Set<Long>>> deoptEntries = new ArrayList<>(CompilationInfoSupport.singleton().getDeoptEntries().entrySet());
    deoptEntries.sort((e1, e2) -> e1.getKey().format("%H.%n(%p)").compareTo(e2.getKey().format("%H.%n(%p)")));
    for (Map.Entry<AnalysisMethod, Set<Long>> entry : deoptEntries) {
        HostedMethod method = imageHeap.getUniverse().lookup(entry.getKey());
        List<Long> encodedBcis = new ArrayList<>(entry.getValue());
        encodedBcis.sort((v1, v2) -> Long.compare(v1, v2));
        for (long encodedBci : encodedBcis) {
            hasError |= verifyDeoptEntry(imageCodeInfo, method, encodedBci);
        }
    }
    if (hasError) {
        VMError.shouldNotReachHere("Verification of deoptimization entry points failed");
    }
}
Also used : Entry(java.util.Map.Entry) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) Set(java.util.Set) ArrayList(java.util.ArrayList) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) HashMap(java.util.HashMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap)

Aggregations

HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)32 DebugContext (org.graalvm.compiler.debug.DebugContext)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 CompilationResult (org.graalvm.compiler.code.CompilationResult)8 Invoke (org.graalvm.compiler.nodes.Invoke)8 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)7 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)7 Infopoint (jdk.vm.ci.code.site.Infopoint)7 Indent (org.graalvm.compiler.debug.Indent)6 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)5 HostedOptionValues (com.oracle.svm.core.option.HostedOptionValues)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Call (jdk.vm.ci.code.site.Call)5 GraalError (org.graalvm.compiler.debug.GraalError)5 OptionValues (org.graalvm.compiler.options.OptionValues)5 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)4 SubstrateIntrinsicGraphBuilder (com.oracle.graal.pointsto.phases.SubstrateIntrinsicGraphBuilder)4 Timer (com.oracle.graal.pointsto.util.Timer)4