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