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