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