This class may be removed in the future. Consider the replacements in JEP 193 'Variable Handles': http://openjdk.java.net/jeps/193
static byte getByte(byte[] data, int index) { return UNSAFE.getByte(data, BYTE_ARRAY_BASE_OFFSET + index); }
static byte getByte(long address) { return UNSAFE.getByte(address); }
byte getByteUnchecked(int index) { return unsafe.getByte(base, address + index); }
@Override public boolean getBool(long byteIndex) { return unsafe.getByte(baseAdress +byteIndex) != 0; }
@Override public byte get(long byteIndex) { return unsafe.getByte(baseAdress +byteIndex); }
static byte getByte(long address) { return UNSAFE.getByte(address); }
static byte getByte(byte[] data, int index) { return UNSAFE.getByte(data, BYTE_ARRAY_BASE_OFFSET + index); }
public static byte getByte( Object obj, long offset ) { return unsafe.getByte( obj, offset ); }
/** * Returns the byte at the given offset of the object * @param ref * @param offset * @return the byte at the given offset */ public static byte toByte(Object ref, long offset) { return theUnsafe.getByte(ref, offset); } }
/** * Gets byte value from given address. * * @param addr Address. * @return Byte value from given address. */ public static byte getByte(long addr) { return UNSAFE.getByte(addr); }
/** * @param addr Address. * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian. */ private static char getCharByByte(long addr, boolean bigEndian) { if (bigEndian) return (char)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff)); else return (char)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff)); }
/** * Gets byte value from object field. * * @param obj Object. * @param fieldOff Field offset. * @return Byte value from object field. */ public static byte getByteField(Object obj, long fieldOff) { return UNSAFE.getByte(obj, fieldOff); }
/** * @param obj Object. * @param off Offset. * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian. */ private static short getShortByByte(Object obj, long off, boolean bigEndian) { if (bigEndian) return (short)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff)); else return (short)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff)); }
@Override public final byte get(int index) { final long pos = address + index; if (index >= 0 && pos < addressLimit) { return UNSAFE.getByte(heapMemory, pos); } else if (address > addressLimit) { throw new IllegalStateException("segment has been freed"); } else { // index is in fact invalid throw new IndexOutOfBoundsException(); } }
@Override public byte get(long byteIndex) { checkIndex(byteIndex,1); return unsafe.getByte(base,off+byteIndex); }
public final int getByteValue(Object obj) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { return FSTUtil.unFlaggedUnsafe.getByte(obj, memOffset); } return field.getByte(obj); }
@Override public boolean getBool(long byteIndex) { checkIndex(byteIndex,1); return unsafe.getByte(base,off+byteIndex) != 0; }
public static byte getByte( long address ) { checkAccess( address, Byte.BYTES ); return unsafe.getByte( address ); }
return ((hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset))) * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset + 1))) * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 3)); * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 2)); case 5: return (hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset))) * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 1)); case 4: return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset)); case 3: return (hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset))) * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset + 1)); case 2: return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset)); case 1: return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset)); default: return hash;
private static long updateTail(long hash, Object base, long address, int index, int length) { while (index <= length - 8) { hash = updateTail(hash, unsafe.getLong(base, address + index)); index += 8; } if (index <= length - 4) { hash = updateTail(hash, unsafe.getInt(base, address + index)); index += 4; } while (index < length) { hash = updateTail(hash, unsafe.getByte(base, address + index)); index++; } hash = finalShuffle(hash); return hash; }