1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test TestNewAcmp 26 * @summary Verifies correctness of the new acmp bytecode. 27 * @library /testlibrary /test/lib /compiler/whitebox / 28 * @compile TestNewAcmp.java 29 * @run driver ClassFileInstaller sun.hotspot.WhiteBox 30 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 31 * compiler.valhalla.valuetypes.TestNewAcmp 32 */ 33 34 package compiler.valhalla.valuetypes; 35 36 import jdk.test.lib.Asserts; 37 import jdk.test.lib.process.ProcessTools; 38 import jdk.test.lib.process.OutputAnalyzer; 39 import java.lang.annotation.Retention; 40 import java.lang.annotation.RetentionPolicy; 41 import java.lang.invoke.*; 42 import java.lang.reflect.Method; 43 import java.util.regex.Pattern; 44 import java.util.regex.Matcher; 45 import java.util.ArrayList; 46 import java.util.Arrays; 47 import java.util.List; 48 import sun.hotspot.WhiteBox; 49 50 51 interface MyInterface { 52 53 } 54 55 inline class MyValue1 implements MyInterface { 56 final int x; 57 58 MyValue1(int x) { 59 this.x = x; 60 } 61 62 static MyValue1 createDefault() { 63 return MyValue1.default; 64 } 65 66 static MyValue1 setX(MyValue1 v, int x) { 67 return new MyValue1(x); 68 } 69 } 70 71 inline class MyValue2 implements MyInterface { 72 final int x; 73 74 MyValue2(int x) { 75 this.x = x; 76 } 77 78 static MyValue2 createDefault() { 79 return MyValue2.default; 80 } 81 82 static MyValue2 setX(MyValue2 v, int x) { 83 return new MyValue2(x); 84 } 85 } 86 87 class MyObject implements MyInterface { 88 int x; 89 } 90 91 // Mark test methods that return false if the argument is null 92 @Retention(RetentionPolicy.RUNTIME) 93 @interface FalseIfNull { } 94 95 // Mark test methods that return true if the argument is null 96 @Retention(RetentionPolicy.RUNTIME) 97 @interface TrueIfNull { } 98 99 public class TestNewAcmp { 100 101 public boolean testEq01_1(Object u1, Object u2) { 102 return get(u1) == u2; // new acmp 103 } 104 105 public boolean testEq01_2(Object u1, Object u2) { 106 return u1 == get(u2); // new acmp 107 } 108 109 public boolean testEq01_3(Object u1, Object u2) { 110 return get(u1) == get(u2); // new acmp 111 } 112 113 @FalseIfNull 114 public boolean testEq01_4(Object u1, Object u2) { 115 return getNotNull(u1) == u2; // new acmp without null check 116 } 117 118 @FalseIfNull 119 public boolean testEq01_5(Object u1, Object u2) { 120 return u1 == getNotNull(u2); // new acmp without null check 121 } 122 123 @FalseIfNull 124 public boolean testEq01_6(Object u1, Object u2) { 125 return getNotNull(u1) == getNotNull(u2); // new acmp without null check 126 } 127 128 public boolean testEq02_1(MyValue1 v1, MyValue1 v2) { 129 return get(v1) == (Object)v2; // only true if both null 130 } 131 132 public boolean testEq02_2(MyValue1 v1, MyValue1 v2) { 133 return (Object)v1 == get(v2); // only true if both null 134 } 135 136 public boolean testEq02_3(MyValue1 v1, MyValue1 v2) { 137 return get(v1) == get(v2); // only true if both null 138 } 139 140 public boolean testEq03_1(MyValue1 v, Object u) { 141 return get(v) == u; // only true if both null 142 } 143 144 public boolean testEq03_2(MyValue1 v, Object u) { 145 return (Object)v == get(u); // only true if both null 146 } 147 148 public boolean testEq03_3(MyValue1 v, Object u) { 149 return get(v) == get(u); // only true if both null 150 } 151 152 public boolean testEq04_1(Object u, MyValue1 v) { 153 return get(u) == (Object)v; // only true if both null 154 } 155 156 public boolean testEq04_2(Object u, MyValue1 v) { 157 return u == get(v); // only true if both null 158 } 159 160 public boolean testEq04_3(Object u, MyValue1 v) { 161 return get(u) == get(v); // only true if both null 162 } 163 164 public boolean testEq05_1(MyObject o, MyValue1 v) { 165 return get(o) == (Object)v; // only true if both null 166 } 167 168 public boolean testEq05_2(MyObject o, MyValue1 v) { 169 return o == get(v); // only true if both null 170 } 171 172 public boolean testEq05_3(MyObject o, MyValue1 v) { 173 return get(o) == get(v); // only true if both null 174 } 175 176 public boolean testEq06_1(MyValue1 v, MyObject o) { 177 return get(v) == o; // only true if both null 178 } 179 180 public boolean testEq06_2(MyValue1 v, MyObject o) { 181 return (Object)v == get(o); // only true if both null 182 } 183 184 public boolean testEq06_3(MyValue1 v, MyObject o) { 185 return get(v) == get(o); // only true if both null 186 } 187 188 public boolean testEq07_1(MyValue1 v1, MyValue1 v2) { 189 return getNotNull(v1) == (Object)v2; // false 190 } 191 192 public boolean testEq07_2(MyValue1 v1, MyValue1 v2) { 193 return (Object)v1 == getNotNull(v2); // false 194 } 195 196 public boolean testEq07_3(MyValue1 v1, MyValue1 v2) { 197 return getNotNull(v1) == getNotNull(v2); // false 198 } 199 200 public boolean testEq08_1(MyValue1 v, Object u) { 201 return getNotNull(v) == u; // false 202 } 203 204 public boolean testEq08_2(MyValue1 v, Object u) { 205 return (Object)v == getNotNull(u); // false 206 } 207 208 public boolean testEq08_3(MyValue1 v, Object u) { 209 return getNotNull(v) == getNotNull(u); // false 210 } 211 212 public boolean testEq09_1(Object u, MyValue1 v) { 213 return getNotNull(u) == (Object)v; // false 214 } 215 216 public boolean testEq09_2(Object u, MyValue1 v) { 217 return u == getNotNull(v); // false 218 } 219 220 public boolean testEq09_3(Object u, MyValue1 v) { 221 return getNotNull(u) == getNotNull(v); // false 222 } 223 224 public boolean testEq10_1(MyObject o, MyValue1 v) { 225 return getNotNull(o) == (Object)v; // false 226 } 227 228 public boolean testEq10_2(MyObject o, MyValue1 v) { 229 return o == getNotNull(v); // false 230 } 231 232 public boolean testEq10_3(MyObject o, MyValue1 v) { 233 return getNotNull(o) == getNotNull(v); // false 234 } 235 236 public boolean testEq11_1(MyValue1 v, MyObject o) { 237 return getNotNull(v) == o; // false 238 } 239 240 public boolean testEq11_2(MyValue1 v, MyObject o) { 241 return (Object)v == getNotNull(o); // false 242 } 243 244 public boolean testEq11_3(MyValue1 v, MyObject o) { 245 return getNotNull(v) == getNotNull(o); // false 246 } 247 248 public boolean testEq12_1(MyObject o1, MyObject o2) { 249 return get(o1) == o2; // old acmp 250 } 251 252 public boolean testEq12_2(MyObject o1, MyObject o2) { 253 return o1 == get(o2); // old acmp 254 } 255 256 public boolean testEq12_3(MyObject o1, MyObject o2) { 257 return get(o1) == get(o2); // old acmp 258 } 259 260 public boolean testEq13_1(Object u, MyObject o) { 261 return get(u) == o; // old acmp 262 } 263 264 public boolean testEq13_2(Object u, MyObject o) { 265 return u == get(o); // old acmp 266 } 267 268 public boolean testEq13_3(Object u, MyObject o) { 269 return get(u) == get(o); // old acmp 270 } 271 272 public boolean testEq14_1(MyObject o, Object u) { 273 return get(o) == u; // old acmp 274 } 275 276 public boolean testEq14_2(MyObject o, Object u) { 277 return o == get(u); // old acmp 278 } 279 280 public boolean testEq14_3(MyObject o, Object u) { 281 return get(o) == get(u); // old acmp 282 } 283 284 public boolean testEq15_1(Object[] a, Object u) { 285 return get(a) == u; // old acmp 286 } 287 288 public boolean testEq15_2(Object[] a, Object u) { 289 return a == get(u); // old acmp 290 } 291 292 public boolean testEq15_3(Object[] a, Object u) { 293 return get(a) == get(u); // old acmp 294 } 295 296 public boolean testEq16_1(Object u, Object[] a) { 297 return get(u) == a; // old acmp 298 } 299 300 public boolean testEq16_2(Object u, Object[] a) { 301 return u == get(a); // old acmp 302 } 303 304 public boolean testEq16_3(Object u, Object[] a) { 305 return get(u) == get(a); // old acmp 306 } 307 308 public boolean testEq17_1(Object[] a, MyValue1 v) { 309 return get(a) == (Object)v; // only true if both null 310 } 311 312 public boolean testEq17_2(Object[] a, MyValue1 v) { 313 return a == get(v); // only true if both null 314 } 315 316 public boolean testEq17_3(Object[] a, MyValue1 v) { 317 return get(a) == get(v); // only true if both null 318 } 319 320 public boolean testEq18_1(MyValue1 v, Object[] a) { 321 return get(v) == a; // only true if both null 322 } 323 324 public boolean testEq18_2(MyValue1 v, Object[] a) { 325 return (Object)v == get(a); // only true if both null 326 } 327 328 public boolean testEq18_3(MyValue1 v, Object[] a) { 329 return get(v) == get(a); // only true if both null 330 } 331 332 public boolean testEq19_1(Object[] a, MyValue1 v) { 333 return getNotNull(a) == (Object)v; // false 334 } 335 336 public boolean testEq19_2(Object[] a, MyValue1 v) { 337 return a == getNotNull(v); // false 338 } 339 340 public boolean testEq19_3(Object[] a, MyValue1 v) { 341 return getNotNull(a) == getNotNull(v); // false 342 } 343 344 public boolean testEq20_1(MyValue1 v, Object[] a) { 345 return getNotNull(v) == a; // false 346 } 347 348 public boolean testEq20_2(MyValue1 v, Object[] a) { 349 return (Object)v == getNotNull(a); // false 350 } 351 352 public boolean testEq20_3(MyValue1 v, Object[] a) { 353 return getNotNull(v) == getNotNull(a); // false 354 } 355 356 public boolean testEq21_1(MyInterface u1, MyInterface u2) { 357 return get(u1) == u2; // new acmp 358 } 359 360 public boolean testEq21_2(MyInterface u1, MyInterface u2) { 361 return u1 == get(u2); // new acmp 362 } 363 364 public boolean testEq21_3(MyInterface u1, MyInterface u2) { 365 return get(u1) == get(u2); // new acmp 366 } 367 368 @FalseIfNull 369 public boolean testEq21_4(MyInterface u1, MyInterface u2) { 370 return getNotNull(u1) == u2; // new acmp without null check 371 } 372 373 @FalseIfNull 374 public boolean testEq21_5(MyInterface u1, MyInterface u2) { 375 return u1 == getNotNull(u2); // new acmp without null check 376 } 377 378 @FalseIfNull 379 public boolean testEq21_6(MyInterface u1, MyInterface u2) { 380 return getNotNull(u1) == getNotNull(u2); // new acmp without null check 381 } 382 383 public boolean testEq22_1(MyValue1 v, MyInterface u) { 384 return get(v) == u; // only true if both null 385 } 386 387 public boolean testEq22_2(MyValue1 v, MyInterface u) { 388 return (Object)v == get(u); // only true if both null 389 } 390 391 public boolean testEq22_3(MyValue1 v, MyInterface u) { 392 return get(v) == get(u); // only true if both null 393 } 394 395 public boolean testEq23_1(MyInterface u, MyValue1 v) { 396 return get(u) == (Object)v; // only true if both null 397 } 398 399 public boolean testEq23_2(MyInterface u, MyValue1 v) { 400 return u == get(v); // only true if both null 401 } 402 403 public boolean testEq23_3(MyInterface u, MyValue1 v) { 404 return get(u) == get(v); // only true if both null 405 } 406 407 public boolean testEq24_1(MyValue1 v, MyInterface u) { 408 return getNotNull(v) == u; // false 409 } 410 411 public boolean testEq24_2(MyValue1 v, MyInterface u) { 412 return (Object)v == getNotNull(u); // false 413 } 414 415 public boolean testEq24_3(MyValue1 v, MyInterface u) { 416 return getNotNull(v) == getNotNull(u); // false 417 } 418 419 public boolean testEq25_1(MyInterface u, MyValue1 v) { 420 return getNotNull(u) == (Object)v; // false 421 } 422 423 public boolean testEq25_2(MyInterface u, MyValue1 v) { 424 return u == getNotNull(v); // false 425 } 426 427 public boolean testEq25_3(MyInterface u, MyValue1 v) { 428 return getNotNull(u) == getNotNull(v); // false 429 } 430 431 public boolean testEq26_1(MyInterface u, MyObject o) { 432 return get(u) == o; // old acmp 433 } 434 435 public boolean testEq26_2(MyInterface u, MyObject o) { 436 return u == get(o); // old acmp 437 } 438 439 public boolean testEq26_3(MyInterface u, MyObject o) { 440 return get(u) == get(o); // old acmp 441 } 442 443 public boolean testEq27_1(MyObject o, MyInterface u) { 444 return get(o) == u; // old acmp 445 } 446 447 public boolean testEq27_2(MyObject o, MyInterface u) { 448 return o == get(u); // old acmp 449 } 450 451 public boolean testEq27_3(MyObject o, MyInterface u) { 452 return get(o) == get(u); // old acmp 453 } 454 455 public boolean testEq28_1(MyInterface[] a, MyInterface u) { 456 return get(a) == u; // old acmp 457 } 458 459 public boolean testEq28_2(MyInterface[] a, MyInterface u) { 460 return a == get(u); // old acmp 461 } 462 463 public boolean testEq28_3(MyInterface[] a, MyInterface u) { 464 return get(a) == get(u); // old acmp 465 } 466 467 public boolean testEq29_1(MyInterface u, MyInterface[] a) { 468 return get(u) == a; // old acmp 469 } 470 471 public boolean testEq29_2(MyInterface u, MyInterface[] a) { 472 return u == get(a); // old acmp 473 } 474 475 public boolean testEq29_3(MyInterface u, MyInterface[] a) { 476 return get(u) == get(a); // old acmp 477 } 478 479 public boolean testEq30_1(MyInterface[] a, MyValue1 v) { 480 return get(a) == (Object)v; // only true if both null 481 } 482 483 public boolean testEq30_2(MyInterface[] a, MyValue1 v) { 484 return a == get(v); // only true if both null 485 } 486 487 public boolean testEq30_3(MyInterface[] a, MyValue1 v) { 488 return get(a) == get(v); // only true if both null 489 } 490 491 public boolean testEq31_1(MyValue1 v, MyInterface[] a) { 492 return get(v) == a; // only true if both null 493 } 494 495 public boolean testEq31_2(MyValue1 v, MyInterface[] a) { 496 return (Object)v == get(a); // only true if both null 497 } 498 499 public boolean testEq31_3(MyValue1 v, MyInterface[] a) { 500 return get(v) == get(a); // only true if both null 501 } 502 503 public boolean testEq32_1(MyInterface[] a, MyValue1 v) { 504 return getNotNull(a) == (Object)v; // false 505 } 506 507 public boolean testEq32_2(MyInterface[] a, MyValue1 v) { 508 return a == getNotNull(v); // false 509 } 510 511 public boolean testEq32_3(MyInterface[] a, MyValue1 v) { 512 return getNotNull(a) == getNotNull(v); // false 513 } 514 515 public boolean testEq33_1(MyValue1 v, MyInterface[] a) { 516 return getNotNull(v) == a; // false 517 } 518 519 public boolean testEq33_2(MyValue1 v, MyInterface[] a) { 520 return (Object)v == getNotNull(a); // false 521 } 522 523 public boolean testEq33_3(MyValue1 v, MyInterface[] a) { 524 return getNotNull(v) == getNotNull(a); // false 525 } 526 527 528 // Null tests 529 530 public boolean testNull01_1(MyValue1 v) { 531 return (Object)v == null; // old acmp 532 } 533 534 public boolean testNull01_2(MyValue1 v) { 535 return get(v) == null; // old acmp 536 } 537 538 public boolean testNull01_3(MyValue1 v) { 539 return (Object)v == get((Object)null); // old acmp 540 } 541 542 public boolean testNull01_4(MyValue1 v) { 543 return get(v) == get((Object)null); // old acmp 544 } 545 546 public boolean testNull02_1(MyValue1 v) { 547 return null == (Object)v; // old acmp 548 } 549 550 public boolean testNull02_2(MyValue1 v) { 551 return get((Object)null) == (Object)v; // old acmp 552 } 553 554 public boolean testNull02_3(MyValue1 v) { 555 return null == get(v); // old acmp 556 } 557 558 public boolean testNull02_4(MyValue1 v) { 559 return get((Object)null) == get(v); // old acmp 560 } 561 562 public boolean testNull03_1(Object u) { 563 return u == null; // old acmp 564 } 565 566 public boolean testNull03_2(Object u) { 567 return get(u) == null; // old acmp 568 } 569 570 public boolean testNull03_3(Object u) { 571 return u == get((Object)null); // old acmp 572 } 573 574 public boolean testNull03_4(Object u) { 575 return get(u) == get((Object)null); // old acmp 576 } 577 578 public boolean testNull04_1(Object u) { 579 return null == u; // old acmp 580 } 581 582 public boolean testNull04_2(Object u) { 583 return get((Object)null) == u; // old acmp 584 } 585 586 public boolean testNull04_3(Object u) { 587 return null == get(u); // old acmp 588 } 589 590 public boolean testNull04_4(Object u) { 591 return get((Object)null) == get(u); // old acmp 592 } 593 594 public boolean testNull05_1(MyObject o) { 595 return o == null; // old acmp 596 } 597 598 public boolean testNull05_2(MyObject o) { 599 return get(o) == null; // old acmp 600 } 601 602 public boolean testNull05_3(MyObject o) { 603 return o == get((Object)null); // old acmp 604 } 605 606 public boolean testNull05_4(MyObject o) { 607 return get(o) == get((Object)null); // old acmp 608 } 609 610 public boolean testNull06_1(MyObject o) { 611 return null == o; // old acmp 612 } 613 614 public boolean testNull06_2(MyObject o) { 615 return get((Object)null) == o; // old acmp 616 } 617 618 public boolean testNull06_3(MyObject o) { 619 return null == get(o); // old acmp 620 } 621 622 public boolean testNull06_4(MyObject o) { 623 return get((Object)null) == get(o); // old acmp 624 } 625 626 public boolean testNull07_1(MyInterface u) { 627 return u == null; // old acmp 628 } 629 630 public boolean testNull07_2(MyInterface u) { 631 return get(u) == null; // old acmp 632 } 633 634 public boolean testNull07_3(MyInterface u) { 635 return u == get((Object)null); // old acmp 636 } 637 638 public boolean testNull07_4(MyInterface u) { 639 return get(u) == get((Object)null); // old acmp 640 } 641 642 public boolean testNull08_1(MyInterface u) { 643 return null == u; // old acmp 644 } 645 646 public boolean testNull08_2(MyInterface u) { 647 return get((Object)null) == u; // old acmp 648 } 649 650 public boolean testNull08_3(MyInterface u) { 651 return null == get(u); // old acmp 652 } 653 654 public boolean testNull08_4(MyInterface u) { 655 return get((Object)null) == get(u); // old acmp 656 } 657 658 // Same tests as above but negated 659 660 public boolean testNotEq01_1(Object u1, Object u2) { 661 return get(u1) != u2; // new acmp 662 } 663 664 public boolean testNotEq01_2(Object u1, Object u2) { 665 return u1 != get(u2); // new acmp 666 } 667 668 public boolean testNotEq01_3(Object u1, Object u2) { 669 return get(u1) != get(u2); // new acmp 670 } 671 672 @TrueIfNull 673 public boolean testNotEq01_4(Object u1, Object u2) { 674 return getNotNull(u1) != u2; // new acmp without null check 675 } 676 677 @TrueIfNull 678 public boolean testNotEq01_5(Object u1, Object u2) { 679 return u1 != getNotNull(u2); // new acmp without null check 680 } 681 682 @TrueIfNull 683 public boolean testNotEq01_6(Object u1, Object u2) { 684 return getNotNull(u1) != getNotNull(u2); // new acmp without null check 685 } 686 687 public boolean testNotEq02_1(MyValue1 v1, MyValue1 v2) { 688 return get(v1) != (Object)v2; // only false if both null 689 } 690 691 public boolean testNotEq02_2(MyValue1 v1, MyValue1 v2) { 692 return (Object)v1 != get(v2); // only false if both null 693 } 694 695 public boolean testNotEq02_3(MyValue1 v1, MyValue1 v2) { 696 return get(v1) != get(v2); // only false if both null 697 } 698 699 public boolean testNotEq03_1(MyValue1 v, Object u) { 700 return get(v) != u; // only false if both null 701 } 702 703 public boolean testNotEq03_2(MyValue1 v, Object u) { 704 return (Object)v != get(u); // only false if both null 705 } 706 707 public boolean testNotEq03_3(MyValue1 v, Object u) { 708 return get(v) != get(u); // only false if both null 709 } 710 711 public boolean testNotEq04_1(Object u, MyValue1 v) { 712 return get(u) != (Object)v; // only false if both null 713 } 714 715 public boolean testNotEq04_2(Object u, MyValue1 v) { 716 return u != get(v); // only false if both null 717 } 718 719 public boolean testNotEq04_3(Object u, MyValue1 v) { 720 return get(u) != get(v); // only false if both null 721 } 722 723 public boolean testNotEq05_1(MyObject o, MyValue1 v) { 724 return get(o) != (Object)v; // only false if both null 725 } 726 727 public boolean testNotEq05_2(MyObject o, MyValue1 v) { 728 return o != get(v); // only false if both null 729 } 730 731 public boolean testNotEq05_3(MyObject o, MyValue1 v) { 732 return get(o) != get(v); // only false if both null 733 } 734 735 public boolean testNotEq06_1(MyValue1 v, MyObject o) { 736 return get(v) != o; // only false if both null 737 } 738 739 public boolean testNotEq06_2(MyValue1 v, MyObject o) { 740 return (Object)v != get(o); // only false if both null 741 } 742 743 public boolean testNotEq06_3(MyValue1 v, MyObject o) { 744 return get(v) != get(o); // only false if both null 745 } 746 747 public boolean testNotEq07_1(MyValue1 v1, MyValue1 v2) { 748 return getNotNull(v1) != (Object)v2; // true 749 } 750 751 public boolean testNotEq07_2(MyValue1 v1, MyValue1 v2) { 752 return (Object)v1 != getNotNull(v2); // true 753 } 754 755 public boolean testNotEq07_3(MyValue1 v1, MyValue1 v2) { 756 return getNotNull(v1) != getNotNull(v2); // true 757 } 758 759 public boolean testNotEq08_1(MyValue1 v, Object u) { 760 return getNotNull(v) != u; // true 761 } 762 763 public boolean testNotEq08_2(MyValue1 v, Object u) { 764 return (Object)v != getNotNull(u); // true 765 } 766 767 public boolean testNotEq08_3(MyValue1 v, Object u) { 768 return getNotNull(v) != getNotNull(u); // true 769 } 770 771 public boolean testNotEq09_1(Object u, MyValue1 v) { 772 return getNotNull(u) != (Object)v; // true 773 } 774 775 public boolean testNotEq09_2(Object u, MyValue1 v) { 776 return u != getNotNull(v); // true 777 } 778 779 public boolean testNotEq09_3(Object u, MyValue1 v) { 780 return getNotNull(u) != getNotNull(v); // true 781 } 782 783 public boolean testNotEq10_1(MyObject o, MyValue1 v) { 784 return getNotNull(o) != (Object)v; // true 785 } 786 787 public boolean testNotEq10_2(MyObject o, MyValue1 v) { 788 return o != getNotNull(v); // true 789 } 790 791 public boolean testNotEq10_3(MyObject o, MyValue1 v) { 792 return getNotNull(o) != getNotNull(v); // true 793 } 794 795 public boolean testNotEq11_1(MyValue1 v, MyObject o) { 796 return getNotNull(v) != o; // true 797 } 798 799 public boolean testNotEq11_2(MyValue1 v, MyObject o) { 800 return (Object)v != getNotNull(o); // true 801 } 802 803 public boolean testNotEq11_3(MyValue1 v, MyObject o) { 804 return getNotNull(v) != getNotNull(o); // true 805 } 806 807 public boolean testNotEq12_1(MyObject o1, MyObject o2) { 808 return get(o1) != o2; // old acmp 809 } 810 811 public boolean testNotEq12_2(MyObject o1, MyObject o2) { 812 return o1 != get(o2); // old acmp 813 } 814 815 public boolean testNotEq12_3(MyObject o1, MyObject o2) { 816 return get(o1) != get(o2); // old acmp 817 } 818 819 public boolean testNotEq13_1(Object u, MyObject o) { 820 return get(u) != o; // old acmp 821 } 822 823 public boolean testNotEq13_2(Object u, MyObject o) { 824 return u != get(o); // old acmp 825 } 826 827 public boolean testNotEq13_3(Object u, MyObject o) { 828 return get(u) != get(o); // old acmp 829 } 830 831 public boolean testNotEq14_1(MyObject o, Object u) { 832 return get(o) != u; // old acmp 833 } 834 835 public boolean testNotEq14_2(MyObject o, Object u) { 836 return o != get(u); // old acmp 837 } 838 839 public boolean testNotEq14_3(MyObject o, Object u) { 840 return get(o) != get(u); // old acmp 841 } 842 843 public boolean testNotEq15_1(Object[] a, Object u) { 844 return get(a) != u; // old acmp 845 } 846 847 public boolean testNotEq15_2(Object[] a, Object u) { 848 return a != get(u); // old acmp 849 } 850 851 public boolean testNotEq15_3(Object[] a, Object u) { 852 return get(a) != get(u); // old acmp 853 } 854 855 public boolean testNotEq16_1(Object u, Object[] a) { 856 return get(u) != a; // old acmp 857 } 858 859 public boolean testNotEq16_2(Object u, Object[] a) { 860 return u != get(a); // old acmp 861 } 862 863 public boolean testNotEq16_3(Object u, Object[] a) { 864 return get(u) != get(a); // old acmp 865 } 866 867 public boolean testNotEq17_1(Object[] a, MyValue1 v) { 868 return get(a) != (Object)v; // only false if both null 869 } 870 871 public boolean testNotEq17_2(Object[] a, MyValue1 v) { 872 return a != get(v); // only false if both null 873 } 874 875 public boolean testNotEq17_3(Object[] a, MyValue1 v) { 876 return get(a) != get(v); // only false if both null 877 } 878 879 public boolean testNotEq18_1(MyValue1 v, Object[] a) { 880 return get(v) != a; // only false if both null 881 } 882 883 public boolean testNotEq18_2(MyValue1 v, Object[] a) { 884 return (Object)v != get(a); // only false if both null 885 } 886 887 public boolean testNotEq18_3(MyValue1 v, Object[] a) { 888 return get(v) != get(a); // only false if both null 889 } 890 891 public boolean testNotEq19_1(Object[] a, MyValue1 v) { 892 return getNotNull(a) != (Object)v; // true 893 } 894 895 public boolean testNotEq19_2(Object[] a, MyValue1 v) { 896 return a != getNotNull(v); // true 897 } 898 899 public boolean testNotEq19_3(Object[] a, MyValue1 v) { 900 return getNotNull(a) != getNotNull(v); // true 901 } 902 903 public boolean testNotEq20_1(MyValue1 v, Object[] a) { 904 return getNotNull(v) != a; // true 905 } 906 907 public boolean testNotEq20_2(MyValue1 v, Object[] a) { 908 return (Object)v != getNotNull(a); // true 909 } 910 911 public boolean testNotEq20_3(MyValue1 v, Object[] a) { 912 return getNotNull(v) != getNotNull(a); // true 913 } 914 915 public boolean testNotEq21_1(MyInterface u1, MyInterface u2) { 916 return get(u1) != u2; // new acmp 917 } 918 919 public boolean testNotEq21_2(MyInterface u1, MyInterface u2) { 920 return u1 != get(u2); // new acmp 921 } 922 923 public boolean testNotEq21_3(MyInterface u1, MyInterface u2) { 924 return get(u1) != get(u2); // new acmp 925 } 926 927 @TrueIfNull 928 public boolean testNotEq21_4(MyInterface u1, MyInterface u2) { 929 return getNotNull(u1) != u2; // new acmp without null check 930 } 931 932 @TrueIfNull 933 public boolean testNotEq21_5(MyInterface u1, MyInterface u2) { 934 return u1 != getNotNull(u2); // new acmp without null check 935 } 936 937 @TrueIfNull 938 public boolean testNotEq21_6(MyInterface u1, MyInterface u2) { 939 return getNotNull(u1) != getNotNull(u2); // new acmp without null check 940 } 941 942 public boolean testNotEq22_1(MyValue1 v, MyInterface u) { 943 return get(v) != u; // only false if both null 944 } 945 946 public boolean testNotEq22_2(MyValue1 v, MyInterface u) { 947 return (Object)v != get(u); // only false if both null 948 } 949 950 public boolean testNotEq22_3(MyValue1 v, MyInterface u) { 951 return get(v) != get(u); // only false if both null 952 } 953 954 public boolean testNotEq23_1(MyInterface u, MyValue1 v) { 955 return get(u) != (Object)v; // only false if both null 956 } 957 958 public boolean testNotEq23_2(MyInterface u, MyValue1 v) { 959 return u != get(v); // only false if both null 960 } 961 962 public boolean testNotEq23_3(MyInterface u, MyValue1 v) { 963 return get(u) != get(v); // only false if both null 964 } 965 966 public boolean testNotEq24_1(MyValue1 v, MyInterface u) { 967 return getNotNull(v) != u; // true 968 } 969 970 public boolean testNotEq24_2(MyValue1 v, MyInterface u) { 971 return (Object)v != getNotNull(u); // true 972 } 973 974 public boolean testNotEq24_3(MyValue1 v, MyInterface u) { 975 return getNotNull(v) != getNotNull(u); // true 976 } 977 978 public boolean testNotEq25_1(MyInterface u, MyValue1 v) { 979 return getNotNull(u) != (Object)v; // true 980 } 981 982 public boolean testNotEq25_2(MyInterface u, MyValue1 v) { 983 return u != getNotNull(v); // true 984 } 985 986 public boolean testNotEq25_3(MyInterface u, MyValue1 v) { 987 return getNotNull(u) != getNotNull(v); // true 988 } 989 990 public boolean testNotEq26_1(MyInterface u, MyObject o) { 991 return get(u) != o; // old acmp 992 } 993 994 public boolean testNotEq26_2(MyInterface u, MyObject o) { 995 return u != get(o); // old acmp 996 } 997 998 public boolean testNotEq26_3(MyInterface u, MyObject o) { 999 return get(u) != get(o); // old acmp 1000 } 1001 1002 public boolean testNotEq27_1(MyObject o, MyInterface u) { 1003 return get(o) != u; // old acmp 1004 } 1005 1006 public boolean testNotEq27_2(MyObject o, MyInterface u) { 1007 return o != get(u); // old acmp 1008 } 1009 1010 public boolean testNotEq27_3(MyObject o, MyInterface u) { 1011 return get(o) != get(u); // old acmp 1012 } 1013 1014 public boolean testNotEq28_1(MyInterface[] a, MyInterface u) { 1015 return get(a) != u; // old acmp 1016 } 1017 1018 public boolean testNotEq28_2(MyInterface[] a, MyInterface u) { 1019 return a != get(u); // old acmp 1020 } 1021 1022 public boolean testNotEq28_3(MyInterface[] a, MyInterface u) { 1023 return get(a) != get(u); // old acmp 1024 } 1025 1026 public boolean testNotEq29_1(MyInterface u, MyInterface[] a) { 1027 return get(u) != a; // old acmp 1028 } 1029 1030 public boolean testNotEq29_2(MyInterface u, MyInterface[] a) { 1031 return u != get(a); // old acmp 1032 } 1033 1034 public boolean testNotEq29_3(MyInterface u, MyInterface[] a) { 1035 return get(u) != get(a); // old acmp 1036 } 1037 1038 public boolean testNotEq30_1(MyInterface[] a, MyValue1 v) { 1039 return get(a) != (Object)v; // only false if both null 1040 } 1041 1042 public boolean testNotEq30_2(MyInterface[] a, MyValue1 v) { 1043 return a != get(v); // only false if both null 1044 } 1045 1046 public boolean testNotEq30_3(MyInterface[] a, MyValue1 v) { 1047 return get(a) != get(v); // only false if both null 1048 } 1049 1050 public boolean testNotEq31_1(MyValue1 v, MyInterface[] a) { 1051 return get(v) != a; // only false if both null 1052 } 1053 1054 public boolean testNotEq31_2(MyValue1 v, MyInterface[] a) { 1055 return (Object)v != get(a); // only false if both null 1056 } 1057 1058 public boolean testNotEq31_3(MyValue1 v, MyInterface[] a) { 1059 return get(v) != get(a); // only false if both null 1060 } 1061 1062 public boolean testNotEq32_1(MyInterface[] a, MyValue1 v) { 1063 return getNotNull(a) != (Object)v; // true 1064 } 1065 1066 public boolean testNotEq32_2(MyInterface[] a, MyValue1 v) { 1067 return a != getNotNull(v); // true 1068 } 1069 1070 public boolean testNotEq32_3(MyInterface[] a, MyValue1 v) { 1071 return getNotNull(a) != getNotNull(v); // true 1072 } 1073 1074 public boolean testNotEq33_1(MyValue1 v, MyInterface[] a) { 1075 return getNotNull(v) != a; // true 1076 } 1077 1078 public boolean testNotEq33_2(MyValue1 v, MyInterface[] a) { 1079 return (Object)v != getNotNull(a); // true 1080 } 1081 1082 public boolean testNotEq33_3(MyValue1 v, MyInterface[] a) { 1083 return getNotNull(v) != getNotNull(a); // true 1084 } 1085 1086 // Null tests 1087 1088 public boolean testNotNull01_1(MyValue1 v) { 1089 return (Object)v != null; // old acmp 1090 } 1091 1092 public boolean testNotNull01_2(MyValue1 v) { 1093 return get(v) != null; // old acmp 1094 } 1095 1096 public boolean testNotNull01_3(MyValue1 v) { 1097 return (Object)v != get((Object)null); // old acmp 1098 } 1099 1100 public boolean testNotNull01_4(MyValue1 v) { 1101 return get(v) != get((Object)null); // old acmp 1102 } 1103 1104 public boolean testNotNull02_1(MyValue1 v) { 1105 return null != (Object)v; // old acmp 1106 } 1107 1108 public boolean testNotNull02_2(MyValue1 v) { 1109 return get((Object)null) != (Object)v; // old acmp 1110 } 1111 1112 public boolean testNotNull02_3(MyValue1 v) { 1113 return null != get(v); // old acmp 1114 } 1115 1116 public boolean testNotNull02_4(MyValue1 v) { 1117 return get((Object)null) != get(v); // old acmp 1118 } 1119 1120 public boolean testNotNull03_1(Object u) { 1121 return u != null; // old acmp 1122 } 1123 1124 public boolean testNotNull03_2(Object u) { 1125 return get(u) != null; // old acmp 1126 } 1127 1128 public boolean testNotNull03_3(Object u) { 1129 return u != get((Object)null); // old acmp 1130 } 1131 1132 public boolean testNotNull03_4(Object u) { 1133 return get(u) != get((Object)null); // old acmp 1134 } 1135 1136 public boolean testNotNull04_1(Object u) { 1137 return null != u; // old acmp 1138 } 1139 1140 public boolean testNotNull04_2(Object u) { 1141 return get((Object)null) != u; // old acmp 1142 } 1143 1144 public boolean testNotNull04_3(Object u) { 1145 return null != get(u); // old acmp 1146 } 1147 1148 public boolean testNotNull04_4(Object u) { 1149 return get((Object)null) != get(u); // old acmp 1150 } 1151 1152 public boolean testNotNull05_1(MyObject o) { 1153 return o != null; // old acmp 1154 } 1155 1156 public boolean testNotNull05_2(MyObject o) { 1157 return get(o) != null; // old acmp 1158 } 1159 1160 public boolean testNotNull05_3(MyObject o) { 1161 return o != get((Object)null); // old acmp 1162 } 1163 1164 public boolean testNotNull05_4(MyObject o) { 1165 return get(o) != get((Object)null); // old acmp 1166 } 1167 1168 public boolean testNotNull06_1(MyObject o) { 1169 return null != o; // old acmp 1170 } 1171 1172 public boolean testNotNull06_2(MyObject o) { 1173 return get((Object)null) != o; // old acmp 1174 } 1175 1176 public boolean testNotNull06_3(MyObject o) { 1177 return null != get(o); // old acmp 1178 } 1179 1180 public boolean testNotNull06_4(MyObject o) { 1181 return get((Object)null) != get(o); // old acmp 1182 } 1183 1184 public boolean testNotNull07_1(MyInterface u) { 1185 return u != null; // old acmp 1186 } 1187 1188 public boolean testNotNull07_2(MyInterface u) { 1189 return get(u) != null; // old acmp 1190 } 1191 1192 public boolean testNotNull07_3(MyInterface u) { 1193 return u != get((Object)null); // old acmp 1194 } 1195 1196 public boolean testNotNull07_4(MyInterface u) { 1197 return get(u) != get((Object)null); // old acmp 1198 } 1199 1200 public boolean testNotNull08_1(MyInterface u) { 1201 return null != u; // old acmp 1202 } 1203 1204 public boolean testNotNull08_2(MyInterface u) { 1205 return get((Object)null) != u; // old acmp 1206 } 1207 1208 public boolean testNotNull08_3(MyInterface u) { 1209 return null != get(u); // old acmp 1210 } 1211 1212 public boolean testNotNull08_4(MyInterface u) { 1213 return get((Object)null) != get(u); // old acmp 1214 } 1215 1216 // The following methods are used with -XX:+AlwaysIncrementalInline to hide exact types during parsing 1217 1218 public Object get(Object u) { 1219 return u; 1220 } 1221 1222 public Object getNotNull(Object u) { 1223 return (u != null) ? u : new Object(); 1224 } 1225 1226 public Object get(MyValue1 v) { 1227 return v; 1228 } 1229 1230 public Object getNotNull(MyValue1 v) { 1231 return ((Object)v != null) ? v : MyValue1.createDefault(); 1232 } 1233 1234 public Object get(MyObject o) { 1235 return o; 1236 } 1237 1238 public Object getNotNull(MyObject o) { 1239 return (o != null) ? o : MyValue1.createDefault(); 1240 } 1241 1242 public Object get(Object[] a) { 1243 return a; 1244 } 1245 1246 public Object getNotNull(Object[] a) { 1247 return (a != null) ? a : new Object[1]; 1248 } 1249 1250 public boolean trueIfNull(Method m) { 1251 return m.isAnnotationPresent(TrueIfNull.class); 1252 } 1253 1254 public boolean falseIfNull(Method m) { 1255 return m.isAnnotationPresent(FalseIfNull.class); 1256 } 1257 1258 public boolean isNegated(Method m) { 1259 return m.getName().startsWith("testNot"); 1260 } 1261 1262 // Tests with profiling 1263 public boolean cmpAlwaysEqual1(Object a, Object b) { 1264 return a == b; 1265 } 1266 1267 public boolean cmpAlwaysEqual2(Object a, Object b) { 1268 return a != b; 1269 } 1270 1271 public boolean cmpAlwaysEqual3(Object a) { 1272 return a == a; 1273 } 1274 1275 public boolean cmpAlwaysEqual4(Object a) { 1276 return a != a; 1277 } 1278 1279 public boolean cmpAlwaysUnEqual1(Object a, Object b) { 1280 return a == b; 1281 } 1282 1283 public boolean cmpAlwaysUnEqual2(Object a, Object b) { 1284 return a != b; 1285 } 1286 1287 public boolean cmpAlwaysUnEqual3(Object a) { 1288 return a == a; 1289 } 1290 1291 public boolean cmpAlwaysUnEqual4(Object a) { 1292 return a != a; 1293 } 1294 1295 public boolean cmpSometimesEqual1(Object a) { 1296 return a == a; 1297 } 1298 1299 public boolean cmpSometimesEqual2(Object a) { 1300 return a != a; 1301 } 1302 1303 static int get_full_opt_level() { 1304 int n = (int)TieredStopAtLevel; 1305 if (n >= 4) { 1306 n = 4; 1307 } 1308 return n; 1309 } 1310 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); 1311 protected static final long TieredStopAtLevel = (Long)WHITE_BOX.getVMFlag("TieredStopAtLevel"); 1312 protected static final int COMP_LEVEL_FULL_OPTIMIZATION = get_full_opt_level(); 1313 1314 // FIXME: temp -- special handling for C1 testing. 1315 protected static final boolean EnableValhallaC1 = (Boolean)WHITE_BOX.getVMFlag("EnableValhallaC1"); 1316 1317 public void runTest(Method m, Object[] args, int warmup, int nullMode, boolean[][] equalities) throws Exception { 1318 Class<?>[] parameterTypes = m.getParameterTypes(); 1319 int parameterCount = parameterTypes.length; 1320 // Nullness mode for first argument 1321 // 0: default, 1: never null, 2: always null 1322 int start = (nullMode != 1) ? 0 : 1; 1323 int end = (nullMode != 2) ? args.length : 1; 1324 for (int i = start; i < end; ++i) { 1325 if (args[i] != null && !parameterTypes[0].isInstance(args[i])) { 1326 continue; 1327 } 1328 if (args[i] == null && parameterTypes[0] == MyValue1.class) { 1329 continue; 1330 } 1331 if (parameterCount == 1) { 1332 // Null checks 1333 System.out.print("Testing " + m.getName() + "(" + args[i] + ")"); 1334 // Avoid acmp in the computation of the expected result! 1335 boolean expected = isNegated(m) ? (i != 0) : (i == 0); 1336 for (int run = 0; run < warmup; ++run) { 1337 Boolean result = (Boolean)m.invoke(this, args[i]); 1338 if (result != expected && WHITE_BOX.isMethodCompiled(m, false)) { 1339 System.out.println(" = " + result); 1340 throw new RuntimeException("Test failed: should return " + expected); 1341 } 1342 } 1343 System.out.println(" = " + expected); 1344 } else { 1345 // Equality checks 1346 for (int j = 0; j < args.length; ++j) { 1347 if (args[j] != null && !parameterTypes[1].isInstance(args[j])) { 1348 continue; 1349 } 1350 if (args[j] == null && parameterTypes[1] == MyValue1.class) { 1351 continue; 1352 } 1353 System.out.print("Testing " + m.getName() + "(" + args[i] + ", " + args[j] + ")"); 1354 // Avoid acmp in the computation of the expected result! 1355 boolean equal = equalities[i][j]; 1356 equal = isNegated(m) ? !equal : equal; 1357 boolean expected = ((i == 0 || j == 0) && trueIfNull(m)) || (equal && !(i == 0 && falseIfNull(m))); 1358 for (int run = 0; run < warmup; ++run) { 1359 Boolean result = (Boolean)m.invoke(this, args[i], args[j]); 1360 if (result != expected && WHITE_BOX.isMethodCompiled(m, false) && warmup == 1) { 1361 System.out.println(" = " + result); 1362 throw new RuntimeException("Test failed: should return " + expected); 1363 } 1364 } 1365 System.out.println(" = " + expected); 1366 } 1367 } 1368 } 1369 } 1370 1371 public void run(int nullMode) throws Exception { 1372 // Prepare test arguments 1373 Object[] args = { null, 1374 new Object(), 1375 new MyObject(), 1376 MyValue1.setX(MyValue1.createDefault(), 42), 1377 new Object[10], 1378 new MyObject[10], 1379 MyValue1.setX(MyValue1.createDefault(), 0x42), 1380 MyValue1.setX(MyValue1.createDefault(), 42), 1381 MyValue2.setX(MyValue2.createDefault(), 42), }; 1382 1383 boolean[][] equalities = { { true, false, false, false, false, false, false, false, false }, 1384 { false, true, false, false, false, false, false, false, false }, 1385 { false, false, true, false, false, false, false, false, false }, 1386 { false, false, false, true, false, false, false, true, false }, 1387 { false, false, false, false, true, false, false, false, false }, 1388 { false, false, false, false, false, true, false, false, false }, 1389 { false, false, false, false, false, false, true, false, false }, 1390 { false, false, false, true, false, false, false, true, false }, 1391 { false, false, false, false, false, false, false, false, true } }; 1392 1393 // Run tests 1394 for (Method m : getClass().getMethods()) { 1395 if (m.getName().startsWith("test")) { 1396 // Do some warmup runs 1397 runTest(m, args, 1000, nullMode, equalities); 1398 // Make sure method is compiled 1399 WHITE_BOX.enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); 1400 Asserts.assertTrue(WHITE_BOX.isMethodCompiled(m, false), m + " not compiled"); 1401 // Run again to verify correctness of compiled code 1402 runTest(m, args, 1, nullMode, equalities); 1403 } 1404 } 1405 1406 Method cmpAlwaysUnEqual3_m = getClass().getMethod("cmpAlwaysUnEqual3", Object.class); 1407 Method cmpAlwaysUnEqual4_m = getClass().getMethod("cmpAlwaysUnEqual4", Object.class); 1408 Method cmpSometimesEqual1_m = getClass().getMethod("cmpSometimesEqual1", Object.class); 1409 Method cmpSometimesEqual2_m = getClass().getMethod("cmpSometimesEqual2", Object.class); 1410 1411 for (int i = 0; i < 20_000; ++i) { 1412 Asserts.assertTrue(cmpAlwaysEqual1(args[1], args[1])); 1413 Asserts.assertFalse(cmpAlwaysEqual2(args[1], args[1])); 1414 Asserts.assertTrue(cmpAlwaysEqual3(args[1])); 1415 Asserts.assertFalse(cmpAlwaysEqual4(args[1])); 1416 1417 Asserts.assertFalse(cmpAlwaysUnEqual1(args[1], args[2])); 1418 Asserts.assertTrue(cmpAlwaysUnEqual2(args[1], args[2])); 1419 boolean res = cmpAlwaysUnEqual3(args[3]); 1420 Asserts.assertTrue(res); 1421 res = cmpAlwaysUnEqual4(args[3]); 1422 Asserts.assertFalse(res); 1423 1424 int idx = i % args.length; 1425 res = cmpSometimesEqual1(args[idx]); 1426 Asserts.assertTrue(res); 1427 res = cmpSometimesEqual2(args[idx]); 1428 Asserts.assertFalse(res); 1429 } 1430 } 1431 1432 public static void main(String[] args) throws Exception { 1433 if (args.length == 0) { 1434 enumerateVMOptions(); 1435 } else { 1436 int nullMode = Integer.valueOf(args[0]); 1437 TestNewAcmp t = new TestNewAcmp(); 1438 t.run(nullMode); 1439 } 1440 } 1441 1442 private static String[] addOptions(String prefix[], String... extra) { 1443 ArrayList<String> list = new ArrayList<String>(); 1444 if (prefix != null) { 1445 for (String s : prefix) { 1446 list.add(s); 1447 } 1448 } 1449 if (extra != null) { 1450 for (String s : extra) { 1451 System.out.println(" " + s); 1452 list.add(s); 1453 } 1454 } 1455 1456 return list.toArray(new String[list.size()]); 1457 } 1458 1459 private static void enumerateVMOptions() throws Exception { 1460 String[] baseOptions = { 1461 "-Xbootclasspath/a:.", 1462 "-XX:+UnlockDiagnosticVMOptions", 1463 "-XX:+WhiteBoxAPI", 1464 "-Xbatch", 1465 "-XX:TypeProfileLevel=222", 1466 "-XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*", 1467 "-XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*"}; 1468 1469 String SCENARIOS = System.getProperty("Scenarios", ""); 1470 List<String> scenarios = null; 1471 if (!SCENARIOS.isEmpty()) { 1472 scenarios = Arrays.asList(SCENARIOS.split(",")); 1473 } 1474 1475 int scenario = -1; 1476 for (int nullMode = 0; nullMode <= 2; nullMode++) { // null mode 1477 for (int incrInline = 0; incrInline < 2; incrInline++) { // 0 = default, 1 = -XX:+AlwaysIncrementalInline 1478 scenario++; 1479 System.out.println("Scenario #" + scenario + " -------------------"); 1480 String[] cmds = baseOptions; 1481 if (incrInline != 0) { 1482 cmds = addOptions(cmds, "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AlwaysIncrementalInline"); 1483 } 1484 1485 cmds = addOptions(cmds, "compiler.valhalla.valuetypes.TestNewAcmp"); 1486 cmds = addOptions(cmds, Integer.toString(nullMode)); 1487 1488 if (scenarios != null && !scenarios.contains(Integer.toString(scenario))) { 1489 System.out.println("Scenario #" + scenario + " is skipped due to -Dscenarios=" + SCENARIOS); 1490 continue; 1491 } 1492 1493 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); 1494 String output = oa.getOutput(); 1495 oa.shouldHaveExitValue(0); 1496 System.out.println(output); 1497 } 1498 } 1499 } 1500 }