Search in sources :

Example 61 with Pointer

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

the class PosixOSInterface method writeBytes0Uninterruptibly.

@Uninterruptible(reason = "byte[] accessed without pinning")
private boolean writeBytes0Uninterruptibly(FileDescriptor descriptor, byte[] bytes, UnsignedWord length, UnsignedWord offsetOfArrayElement) {
    final Pointer addressOfObject = Word.objectToUntrackedPointer(bytes);
    final CCharPointer bytePointer = (CCharPointer) addressOfObject.add(offsetOfArrayElement);
    return writeBytesUninterruptibly(descriptor, bytePointer, length);
}
Also used : Pointer(org.graalvm.word.Pointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 62 with Pointer

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

the class PosixOSInterface method allocateVirtualMemory.

@Override
public Pointer allocateVirtualMemory(UnsignedWord size, boolean executable) {
    trackVirtualMemory(size);
    int protect = PROT_READ() | PROT_WRITE() | (executable ? PROT_EXEC() : 0);
    int flags = MAP_ANON() | MAP_PRIVATE();
    final Pointer result = mmap(WordFactory.nullPointer(), size, protect, flags, -1, 0);
    if (result.equal(MAP_FAILED())) {
        // Turn the mmap failure into a null Pointer.
        return WordFactory.nullPointer();
    }
    return result;
}
Also used : Pointer(org.graalvm.word.Pointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer)

Example 63 with Pointer

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

the class SubstrateUtil method dumpTopFrame.

@NeverInline("catch implicit exceptions")
private static void dumpTopFrame(Log log, Pointer sp, CodePointer ip) {
    log.string("TopFrame info:").newline();
    log.indent(true);
    if (sp.isNonNull() && ip.isNonNull()) {
        long totalFrameSize;
        DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sp);
        if (deoptFrame != null) {
            log.string("RSP ").zhex(sp.rawValue()).string(" frame was deoptimized:").newline();
            log.string("SourcePC ").zhex(deoptFrame.getSourcePC().rawValue()).newline();
            totalFrameSize = deoptFrame.getSourceTotalFrameSize();
        } else {
            log.string("Lookup TotalFrameSize in CodeInfoTable:").newline();
            totalFrameSize = CodeInfoTable.lookupTotalFrameSize(ip);
        }
        log.string("SourceTotalFrameSize ").signed(totalFrameSize).newline();
        if (totalFrameSize == -1) {
            log.string("Does not look like a Java Frame. Use JavaFrameAnchors to find LastJavaSP:").newline();
            JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor();
            while (anchor.isNonNull() && anchor.getLastJavaSP().belowOrEqual(sp)) {
                anchor = anchor.getPreviousAnchor();
            }
            if (anchor.isNonNull()) {
                log.string("Found matching Anchor:").zhex(anchor.rawValue()).newline();
                Pointer lastSp = anchor.getLastJavaSP();
                log.string("LastJavaSP ").zhex(lastSp.rawValue()).newline();
                CodePointer lastIp = FrameAccess.readReturnAddress(lastSp);
                log.string("LastJavaIP ").zhex(lastIp.rawValue()).newline();
            }
        }
    }
    log.indent(false);
}
Also used : JavaFrameAnchor(com.oracle.svm.core.stack.JavaFrameAnchor) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) DeoptimizedFrame(com.oracle.svm.core.deopt.DeoptimizedFrame) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 64 with Pointer

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

the class PosixJavaLangSubstitutions method writeEntirely.

@Uninterruptible(reason = "Called from uninterruptible code.")
static SignedWord writeEntirely(int fd, PointerBase buf, UnsignedWord count) {
    Pointer ptr = WordFactory.pointer(buf.rawValue());
    final Pointer end = ptr.add(count);
    SignedWord written;
    do {
        Errno.set_errno(0);
        written = UnistdNoTransitions.write(fd, ptr, end.subtract(ptr));
        if (written.greaterThan(0)) {
            ptr = ptr.add((int) written.rawValue());
        }
    } while (ptr.notEqual(end) && (written.notEqual(-1) || Errno.errno() == Errno.EINTR()));
    if (ptr.notEqual(buf)) {
        return WordFactory.signed(ptr.rawValue() - buf.rawValue());
    }
    return written;
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) Dirent.direntPointer(com.oracle.svm.core.posix.headers.Dirent.direntPointer) Pointer(org.graalvm.word.Pointer) SignedWord(org.graalvm.word.SignedWord) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 65 with Pointer

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

the class PosixJavaLangSubstitutions method readEntirely.

static SignedWord readEntirely(int fd, PointerBase buf, UnsignedWord count) {
    Pointer ptr = WordFactory.pointer(buf.rawValue());
    final Pointer end = ptr.add(count);
    SignedWord read;
    do {
        Errno.set_errno(0);
        read = Unistd.read(fd, ptr, end.subtract(ptr));
        if (read.equal(0)) {
            // EOF
            break;
        } else if (read.greaterThan(0)) {
            ptr = ptr.add((int) read.rawValue());
        }
    } while (ptr.notEqual(end) && (read.notEqual(-1) || Errno.errno() == Errno.EINTR()));
    if (ptr.notEqual(buf)) {
        return WordFactory.signed(ptr.rawValue() - buf.rawValue());
    }
    return read;
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) Dirent.direntPointer(com.oracle.svm.core.posix.headers.Dirent.direntPointer) Pointer(org.graalvm.word.Pointer) SignedWord(org.graalvm.word.SignedWord)

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