133 test.run();
134 int i;
135 for (i = 0; i < Math.max(offset, 0); i++) {
136 if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
137 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
138 }
139 }
140 for (; i < Math.min(size * 8 + offset, size * 8); i++) {
141 if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
142 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
143 }
144 }
145 for (; i < byteArray.length; i++) {
146 if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
147 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
148 }
149 }
150 }
151
152 @Test
153 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
154 public static void testByteLong1(byte[] dest, long[] src) {
155 for (int i = 0; i < src.length; i++) {
156 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
157 }
158 }
159
160 @Run(test = "testByteLong1")
161 public static void testByteLong1_runner() {
162 runAndVerify(() -> testByteLong1(byteArray, longArray), 0);
163 }
164
165 @Test
166 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
167 public static void testByteLong2(byte[] dest, long[] src) {
168 for (int i = 1; i < src.length; i++) {
169 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
170 }
171 }
172
173 @Run(test = "testByteLong2")
174 public static void testByteLong2_runner() {
175 runAndVerify(() -> testByteLong2(byteArray, longArray), -8);
176 }
177
178 @Test
179 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
180 public static void testByteLong3(byte[] dest, long[] src) {
181 for (int i = 0; i < src.length - 1; i++) {
182 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]);
183 }
184 }
185
186 @Run(test = "testByteLong3")
187 public static void testByteLong3_runner() {
188 runAndVerify(() -> testByteLong3(byteArray, longArray), 8);
189 }
190
191 @Test
192 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
193 public static void testByteLong4(byte[] dest, long[] src, int start, int stop) {
194 for (int i = start; i < stop; i++) {
195 UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
196 }
197 }
198
199 @Run(test = "testByteLong4")
200 public static void testByteLong4_runner() {
201 baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
202 runAndVerify(() -> testByteLong4(byteArray, longArray, 0, size), 0);
203 }
204
205 @Test
206 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
207 public static void testByteLong5(byte[] dest, long[] src, int start, int stop) {
208 for (int i = start; i < stop; i++) {
209 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
210 }
211 }
212
213 @Run(test = "testByteLong5")
214 public static void testByteLong5_runner() {
215 baseOffset = 1;
216 runAndVerify(() -> testByteLong5(byteArray, longArray, 0, size-1), 8);
217 }
218
219 @Test
220 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
221 public static void testByteByte1(byte[] dest, byte[] src) {
222 for (int i = 0; i < src.length / 8; i++) {
223 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
224 }
225 }
226
227 @Run(test = "testByteByte1")
228 public static void testByteByte1_runner() {
229 runAndVerify2(() -> testByteByte1(byteArray, byteArray), 0);
230 }
231
232 // It would be legal to vectorize this one but it's not currently
233 @Test
234 //@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
235 public static void testByteByte2(byte[] dest, byte[] src) {
236 for (int i = 1; i < src.length / 8; i++) {
237 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
238 }
239 }
240
|
133 test.run();
134 int i;
135 for (i = 0; i < Math.max(offset, 0); i++) {
136 if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
137 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
138 }
139 }
140 for (; i < Math.min(size * 8 + offset, size * 8); i++) {
141 if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
142 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
143 }
144 }
145 for (; i < byteArray.length; i++) {
146 if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
147 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
148 }
149 }
150 }
151
152 @Test
153 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
154 applyIf = {"UseCompactObjectHeaders", "false"})
155 public static void testByteLong1(byte[] dest, long[] src) {
156 for (int i = 0; i < src.length; i++) {
157 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
158 }
159 }
160
161 @Run(test = "testByteLong1")
162 public static void testByteLong1_runner() {
163 runAndVerify(() -> testByteLong1(byteArray, longArray), 0);
164 }
165
166 @Test
167 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
168 applyIf = {"UseCompactObjectHeaders", "false"})
169 public static void testByteLong2(byte[] dest, long[] src) {
170 for (int i = 1; i < src.length; i++) {
171 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
172 }
173 }
174
175 @Run(test = "testByteLong2")
176 public static void testByteLong2_runner() {
177 runAndVerify(() -> testByteLong2(byteArray, longArray), -8);
178 }
179
180 @Test
181 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
182 applyIf = {"UseCompactObjectHeaders", "false"})
183 public static void testByteLong3(byte[] dest, long[] src) {
184 for (int i = 0; i < src.length - 1; i++) {
185 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]);
186 }
187 }
188
189 @Run(test = "testByteLong3")
190 public static void testByteLong3_runner() {
191 runAndVerify(() -> testByteLong3(byteArray, longArray), 8);
192 }
193
194 @Test
195 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
196 public static void testByteLong4(byte[] dest, long[] src, int start, int stop) {
197 for (int i = start; i < stop; i++) {
198 UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
199 }
200 }
201
202 @Run(test = "testByteLong4")
203 public static void testByteLong4_runner() {
204 baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
205 runAndVerify(() -> testByteLong4(byteArray, longArray, 0, size), 0);
206 }
207
208 @Test
209 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
210 applyIf = {"UseCompactObjectHeaders", "false"})
211 public static void testByteLong5(byte[] dest, long[] src, int start, int stop) {
212 for (int i = start; i < stop; i++) {
213 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
214 }
215 }
216
217 @Run(test = "testByteLong5")
218 public static void testByteLong5_runner() {
219 baseOffset = 1;
220 runAndVerify(() -> testByteLong5(byteArray, longArray, 0, size-1), 8);
221 }
222
223 @Test
224 @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
225 applyIf = {"UseCompactObjectHeaders", "false"})
226 public static void testByteByte1(byte[] dest, byte[] src) {
227 for (int i = 0; i < src.length / 8; i++) {
228 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
229 }
230 }
231
232 @Run(test = "testByteByte1")
233 public static void testByteByte1_runner() {
234 runAndVerify2(() -> testByteByte1(byteArray, byteArray), 0);
235 }
236
237 // It would be legal to vectorize this one but it's not currently
238 @Test
239 //@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
240 public static void testByteByte2(byte[] dest, byte[] src) {
241 for (int i = 1; i < src.length / 8; i++) {
242 UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
243 }
244 }
245
|