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