8284161: Implementation of Virtual Threads (Preview)

Co-authored-by: Ron Pressler <rpressler@openjdk.org>
Co-authored-by: Alan Bateman <alanb@openjdk.org>
Co-authored-by: Erik Österlund <eosterlund@openjdk.org>
Co-authored-by: Andrew Haley <aph@openjdk.org>
Co-authored-by: Rickard Bäckman <rbackman@openjdk.org>
Co-authored-by: Markus Grönlund <mgronlun@openjdk.org>
Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org>
Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org>
Co-authored-by: Chris Plummer <cjplummer@openjdk.org>
Co-authored-by: Coleen Phillimore <coleenp@openjdk.org>
Co-authored-by: Robbin Ehn <rehn@openjdk.org>
Co-authored-by: Stefan Karlsson <stefank@openjdk.org>
Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org>
Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org>
Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
Alan Bateman 2022-05-07 08:06:16 +00:00
parent 5212535a27
commit 9583e3657e
1133 changed files with 95935 additions and 8335 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2022, 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
@ -29,6 +29,7 @@ import java.nio.channels.FileChannel;
import jdk.internal.access.JavaIORandomAccessFileAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Blocker;
import sun.nio.ch.FileChannelImpl;
@ -339,9 +340,13 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param mode the mode flags, a combination of the O_ constants
* defined above
*/
private void open(String name, int mode)
throws FileNotFoundException {
open0(name, mode);
private void open(String name, int mode) throws FileNotFoundException {
long comp = Blocker.begin();
try {
open0(name, mode);
} finally {
Blocker.end(comp);
}
}
// 'Read' primitives
@ -362,7 +367,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* end-of-file has been reached.
*/
public int read() throws IOException {
return read0();
long comp = Blocker.begin();
try {
return read0();
} finally {
Blocker.end(comp);
}
}
private native int read0() throws IOException;
@ -374,7 +384,16 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param len the number of bytes to read.
* @throws IOException If an I/O error has occurred.
*/
private native int readBytes(byte[] b, int off, int len) throws IOException;
private int readBytes(byte[] b, int off, int len) throws IOException {
long comp = Blocker.begin();
try {
return readBytes0(b, off, len);
} finally {
Blocker.end(comp);
}
}
private native int readBytes0(byte[] b, int off, int len) throws IOException;
/**
* Reads up to {@code len} bytes of data from this file into an
@ -519,7 +538,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @throws IOException if an I/O error occurs.
*/
public void write(int b) throws IOException {
write0(b);
long comp = Blocker.begin();
try {
write0(b);
} finally {
Blocker.end(comp);
}
}
private native void write0(int b) throws IOException;
@ -532,7 +556,16 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param len the number of bytes that are written
* @throws IOException If an I/O error has occurred.
*/
private native void writeBytes(byte[] b, int off, int len) throws IOException;
private void writeBytes(byte[] b, int off, int len) throws IOException {
long comp = Blocker.begin();
try {
writeBytes0(b, off, len);
} finally {
Blocker.end(comp);
}
}
private native void writeBytes0(byte[] b, int off, int len) throws IOException;
/**
* Writes {@code b.length} bytes from the specified byte array
@ -587,8 +620,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
public void seek(long pos) throws IOException {
if (pos < 0) {
throw new IOException("Negative seek offset");
} else {
}
long comp = Blocker.begin();
try {
seek0(pos);
} finally {
Blocker.end(comp);
}
}
@ -600,7 +637,16 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @return the length of this file, measured in bytes.
* @throws IOException if an I/O error occurs.
*/
public native long length() throws IOException;
public long length() throws IOException {
long comp = Blocker.begin();
try {
return length0();
} finally {
Blocker.end(comp);
}
}
private native long length0() throws IOException;
/**
* Sets the length of this file.
@ -621,7 +667,16 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @throws IOException If an I/O error occurs
* @since 1.2
*/
public native void setLength(long newLength) throws IOException;
public void setLength(long newLength) throws IOException {
long comp = Blocker.begin();
try {
setLength0(newLength);
} finally {
Blocker.end(comp);
}
}
private native void setLength0(long newLength) throws IOException;
/**
* Closes this random access file stream and releases any system