8254078: DataOutputStream is very slow post-disabling of Biased Locking

Reviewed-by: rriggs, shade, alanb
This commit is contained in:
Andrew Haley 2020-11-09 16:02:30 +00:00
parent 79b7909507
commit 17f04fc9e7
3 changed files with 143 additions and 11 deletions

View file

@ -33,9 +33,10 @@ import java.util.Objects;
* way. An application uses a data output stream to write data that
* can later be read by a data input stream.
* <p>
* DataInputStream is not necessarily safe for multithreaded access.
* Thread safety is optional and is the responsibility of users of
* methods in this class.
* A DataInputStream is not safe for use by multiple concurrent
* threads. If a DataInputStream is to be used by more than one
* thread then access to the data input stream should be controlled
* by appropriate synchronization.
*
* @author Arthur van Hoff
* @see java.io.DataOutputStream

View file

@ -29,6 +29,11 @@ package java.io;
* A data output stream lets an application write primitive Java data
* types to an output stream in a portable way. An application can
* then use a data input stream to read the data back in.
* <p>
* A DataOutputStream is not safe for use by multiple concurrent
* threads. If a DataOutputStream is to be used by more than one
* thread then access to the data output stream should be controlled
* by appropriate synchronization.
*
* @see java.io.DataInputStream
* @since 1.0
@ -162,8 +167,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* @see java.io.FilterOutputStream#out
*/
public final void writeShort(int v) throws IOException {
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
writeBuffer[0] = (byte)(v >>> 8);
writeBuffer[1] = (byte)(v >>> 0);
out.write(writeBuffer, 0, 2);
incCount(2);
}
@ -177,8 +183,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* @see java.io.FilterOutputStream#out
*/
public final void writeChar(int v) throws IOException {
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
writeBuffer[0] = (byte)(v >>> 8);
writeBuffer[1] = (byte)(v >>> 0);
out.write(writeBuffer, 0, 2);
incCount(2);
}
@ -192,10 +199,11 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* @see java.io.FilterOutputStream#out
*/
public final void writeInt(int v) throws IOException {
out.write((v >>> 24) & 0xFF);
out.write((v >>> 16) & 0xFF);
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
writeBuffer[0] = (byte)(v >>> 24);
writeBuffer[1] = (byte)(v >>> 16);
writeBuffer[2] = (byte)(v >>> 8);
writeBuffer[3] = (byte)(v >>> 0);
out.write(writeBuffer, 0, 4);
incCount(4);
}