Java Code Examples for sun.misc.Unsafe#copyMemory()

The following examples show how to use sun.misc.Unsafe#copyMemory() . 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: CopyMemory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to raw memory...");
    byte[] b1 = new byte[BUFFER_SIZE];
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 2
Source File: CopyMemory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 3
Source File: CopyMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to raw memory...");
    byte[] b1 = new byte[BUFFER_SIZE];
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 4
Source File: CopyMemory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to raw memory...");
    byte[] b1 = new byte[BUFFER_SIZE];
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 5
Source File: CopyMemory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 6
Source File: CopyMemory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to raw memory...");
    long b1 = getMemory(BUFFER_SIZE);
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 7
Source File: CopyMemory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 8
Source File: CopyMemory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to byte[]...");
    byte[] b1 = new byte[BUFFER_SIZE];
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 9
Source File: CopyMemory.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 10
Source File: CopyMemory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 11
Source File: CopyMemory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to raw memory...");
    long b1 = getMemory(BUFFER_SIZE);
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 12
Source File: CopyMemory.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 13
Source File: CopyMemory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to byte[]...");
    byte[] b1 = new byte[BUFFER_SIZE];
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 14
Source File: CopyMemory.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to raw memory...");
    byte[] b1 = new byte[BUFFER_SIZE];
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 15
Source File: CopyMemory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 16
Source File: CopyMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to byte[]...");
    long b1 = getMemory(BUFFER_SIZE);
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 17
Source File: CopyMemory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to raw memory...");
    long b1 = getMemory(BUFFER_SIZE);
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 18
Source File: CopyMemory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for raw memory to raw memory...");
    long b1 = getMemory(BUFFER_SIZE);
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(unsafe, b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(null, b1 + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 19
Source File: CopyMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToByteArray(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to byte[]...");
    byte[] b1 = new byte[BUFFER_SIZE];
    byte[] b2 = new byte[BUFFER_SIZE];
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
        check(b2, 0, ofs2 - 1, FILLER2);
        check(b2, ofs2, len, val);
        check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}
 
Example 20
Source File: CopyMemory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
    System.out.println("Testing copyMemory() for byte[] to raw memory...");
    byte[] b1 = new byte[BUFFER_SIZE];
    long b2 = getMemory(BUFFER_SIZE);
    for (int i = 0; i < N; i++) {
        set(b1, 0, BUFFER_SIZE, FILLER);
        set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
        int ofs = random.nextInt(BUFFER_SIZE / 2);
        int len = random.nextInt(BUFFER_SIZE / 2);
        int val = random.nextInt(256);
        set(b1, ofs, len, val);
        int ofs2 = random.nextInt(BUFFER_SIZE / 2);
        unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
            null, b2 + ofs2, len);
        check(unsafe, b2, 0, ofs2 - 1, FILLER2);
        check(unsafe, b2, ofs2, len, val);
        check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
    }
}