mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8340189: 8339531 incorrect for Big Endian platforms
Reviewed-by: mdoerr, amitkumar
This commit is contained in:
parent
e6698f51a1
commit
521effe017
1 changed files with 9 additions and 17 deletions
|
@ -200,8 +200,8 @@ public final class SegmentBulkOperations {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
final int limit = length & (NATIVE_THRESHOLD_MISMATCH - 8);
|
final int limit = length & (NATIVE_THRESHOLD_MISMATCH - 8);
|
||||||
for (; offset < limit; offset += 8) {
|
for (; offset < limit; offset += 8) {
|
||||||
final long s = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, !Architecture.isLittleEndian());
|
final long s = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false);
|
||||||
final long d = SCOPED_MEMORY_ACCESS.getLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, !Architecture.isLittleEndian());
|
final long d = SCOPED_MEMORY_ACCESS.getLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false);
|
||||||
if (s != d) {
|
if (s != d) {
|
||||||
return start + offset + mismatch(s, d);
|
return start + offset + mismatch(s, d);
|
||||||
}
|
}
|
||||||
|
@ -210,8 +210,8 @@ public final class SegmentBulkOperations {
|
||||||
|
|
||||||
// 0...0X00
|
// 0...0X00
|
||||||
if (remaining >= 4) {
|
if (remaining >= 4) {
|
||||||
final int s = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, !Architecture.isLittleEndian());
|
final int s = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false);
|
||||||
final int d = SCOPED_MEMORY_ACCESS.getIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, !Architecture.isLittleEndian());
|
final int d = SCOPED_MEMORY_ACCESS.getIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false);
|
||||||
if (s != d) {
|
if (s != d) {
|
||||||
return start + offset + mismatch(s, d);
|
return start + offset + mismatch(s, d);
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,8 @@ public final class SegmentBulkOperations {
|
||||||
}
|
}
|
||||||
// 0...00X0
|
// 0...00X0
|
||||||
if (remaining >= 2) {
|
if (remaining >= 2) {
|
||||||
final short s = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, !Architecture.isLittleEndian());
|
final short s = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false);
|
||||||
final short d = SCOPED_MEMORY_ACCESS.getShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, !Architecture.isLittleEndian());
|
final short d = SCOPED_MEMORY_ACCESS.getShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false);
|
||||||
if (s != d) {
|
if (s != d) {
|
||||||
return start + offset + mismatch(s, d);
|
return start + offset + mismatch(s, d);
|
||||||
}
|
}
|
||||||
|
@ -243,26 +243,18 @@ public final class SegmentBulkOperations {
|
||||||
@ForceInline
|
@ForceInline
|
||||||
private static int mismatch(long first, long second) {
|
private static int mismatch(long first, long second) {
|
||||||
final long x = first ^ second;
|
final long x = first ^ second;
|
||||||
return (Architecture.isLittleEndian()
|
return Long.numberOfTrailingZeros(x) / 8;
|
||||||
? Long.numberOfTrailingZeros(x)
|
|
||||||
: Long.numberOfLeadingZeros(x)) / 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
private static int mismatch(int first, int second) {
|
private static int mismatch(int first, int second) {
|
||||||
final int x = first ^ second;
|
final int x = first ^ second;
|
||||||
return (Architecture.isLittleEndian()
|
return Integer.numberOfTrailingZeros(x) / 8;
|
||||||
? Integer.numberOfTrailingZeros(x)
|
|
||||||
: Integer.numberOfLeadingZeros(x)) / 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
private static int mismatch(short first, short second) {
|
private static int mismatch(short first, short second) {
|
||||||
if (Architecture.isLittleEndian()) {
|
return ((0xff & first) == (0xff & second)) ? 1 : 0;
|
||||||
return ((0xff & first) == (0xff & second)) ? 1 : 0;
|
|
||||||
} else {
|
|
||||||
return ((0xff & first) == (0xff & second)) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue