8264774: Implementation of Foreign Function and Memory API (Incubator)

Co-authored-by: Paul Sandoz <psandoz@openjdk.org>
Co-authored-by: Jorn Vernee <jvernee@openjdk.org>
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
Co-authored-by: Athijegannathan Sundararajan <sundar@openjdk.org>
Co-authored-by: Chris Hegarty <chegar@openjdk.org>
Reviewed-by: psandoz, chegar, mchung, vlivanov
This commit is contained in:
Maurizio Cimadamore 2021-06-02 10:53:06 +00:00
parent 71425ddfb4
commit a223189b06
219 changed files with 10936 additions and 5695 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -76,6 +76,7 @@ class UnixAsynchronousSocketChannelImpl
private boolean isScatteringRead;
private ByteBuffer readBuffer;
private ByteBuffer[] readBuffers;
private Runnable readScopeHandleReleasers;
private CompletionHandler<Number,Object> readHandler;
private Object readAttachment;
private PendingFuture<Number,Object> readFuture;
@ -86,6 +87,7 @@ class UnixAsynchronousSocketChannelImpl
private boolean isGatheringWrite;
private ByteBuffer writeBuffer;
private ByteBuffer[] writeBuffers;
private Runnable writeScopeHandleReleasers;
private CompletionHandler<Number,Object> writeHandler;
private Object writeAttachment;
private PendingFuture<Number,Object> writeFuture;
@ -392,9 +394,9 @@ class UnixAsynchronousSocketChannelImpl
begin();
if (scattering) {
n = (int)IOUtil.read(fd, readBuffers, nd);
n = (int)IOUtil.read(fd, readBuffers, true, nd);
} else {
n = IOUtil.read(fd, readBuffer, -1, nd);
n = IOUtil.read(fd, readBuffer, -1, true, nd);
}
if (n == IOStatus.UNAVAILABLE) {
// spurious wakeup, is this possible?
@ -409,6 +411,7 @@ class UnixAsynchronousSocketChannelImpl
this.readBuffers = null;
this.readAttachment = null;
this.readHandler = null;
IOUtil.releaseScopes(readScopeHandleReleasers);
// allow another read to be initiated
enableReading();
@ -516,9 +519,9 @@ class UnixAsynchronousSocketChannelImpl
if (attemptRead) {
if (isScatteringRead) {
n = (int)IOUtil.read(fd, dsts, nd);
n = (int)IOUtil.read(fd, dsts, true, nd);
} else {
n = IOUtil.read(fd, dst, -1, nd);
n = IOUtil.read(fd, dst, -1, true, nd);
}
}
@ -526,6 +529,7 @@ class UnixAsynchronousSocketChannelImpl
PendingFuture<V,A> result = null;
synchronized (updateLock) {
this.isScatteringRead = isScatteringRead;
this.readScopeHandleReleasers = IOUtil.acquireScopes(dst, dsts);
this.readBuffer = dst;
this.readBuffers = dsts;
if (handler == null) {
@ -592,9 +596,9 @@ class UnixAsynchronousSocketChannelImpl
begin();
if (gathering) {
n = (int)IOUtil.write(fd, writeBuffers, nd);
n = (int)IOUtil.write(fd, writeBuffers, true, nd);
} else {
n = IOUtil.write(fd, writeBuffer, -1, nd);
n = IOUtil.write(fd, writeBuffer, -1, true, nd);
}
if (n == IOStatus.UNAVAILABLE) {
// spurious wakeup, is this possible?
@ -609,6 +613,7 @@ class UnixAsynchronousSocketChannelImpl
this.writeBuffers = null;
this.writeAttachment = null;
this.writeHandler = null;
IOUtil.releaseScopes(writeScopeHandleReleasers);
// allow another write to be initiated
enableWriting();
@ -702,9 +707,9 @@ class UnixAsynchronousSocketChannelImpl
if (attemptWrite) {
if (isGatheringWrite) {
n = (int)IOUtil.write(fd, srcs, nd);
n = (int)IOUtil.write(fd, srcs, true, nd);
} else {
n = IOUtil.write(fd, src, -1, nd);
n = IOUtil.write(fd, src, -1, true, nd);
}
}
@ -712,6 +717,7 @@ class UnixAsynchronousSocketChannelImpl
PendingFuture<V,A> result = null;
synchronized (updateLock) {
this.isGatheringWrite = isGatheringWrite;
this.writeScopeHandleReleasers = IOUtil.acquireScopes(src, srcs);
this.writeBuffer = src;
this.writeBuffers = srcs;
if (handler == null) {