Search in sources :

Example 1 with MethodPointer

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

the class NativeImageHeap method addNonDataRelocation.

/**
 * Adds a relocation for a code pointer or other non-data pointers.
 */
private void addNonDataRelocation(RelocatableBuffer buffer, int index, RelocatedPointer pointer) {
    mustBeAligned(index);
    assert pointer instanceof CFunctionPointer : "unknown relocated pointer " + pointer;
    assert pointer instanceof MethodPointer : "cannot create relocation for unknown FunctionPointer " + pointer;
    HostedMethod method = ((MethodPointer) pointer).getMethod();
    if (method.isCodeAddressOffsetValid()) {
        // Only compiled methods inserted in vtables require relocation.
        buffer.addDirectRelocationWithoutAddend(index, objectSize(), pointer);
    }
}
Also used : MethodPointer(com.oracle.svm.hosted.meta.MethodPointer) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer)

Example 2 with MethodPointer

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

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

the class RelocatableBuffer method targetObjectClassification.

protected static String targetObjectClassification(final Object targetObject) {
    final StringBuilder result = new StringBuilder();
    if (targetObject == null) {
        result.append("null");
    } else {
        if (targetObject instanceof CFunctionPointer) {
            result.append("pointer to function");
            if (targetObject instanceof MethodPointer) {
                final MethodPointer mp = (MethodPointer) targetObject;
                final HostedMethod hm = mp.getMethod();
                result.append("  name: ");
                result.append(hm.getName());
            }
        } else {
            result.append("pointer to data");
        }
    }
    return result.toString();
}
Also used : MethodPointer(com.oracle.svm.hosted.meta.MethodPointer) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer)

Aggregations

HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)3 MethodPointer (com.oracle.svm.hosted.meta.MethodPointer)3 CFunctionPointer (org.graalvm.nativeimage.c.function.CFunctionPointer)3