Lines Matching refs:unsafe

26  * @summary Minimal test for unsafe.copyMemory() and unsafe.setMemory()
62 private static void set(Unsafe unsafe, long addr, int ofs, int len, int value) {
64 unsafe.putByte(null, addr + ofs + i, (byte)value);
68 private static void check(Unsafe unsafe, long addr, int ofs, int len, int value) {
70 int r = unsafe.getByte(null, addr + ofs + i) & 0xff;
88 private static void testSetByteArray(Unsafe unsafe) throws Exception {
96 unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val);
103 private static void testSetRawMemory(Unsafe unsafe) throws Exception {
107 set(unsafe, b, 0, BUFFER_SIZE, FILLER);
111 unsafe.setMemory(null, b + ofs, len, (byte)val);
112 check(unsafe, b, 0, ofs - 1, FILLER);
113 check(unsafe, b, ofs, len, val);
114 check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER);
118 private static void testCopyByteArrayToByteArray(Unsafe unsafe) throws Exception {
130 unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
138 private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
144 set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
150 unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
152 check(unsafe, b2, 0, ofs2 - 1, FILLER2);
153 check(unsafe, b2, ofs2, len, val);
154 check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
158 private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
163 set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
168 set(unsafe, b1, ofs, len, val);
170 unsafe.copyMemory(null, b1 + ofs,
178 private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
183 set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
184 set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
188 set(unsafe, b1, ofs, len, val);
190 unsafe.copyMemory(null, b1 + ofs,
192 check(unsafe, b2, 0, ofs2 - 1, FILLER2);
193 check(unsafe, b2, ofs2, len, val);
194 check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
205 Unsafe unsafe = getUnsafe();
207 testSetByteArray(unsafe);
208 testSetRawMemory(unsafe);
209 testCopyByteArrayToByteArray(unsafe);
210 testCopyByteArrayToRawMemory(unsafe);
211 testCopyRawMemoryToByteArray(unsafe);
212 testCopyRawMemoryToRawMemory(unsafe);