mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8289188: SegmentAllocator:allocateArray(*) default behavior mismatch to spec
Reviewed-by: alanb
This commit is contained in:
parent
699ad45b43
commit
2c8ada689f
3 changed files with 48 additions and 6 deletions
|
@ -282,12 +282,13 @@ public interface SegmentAllocator {
|
|||
|
||||
private <Z> MemorySegment copyArrayWithSwapIfNeeded(Z array, ValueLayout elementLayout,
|
||||
Function<Z, MemorySegment> heapSegmentFactory) {
|
||||
Objects.requireNonNull(array);
|
||||
Objects.requireNonNull(elementLayout);
|
||||
int size = Array.getLength(array);
|
||||
MemorySegment addr = allocate(MemoryLayout.sequenceLayout(size, elementLayout));
|
||||
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,
|
||||
addr, elementLayout.withOrder(ByteOrder.nativeOrder()), 0, size);
|
||||
int size = array == null ? 0 : Array.getLength(array);
|
||||
MemorySegment addr = allocateArray(elementLayout, size);
|
||||
if (size > 0) {
|
||||
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,
|
||||
addr, elementLayout.withOrder(ByteOrder.nativeOrder()), 0, size);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue