private static void verifyHacks() { // Make sure that we have access to theUnsafe. UnsafeUtil.assertHasUnsafe(); }
@Test void mustHaveUnsafe() { assertHasUnsafe(); }
protected OffHeapNumberArray( long length, int itemSize, long base, MemoryAllocationTracker allocationTracker ) { super( itemSize, base ); UnsafeUtil.assertHasUnsafe(); this.length = length; this.allocationTracker = allocationTracker; long dataSize = length * itemSize; boolean itemSizeIsPowerOfTwo = Integer.bitCount( itemSize ) == 1; if ( UnsafeUtil.allowUnalignedMemoryAccess || !itemSizeIsPowerOfTwo ) { // we can end up here even if we require aligned memory access. Reason is that item size // isn't power of two anyway and so we have to fallback to safer means of accessing the memory, // i.e. byte for byte. allocatedBytes = dataSize; this.allocatedAddress = this.address = UnsafeUtil.allocateMemory( allocatedBytes, allocationTracker ); } else { // the item size is a power of two and we're required to access memory aligned // so we can allocate a bit more to ensure we can get an aligned memory address to start from. allocatedBytes = dataSize + itemSize - 1; this.allocatedAddress = UnsafeUtil.allocateMemory( allocatedBytes, allocationTracker ); this.address = UnsafeUtil.alignedMemory( allocatedAddress, itemSize ); } }
protected UnsafeTable( int capacity, int bytesPerKey, VALUE valueMarker, MemoryAllocationTracker allocationTracker ) UnsafeUtil.assertHasUnsafe(); this.allocationTracker = allocationTracker; this.bytesPerKey = bytesPerKey;
private static void verifyHacks() { // Make sure that we have access to theUnsafe. UnsafeUtil.assertHasUnsafe(); }
protected OffHeapNumberArray( long length, int itemSize, long base, MemoryAllocationTracker allocationTracker ) { super( itemSize, base ); UnsafeUtil.assertHasUnsafe(); this.length = length; this.allocationTracker = allocationTracker; long dataSize = length * itemSize; boolean itemSizeIsPowerOfTwo = Integer.bitCount( itemSize ) == 1; if ( UnsafeUtil.allowUnalignedMemoryAccess || !itemSizeIsPowerOfTwo ) { // we can end up here even if we require aligned memory access. Reason is that item size // isn't power of two anyway and so we have to fallback to safer means of accessing the memory, // i.e. byte for byte. allocatedBytes = dataSize; this.allocatedAddress = this.address = UnsafeUtil.allocateMemory( allocatedBytes, allocationTracker ); } else { // the item size is a power of two and we're required to access memory aligned // so we can allocate a bit more to ensure we can get an aligned memory address to start from. allocatedBytes = dataSize + itemSize - 1; this.allocatedAddress = UnsafeUtil.allocateMemory( allocatedBytes, allocationTracker ); this.address = UnsafeUtil.alignedMemory( allocatedAddress, itemSize ); } }
protected UnsafeTable( int capacity, int bytesPerKey, VALUE valueMarker, MemoryAllocationTracker allocationTracker ) UnsafeUtil.assertHasUnsafe(); this.allocationTracker = allocationTracker; this.bytesPerKey = bytesPerKey;
protected UnsafeTable( int capacity, int bytesPerKey, VALUE valueMarker, MemoryAllocationTracker allocationTracker ) UnsafeUtil.assertHasUnsafe(); this.allocationTracker = allocationTracker; this.bytesPerKey = bytesPerKey;