8224042: Add private alignDown method to MappedByteBuffer
Use alignDown method to round addresses down to page boundary Reviewed-by: stuefe, mikael, alanb
This commit is contained in:
parent
244bdce994
commit
772ad03cb5
@ -106,7 +106,7 @@ public abstract class MappedByteBuffer
|
||||
private long mappingOffset(int index) {
|
||||
int ps = Bits.pageSize();
|
||||
long indexAddress = address + index;
|
||||
long baseAddress = (indexAddress & ~(ps-1));
|
||||
long baseAddress = alignDown(indexAddress, ps);
|
||||
return indexAddress - baseAddress;
|
||||
}
|
||||
|
||||
@ -140,6 +140,12 @@ public abstract class MappedByteBuffer
|
||||
return length + mappingOffset;
|
||||
}
|
||||
|
||||
// align address down to page size
|
||||
private static long alignDown(long address, int pageSize) {
|
||||
// pageSize must be a power of 2
|
||||
return address & ~(pageSize - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer's content is resident in physical
|
||||
* memory.
|
||||
|
Loading…
x
Reference in New Issue
Block a user