Java Code Examples for jdk.internal.misc.Unsafe#ARRAY_LONG_BASE_OFFSET

The following examples show how to use jdk.internal.misc.Unsafe#ARRAY_LONG_BASE_OFFSET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArraysSupport.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public static int mismatch(long[] a, int aFromIndex,
                           long[] b, int bFromIndex,
                           int length) {
    if (length == 0) {
        return -1;
    }
    if (a[aFromIndex] != b[bFromIndex])
        return 0;
    int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
    int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
    int i = vectorizedMismatch(
            a, aOffset,
            b, bOffset,
            length, LOG2_ARRAY_LONG_INDEX_SCALE);
    return i >= 0 ? i : -1;
}
 
Example 2
Source File: HotSpotJVMCIRuntimeProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The offset from the origin of an array to the first element.
 *
 * @return the offset in bytes
 */
static int getArrayBaseOffset(JavaKind kind) {
    switch (kind) {
        case Boolean:
            return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
        case Byte:
            return Unsafe.ARRAY_BYTE_BASE_OFFSET;
        case Char:
            return Unsafe.ARRAY_CHAR_BASE_OFFSET;
        case Short:
            return Unsafe.ARRAY_SHORT_BASE_OFFSET;
        case Int:
            return Unsafe.ARRAY_INT_BASE_OFFSET;
        case Long:
            return Unsafe.ARRAY_LONG_BASE_OFFSET;
        case Float:
            return Unsafe.ARRAY_FLOAT_BASE_OFFSET;
        case Double:
            return Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
        case Object:
            return Unsafe.ARRAY_OBJECT_BASE_OFFSET;
        default:
            throw new JVMCIError("%s", kind);
    }
}
 
Example 3
Source File: RenderBuffer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public RenderBuffer put(long[] x, int offset, int length) {
    // assert (position() % SIZEOF_LONG == 0);
    if (length > COPY_FROM_ARRAY_THRESHOLD) {
        long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
        long lengthInBytes = length * SIZEOF_LONG;
        unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
        position(position() + lengthInBytes);
    } else {
        int end = offset + length;
        for (int i = offset; i < end; i++) {
            putLong(x[i]);
        }
    }
    return this;
}
 
Example 4
Source File: ArraysSupport.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static int mismatch(long[] a, int aFromIndex,
                    long[] b, int bFromIndex,
                    int length) {
    if (length == 0) {
        return -1;
    }
    int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
    int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
    int i = vectorizedMismatch(
            a, aOffset,
            b, bOffset,
            length, LOG2_ARRAY_LONG_INDEX_SCALE);
    return i >= 0 ? i : -1;
}
 
Example 5
Source File: RenderBuffer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public RenderBuffer put(long[] x, int offset, int length) {
    // assert (position() % SIZEOF_LONG == 0);
    if (length > COPY_FROM_ARRAY_THRESHOLD) {
        long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
        long lengthInBytes = length * SIZEOF_LONG;
        unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
        position(position() + lengthInBytes);
    } else {
        int end = offset + length;
        for (int i = offset; i < end; i++) {
            putLong(x[i]);
        }
    }
    return this;
}