mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
Reviewed-by: psandoz, vlivanov, plevart
This commit is contained in:
parent
f439f2166b
commit
de3604ea0c
6 changed files with 113 additions and 67 deletions
|
@ -26,6 +26,7 @@
|
|||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.ref.Reference;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
|
||||
|
@ -166,9 +167,15 @@ public abstract class MappedByteBuffer
|
|||
int count = Bits.pageCount(length);
|
||||
long a = mappingAddress(offset);
|
||||
byte x = 0;
|
||||
for (int i=0; i<count; i++) {
|
||||
x ^= unsafe.getByte(a);
|
||||
a += ps;
|
||||
try {
|
||||
for (int i=0; i<count; i++) {
|
||||
// TODO consider changing to getByteOpaque thus avoiding
|
||||
// dead code elimination and the need to calculate a checksum
|
||||
x ^= unsafe.getByte(a);
|
||||
a += ps;
|
||||
}
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
if (unused != 0)
|
||||
unused = x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue