< prev index next >

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java

Print this page

130         test.run();
131         int i;
132         for (i = 0; i < Math.max(offset, 0); i++) {
133             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
134                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
135             }
136         }
137         for (; i < Math.min(size * 8 + offset, size * 8); i++) {
138             if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
139                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
140             }
141         }
142         for (; i < byteArray.length; i++) {
143             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
144                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
145             }
146         }
147     }
148 
149     @Test
150     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

151     public static void testByteLong1(byte[] dest, long[] src) {
152         for (int i = 0; i < src.length; i++) {
153             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
154         }
155     }
156 
157     @Run(test = "testByteLong1")
158     public static void testByteLong1_runner() {
159         runAndVerify(() -> testByteLong1(byteArray, longArray), 0);
160     }
161 
162     @Test
163     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

164     public static void testByteLong2(byte[] dest, long[] src) {
165         for (int i = 1; i < src.length; i++) {
166             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
167         }
168     }
169 
170     @Run(test = "testByteLong2")
171     public static void testByteLong2_runner() {
172         runAndVerify(() -> testByteLong2(byteArray, longArray), -8);
173     }
174 
175     @Test
176     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

177     public static void testByteLong3(byte[] dest, long[] src) {
178         for (int i = 0; i < src.length - 1; i++) {
179             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]);
180         }
181     }
182 
183     @Run(test = "testByteLong3")
184     public static void testByteLong3_runner() {
185         runAndVerify(() -> testByteLong3(byteArray, longArray), 8);
186     }
187 
188     @Test
189     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" },
190         applyIf = {"AlignVector", "false"})
191     // AlignVector cannot guarantee that invar is aligned.
192     public static void testByteLong4(byte[] dest, long[] src, int start, int stop) {
193         for (int i = start; i < stop; i++) {
194             UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
195         }
196     }
197 
198     @Run(test = "testByteLong4")
199     public static void testByteLong4_runner() {
200         baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
201         runAndVerify(() -> testByteLong4(byteArray, longArray, 0, size), 0);
202     }
203 
204     @Test
205     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

206     public static void testByteLong5(byte[] dest, long[] src, int start, int stop) {
207         for (int i = start; i < stop; i++) {
208             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
209         }
210     }
211 
212     @Run(test = "testByteLong5")
213     public static void testByteLong5_runner() {
214         baseOffset = 1;
215         runAndVerify(() -> testByteLong5(byteArray, longArray, 0, size-1), 8);
216     }
217 
218     @Test
219     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

220     public static void testByteByte1(byte[] dest, byte[] src) {
221         for (int i = 0; i < src.length / 8; i++) {
222             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
223         }
224     }
225 
226     @Run(test = "testByteByte1")
227     public static void testByteByte1_runner() {
228         runAndVerify2(() -> testByteByte1(byteArray, byteArray), 0);
229     }
230 
231     @Test
232     @IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })

233     public static void testByteByte2(byte[] dest, byte[] src) {
234         for (int i = 1; i < src.length / 8; i++) {
235             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
236         }
237     }
238 
239     @Run(test = "testByteByte2")
240     public static void testByteByte2_runner() {
241         runAndVerify2(() -> testByteByte2(byteArray, byteArray), -8);
242     }
243 
244     @Test
245     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
246     public static void testByteByte3(byte[] dest, byte[] src) {
247         for (int i = 0; i < src.length / 8 - 1; i++) {
248             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
249         }
250     }
251 
252     @Run(test = "testByteByte3")

130         test.run();
131         int i;
132         for (i = 0; i < Math.max(offset, 0); i++) {
133             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
134                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
135             }
136         }
137         for (; i < Math.min(size * 8 + offset, size * 8); i++) {
138             if (UNSAFE.getByte(null, baseOffHeap + i) != verifyByteArray[i - offset]) {
139                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != " + verifyByteArray[i-offset]);
140             }
141         }
142         for (; i < byteArray.length; i++) {
143             if (UNSAFE.getByte(null, baseOffHeap + i) != 0) {
144                 throw new RuntimeException("Incorrect result at " + i + " " + byteArray[i] + " != 0");
145             }
146         }
147     }
148 
149     @Test
150     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
151         counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
152     public static void testByteLong1(byte[] dest, long[] src) {
153         for (int i = 0; i < src.length; i++) {
154             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
155         }
156     }
157 
158     @Run(test = "testByteLong1")
159     public static void testByteLong1_runner() {
160         runAndVerify(() -> testByteLong1(byteArray, longArray), 0);
161     }
162 
163     @Test
164     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
165         counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
166     public static void testByteLong2(byte[] dest, long[] src) {
167         for (int i = 1; i < src.length; i++) {
168             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
169         }
170     }
171 
172     @Run(test = "testByteLong2")
173     public static void testByteLong2_runner() {
174         runAndVerify(() -> testByteLong2(byteArray, longArray), -8);
175     }
176 
177     @Test
178     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
179         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         applyIf = {"AlignVector", "false"})
194     // AlignVector cannot guarantee that invar is aligned.
195     public static void testByteLong4(byte[] dest, long[] src, int start, int stop) {
196         for (int i = start; i < stop; i++) {
197             UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
198         }
199     }
200 
201     @Run(test = "testByteLong4")
202     public static void testByteLong4_runner() {
203         baseOffset = UNSAFE.ARRAY_BYTE_BASE_OFFSET;
204         runAndVerify(() -> testByteLong4(byteArray, longArray, 0, size), 0);
205     }
206 
207     @Test
208     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
209         counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
210     public static void testByteLong5(byte[] dest, long[] src, int start, int stop) {
211         for (int i = start; i < stop; i++) {
212             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
213         }
214     }
215 
216     @Run(test = "testByteLong5")
217     public static void testByteLong5_runner() {
218         baseOffset = 1;
219         runAndVerify(() -> testByteLong5(byteArray, longArray, 0, size-1), 8);
220     }
221 
222     @Test
223     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
224         counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
225     public static void testByteByte1(byte[] dest, byte[] src) {
226         for (int i = 0; i < src.length / 8; i++) {
227             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
228         }
229     }
230 
231     @Run(test = "testByteByte1")
232     public static void testByteByte1_runner() {
233         runAndVerify2(() -> testByteByte1(byteArray, byteArray), 0);
234     }
235 
236     @Test
237     @IR(applyIf = {"UseCompactObjectHeaders", "false"},
238         counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
239     public static void testByteByte2(byte[] dest, byte[] src) {
240         for (int i = 1; i < src.length / 8; i++) {
241             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
242         }
243     }
244 
245     @Run(test = "testByteByte2")
246     public static void testByteByte2_runner() {
247         runAndVerify2(() -> testByteByte2(byteArray, byteArray), -8);
248     }
249 
250     @Test
251     @IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
252     public static void testByteByte3(byte[] dest, byte[] src) {
253         for (int i = 0; i < src.length / 8 - 1; i++) {
254             UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
255         }
256     }
257 
258     @Run(test = "testByteByte3")
< prev index next >