OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Test correctness of side effects tracking used by load to load forwarding. | 4 // Test correctness of side effects tracking used by load to load forwarding. |
5 | 5 |
6 // VMOptions=--optimization-counter-threshold=10 | 6 // VMOptions=--optimization-counter-threshold=10 |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 import "dart:typed_data"; | 9 import "dart:typed_data"; |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return v + w; | 233 return v + w; |
234 } | 234 } |
235 | 235 |
236 testIndexedNoAlias(a) { | 236 testIndexedNoAlias(a) { |
237 a[0] = 1; | 237 a[0] = 1; |
238 a[1] = 2; | 238 a[1] = 2; |
239 a[2] = 3; | 239 a[2] = 3; |
240 return a[0] + a[1]; | 240 return a[0] + a[1]; |
241 } | 241 } |
242 | 242 |
243 testIndexedAliasedStore(a, b) { | 243 // |
244 a[0] = 1; | 244 // Tests for indexed store aliases were autogenerated to have extensive |
245 a[1] = 2; | 245 // coverage for all interesting aliasing combinations within the alias |
246 if (a == b) { | 246 // lattice (*[*], *[C], X[*], X[C]) |
247 b[0] = 3; | 247 // |
248 } | 248 |
249 return a[0] + a[1]; | 249 testIndexedAliasedStore1(i) { |
250 } | 250 var a = new List(2); |
251 | 251 a[0] = 1; // X[C] |
252 testIndexedAliasedStore1(a, b) { | 252 a[i] = 2; // X[*] |
253 a[0] = 1; | |
254 a[1] = 2; | |
255 if (a == b) { | |
256 b[0] = 3; | |
257 } | |
258 return a[0] + a[1]; | |
259 } | |
260 | |
261 testIndexedAliasedStore2(a, b, i) { | |
262 a[0] = 1; | |
263 a[1] = 2; | |
264 if (a == b) { | |
265 b[i] = 3; | |
266 } | |
267 return a[0] + a[1]; | |
268 } | |
269 | |
270 | |
271 testIndexedAliasedStore3(i) { | |
272 var a = new List(2); | |
273 a[0] = 1; | |
274 a[i] = 3; | |
275 return a[0]; | 253 return a[0]; |
276 } | 254 } |
277 | 255 |
278 | 256 testIndexedAliasedStore2(f, c) { |
279 testIndexedAliasedStore4(b) { | 257 var a = new List(2); |
280 var a = new List(2); | 258 var d = f ? a : c; |
281 a[0] = 1; | 259 a[0] = 1; // X[C] |
282 b[0] = 3; | 260 d[0] = 2; // *[C] |
283 return a[0]; | 261 return a[0]; |
284 } | 262 } |
285 | 263 |
| 264 testIndexedAliasedStore3(f, c, i) { |
| 265 var a = new List(2); |
| 266 var d = f ? a : c; |
| 267 a[0] = 1; // X[C] |
| 268 d[i] = 2; // *[*] |
| 269 return a[0]; |
| 270 } |
| 271 |
| 272 testIndexedAliasedStore4(i) { |
| 273 var a = new List(2); |
| 274 a[i] = 1; // X[*] |
| 275 a[0] = 2; // X[C] |
| 276 return a[i]; |
| 277 } |
| 278 |
| 279 testIndexedAliasedStore5(i, j) { |
| 280 var a = new List(2); |
| 281 a[i] = 1; // X[*] |
| 282 a[j] = 2; // X[*] |
| 283 return a[i]; |
| 284 } |
| 285 |
| 286 testIndexedAliasedStore6(i, f, c) { |
| 287 var a = new List(2); |
| 288 var d = f ? a : c; |
| 289 a[i] = 1; // X[*] |
| 290 d[0] = 2; // *[C] |
| 291 return a[i]; |
| 292 } |
| 293 |
| 294 testIndexedAliasedStore7(i, f, c) { |
| 295 var a = new List(2); |
| 296 var d = f ? a : c; |
| 297 a[i] = 1; // X[*] |
| 298 d[i] = 2; // *[*] |
| 299 return a[i]; |
| 300 } |
| 301 |
| 302 testIndexedAliasedStore8(c, i) { |
| 303 c[0] = 1; // *[C] |
| 304 c[i] = 2; // *[*] |
| 305 return c[0]; |
| 306 } |
| 307 |
| 308 testIndexedAliasedStore9(c, f) { |
| 309 var a = new List(2); |
| 310 var d = f ? a : c; |
| 311 c[0] = 1; // *[C] |
| 312 d[0] = 2; // *[C] |
| 313 return c[0]; |
| 314 } |
| 315 |
| 316 testIndexedAliasedStore10(c, i) { |
| 317 c[i] = 1; // *[*] |
| 318 c[0] = 2; // *[C] |
| 319 return c[i]; |
| 320 } |
| 321 |
| 322 testIndexedAliasedStore11(c, i, j) { |
| 323 c[i] = 1; // *[*] |
| 324 c[j] = 2; // *[*] |
| 325 return c[i]; |
| 326 } |
| 327 |
| 328 testIndexedAliasedStore12(f, c) { |
| 329 var a = new List(2); |
| 330 var d = f ? a : c; |
| 331 d[0] = 1; // *[C] |
| 332 a[0] = 2; // X[C] |
| 333 return d[0]; |
| 334 } |
| 335 |
| 336 testIndexedAliasedStore13(f, c, i) { |
| 337 var a = new List(2); |
| 338 var d = f ? a : c; |
| 339 d[0] = 1; // *[C] |
| 340 a[i] = 2; // X[*] |
| 341 return d[0]; |
| 342 } |
| 343 |
| 344 testIndexedAliasedStore14(f, c, i) { |
| 345 var a = new List(2); |
| 346 var d = f ? a : c; |
| 347 d[i] = 1; // *[*] |
| 348 a[0] = 2; // X[C] |
| 349 return d[i]; |
| 350 } |
| 351 |
| 352 testIndexedAliasedStore15(f, c, i) { |
| 353 var a = new List(2); |
| 354 var d = f ? a : c; |
| 355 d[i] = 1; // *[*] |
| 356 a[i] = 2; // X[*] |
| 357 return d[i]; |
| 358 } |
| 359 |
| 360 testIndexedAliasedStores() { |
| 361 var arr = new List(2); |
| 362 |
| 363 for (var i = 0; i < 50; i++) { |
| 364 Expect.equals(2, testIndexedAliasedStore1(0)); |
| 365 Expect.equals(1, testIndexedAliasedStore1(1)); |
| 366 } |
| 367 |
| 368 for (var i = 0; i < 50; i++) { |
| 369 Expect.equals(1, testIndexedAliasedStore2(false, arr)); |
| 370 Expect.equals(2, testIndexedAliasedStore2(true, arr)); |
| 371 } |
| 372 |
| 373 for (var i = 0; i < 50; i++) { |
| 374 Expect.equals(1, testIndexedAliasedStore3(false, arr, 0)); |
| 375 Expect.equals(1, testIndexedAliasedStore3(false, arr, 1)); |
| 376 Expect.equals(2, testIndexedAliasedStore3(true, arr, 0)); |
| 377 Expect.equals(1, testIndexedAliasedStore3(true, arr, 1)); |
| 378 } |
| 379 |
| 380 for (var i = 0; i < 50; i++) { |
| 381 Expect.equals(2, testIndexedAliasedStore4(0)); |
| 382 Expect.equals(1, testIndexedAliasedStore4(1)); |
| 383 } |
| 384 |
| 385 for (var i = 0; i < 50; i++) { |
| 386 Expect.equals(2, testIndexedAliasedStore5(0, 0)); |
| 387 Expect.equals(1, testIndexedAliasedStore5(0, 1)); |
| 388 Expect.equals(1, testIndexedAliasedStore5(1, 0)); |
| 389 Expect.equals(2, testIndexedAliasedStore5(1, 1)); |
| 390 } |
| 391 |
| 392 for (var i = 0; i < 50; i++) { |
| 393 Expect.equals(1, testIndexedAliasedStore6(0, false, arr)); |
| 394 Expect.equals(2, testIndexedAliasedStore6(0, true, arr)); |
| 395 Expect.equals(1, testIndexedAliasedStore6(1, false, arr)); |
| 396 Expect.equals(1, testIndexedAliasedStore6(1, true, arr)); |
| 397 } |
| 398 |
| 399 for (var i = 0; i < 50; i++) { |
| 400 Expect.equals(1, testIndexedAliasedStore7(0, false, arr)); |
| 401 Expect.equals(2, testIndexedAliasedStore7(0, true, arr)); |
| 402 Expect.equals(1, testIndexedAliasedStore7(1, false, arr)); |
| 403 Expect.equals(2, testIndexedAliasedStore7(1, true, arr)); |
| 404 } |
| 405 |
| 406 for (var i = 0; i < 50; i++) { |
| 407 Expect.equals(2, testIndexedAliasedStore8(arr, 0)); |
| 408 Expect.equals(1, testIndexedAliasedStore8(arr, 1)); |
| 409 } |
| 410 |
| 411 for (var i = 0; i < 50; i++) { |
| 412 Expect.equals(2, testIndexedAliasedStore9(arr, false)); |
| 413 Expect.equals(1, testIndexedAliasedStore9(arr, true)); |
| 414 } |
| 415 |
| 416 for (var i = 0; i < 50; i++) { |
| 417 Expect.equals(2, testIndexedAliasedStore10(arr, 0)); |
| 418 Expect.equals(1, testIndexedAliasedStore10(arr, 1)); |
| 419 } |
| 420 |
| 421 for (var i = 0; i < 50; i++) { |
| 422 Expect.equals(2, testIndexedAliasedStore11(arr, 0, 0)); |
| 423 Expect.equals(1, testIndexedAliasedStore11(arr, 0, 1)); |
| 424 Expect.equals(1, testIndexedAliasedStore11(arr, 1, 0)); |
| 425 Expect.equals(2, testIndexedAliasedStore11(arr, 1, 1)); |
| 426 } |
| 427 |
| 428 for (var i = 0; i < 50; i++) { |
| 429 Expect.equals(1, testIndexedAliasedStore12(false, arr)); |
| 430 Expect.equals(2, testIndexedAliasedStore12(true, arr)); |
| 431 } |
| 432 |
| 433 for (var i = 0; i < 50; i++) { |
| 434 Expect.equals(1, testIndexedAliasedStore13(false, arr, 0)); |
| 435 Expect.equals(1, testIndexedAliasedStore13(false, arr, 1)); |
| 436 Expect.equals(2, testIndexedAliasedStore13(true, arr, 0)); |
| 437 Expect.equals(1, testIndexedAliasedStore13(true, arr, 1)); |
| 438 } |
| 439 |
| 440 for (var i = 0; i < 50; i++) { |
| 441 Expect.equals(1, testIndexedAliasedStore14(false, arr, 0)); |
| 442 Expect.equals(1, testIndexedAliasedStore14(false, arr, 1)); |
| 443 Expect.equals(2, testIndexedAliasedStore14(true, arr, 0)); |
| 444 Expect.equals(1, testIndexedAliasedStore14(true, arr, 1)); |
| 445 } |
| 446 |
| 447 for (var i = 0; i < 50; i++) { |
| 448 Expect.equals(1, testIndexedAliasedStore15(false, arr, 0)); |
| 449 Expect.equals(1, testIndexedAliasedStore15(false, arr, 1)); |
| 450 Expect.equals(2, testIndexedAliasedStore15(true, arr, 0)); |
| 451 Expect.equals(2, testIndexedAliasedStore15(true, arr, 1)); |
| 452 } |
| 453 } |
286 | 454 |
287 var indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 455 var indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
288 | 456 |
289 class Z { | 457 class Z { |
290 var x = 42; | 458 var x = 42; |
291 } | 459 } |
292 | 460 |
293 var global_array = new List<Z>(1); | 461 var global_array = new List<Z>(1); |
294 | 462 |
295 side_effect() { | 463 side_effect() { |
(...skipping 13 matching lines...) Expand all Loading... |
309 testImmutableVMFields(fixed, true); | 477 testImmutableVMFields(fixed, true); |
310 testImmutableVMFields(growable, false); | 478 testImmutableVMFields(growable, false); |
311 testImmutableVMFields(growable, false); | 479 testImmutableVMFields(growable, false); |
312 | 480 |
313 final f64List = new Float64List(2); | 481 final f64List = new Float64List(2); |
314 testPhiRepresentation(true, f64List); | 482 testPhiRepresentation(true, f64List); |
315 testPhiRepresentation(false, f64List); | 483 testPhiRepresentation(false, f64List); |
316 | 484 |
317 final obj = new X(new X(new X(null))); | 485 final obj = new X(new X(new X(null))); |
318 | 486 |
319 final cs = new C(0, new C(1, new C(2, null))); | 487 final cs = new C(0, new C(1, new C(2, null))); |
320 | 488 |
321 for (var i = 0; i < 20; i++) { | 489 for (var i = 0; i < 20; i++) { |
322 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); | 490 Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0))); |
323 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); | 491 Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false)); |
324 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); | 492 Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true)); |
325 testImmutableVMFields(fixed, true); | 493 testImmutableVMFields(fixed, true); |
326 testPhiRepresentation(true, f64List); | 494 testPhiRepresentation(true, f64List); |
327 testPhiForwarding(obj); | 495 testPhiForwarding(obj); |
328 testPhiForwarding2(obj); | 496 testPhiForwarding2(obj); |
329 testPhiForwarding3(); | 497 testPhiForwarding3(); |
(...skipping 24 matching lines...) Expand all Loading... |
354 | 522 |
355 final escape = new List(1); | 523 final escape = new List(1); |
356 for (var i = 0; i < 20; i++) { | 524 for (var i = 0; i < 20; i++) { |
357 fakeAliasing(escape); | 525 fakeAliasing(escape); |
358 } | 526 } |
359 | 527 |
360 final array = new List(3); | 528 final array = new List(3); |
361 for (var i = 0; i < 20; i++) { | 529 for (var i = 0; i < 20; i++) { |
362 Expect.equals(3, testIndexedNoAlias(array)); | 530 Expect.equals(3, testIndexedNoAlias(array)); |
363 } | 531 } |
364 for (var i = 0; i < 20; i++) { | |
365 Expect.equals(5, testIndexedAliasedStore1(array, array)); | |
366 } | |
367 for (var i = 0; i < 20; i++) { | |
368 Expect.equals(4, testIndexedAliasedStore2(array, array, indices[1])); | |
369 } | |
370 for (var i = 0; i < 20; i++) { | |
371 Expect.equals(3, testIndexedAliasedStore3(indices[0])); | |
372 } | |
373 for (var i = 0; i < 20; i++) { | |
374 Expect.equals(1, testIndexedAliasedStore3(indices[1])); | |
375 } | |
376 | 532 |
377 for (var i = 0; i < 20; i++) { | 533 testIndexedAliasedStores(); |
378 Expect.equals(1, testIndexedAliasedStore4(array)); | |
379 } | |
380 | 534 |
381 var test_array = new List(1); | 535 var test_array = new List(1); |
382 for (var i = 0; i < 20; i++) { | 536 for (var i = 0; i < 20; i++) { |
383 Expect.equals(43, testAliasingStoreIndexed(global_array)); | 537 Expect.equals(43, testAliasingStoreIndexed(global_array)); |
384 } | 538 } |
385 } | 539 } |
OLD | NEW |