Search in sources :

Example 56 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class InstalledCodeBuilder method writeObjectConstantsToCode.

@Uninterruptible(reason = "Operates on raw pointers to objects")
private void writeObjectConstantsToCode(ObjectConstantsHolder objectConstants) {
    boolean compressed = ReferenceAccess.singleton().haveCompressedReferences();
    Pointer constantsStart = code.add(constantsOffset);
    for (int i = 0; i < objectConstants.count; i++) {
        Pointer address = constantsStart.add(objectConstants.offsets[i]);
        ReferenceAccess.singleton().writeObjectAt(address, objectConstants.values[i], compressed);
    }
    /* From now on the constantsWalker will operate on the constants area. */
    constantsWalker.pointerMapValid = true;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) Infopoint(jdk.vm.ci.code.site.Infopoint) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 57 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class InstalledCodeBuilder method allocateOSMemory.

/**
 * A tracing wrapper around getOSInterface().allocateVirtualMemory.
 */
protected Pointer allocateOSMemory(final UnsignedWord size, final boolean executable) {
    final Log trace = Log.noopLog();
    trace.string("[SubstrateInstalledCode.allocateAlignedMemory:");
    trace.string("  size: ").unsigned(size);
    trace.string("  executable: ").bool(executable);
    final Pointer result = ConfigurationValues.getOSInterface().allocateVirtualMemory(size, executable);
    trace.string("  returns: ").hex(result);
    trace.string("]").newline();
    return result;
}
Also used : Log(com.oracle.svm.core.log.Log) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer)

Example 58 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class PosixAMD64VaListSnippets method vaArgDoubleSnippet.

@Snippet
protected static double vaArgDoubleSnippet(Pointer vaList) {
    int fpOffset = vaList.readInt(FP_OFFSET_LOCATION);
    if (fpOffset < MAX_FP_OFFSET) {
        Pointer regSaveArea = vaList.readWord(REG_SAVE_AREA_LOCATION);
        double v = regSaveArea.readDouble(fpOffset);
        // 16-byte XMM register
        vaList.writeInt(FP_OFFSET_LOCATION, fpOffset + 16);
        return v;
    } else {
        Pointer overflowArgArea = vaList.readWord(OVERFLOW_ARG_AREA_LOCATION);
        double v = overflowArgArea.readDouble(0);
        vaList.writeWord(OVERFLOW_ARG_AREA_LOCATION, overflowArgArea.add(OVERFLOW_ARG_AREA_ALIGNMENT));
        return v;
    }
}
Also used : Pointer(org.graalvm.word.Pointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 59 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class ExceptionStateNode method unwindSnippet.

@Snippet
protected static void unwindSnippet(Throwable exception) {
    Pointer callerSP = readCallerStackPointer();
    CodePointer callerIP = readReturnAddress();
    runtimeCall(UNWIND_EXCEPTION, exception, callerSP, callerIP);
    throw unreachable();
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 60 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class PointerUtils method absoluteDifference.

/**
 * Return the distance between two Pointers.
 *
 * @param pointer1 A first Pointer.
 * @param pointer2 A second Pointer.
 * @return The distance in bytes between the two Pointers.
 */
public static UnsignedWord absoluteDifference(PointerBase pointer1, PointerBase pointer2) {
    Pointer p1 = (Pointer) pointer1;
    Pointer p2 = (Pointer) pointer2;
    final UnsignedWord result;
    if (p1.aboveOrEqual(p2)) {
        result = p1.subtract(p2);
    } else {
        result = p2.subtract(p1);
    }
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Aggregations

Pointer (org.graalvm.word.Pointer)103 UnsignedWord (org.graalvm.word.UnsignedWord)45 Log (com.oracle.svm.core.log.Log)30 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)17 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)15 Snippet (org.graalvm.compiler.api.replacements.Snippet)14 Word (org.graalvm.compiler.word.Word)12 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)9 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)7 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)5 NeverInline (com.oracle.svm.core.annotate.NeverInline)5 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)5 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)4 DynamicHub (com.oracle.svm.core.hub.DynamicHub)3 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)3 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)3 SignedWord (org.graalvm.word.SignedWord)3 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)2 Dirent.direntPointer (com.oracle.svm.core.posix.headers.Dirent.direntPointer)2