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);
}
}
}
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);
}
}
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);
}
}
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);
}
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");
}
}
Aggregations