Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8183929

[MVT] Bad intrinsic for guard with test causes wrong behavior

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • repo-valhalla
    • None
    • core-libs

      The simple test below passes with the revision right before JDK-8183130 and
      fails (detects incorrect result) with JDK-8183130. It passes again if I
      change:

      vt.verify(test94_bool ? test94_vt1 : test94_vt2);

      to:

      vt.verify(test94_bool ? test94_vt2 : test94_vt1);

      which is obviously incorrect.

      Roland.

      diff --git a/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java b/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
      --- a/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
      +++ b/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
      @@ -2422,6 +2422,14 @@
       
                   MethodType test86_mt = MethodType.fromMethodDescriptorString("(Qcompiler/valhalla/valuetypes/MyValue1;)I", ValueTypeTestBench.class.getClassLoader());
                   test86_mh = lookup.findVirtual(ValueTypeTestBench.class, "test86_target", test86_mt);
      +
      + MethodType test94_mt = MethodType.fromMethodDescriptorString("()Qcompiler/valhalla/valuetypes/MyValue3;", ValueTypeTestBench.class.getClassLoader());
      + MethodHandle test94_mh1 = lookup.findVirtual(ValueTypeTestBench.class, "test94_target1", test94_mt);
      + MethodHandle test94_mh2 = lookup.findVirtual(ValueTypeTestBench.class, "test94_target2", test94_mt);
      + MethodType test94_mt2 = MethodType.methodType(boolean.class);
      + MethodHandle test94_mh_test = lookup.findVirtual(ValueTypeTestBench.class, "test94_test", test94_mt2);
      + test94_mh = MethodHandles.guardWithTest(test94_mh_test, test94_mh1, test94_mh2);
      +
               } catch (NoSuchMethodException|IllegalAccessException e) {
                   throw new RuntimeException("method handle lookup fails");
               }
      @@ -2605,6 +2613,40 @@
               Asserts.assertEQ(result, 0L);
           }
       
      + // method handle combinators
      + final MyValue3 test94_vt1 = MyValue3.create();
      + @ForceInline
      + MyValue3 test94_target1() {
      + return test94_vt1;
      + }
      +
      + final MyValue3 test94_vt2 = MyValue3.create();
      + @ForceInline
      + MyValue3 test94_target2() {
      + return test94_vt2;
      + }
      +
      + boolean test94_bool = true;
      + @ForceInline
      + boolean test94_test() {
      + return test94_bool;
      + }
      +
      + static final MethodHandle test94_mh;
      +
      + @Test
      + MyValue3 test94() throws Throwable {
      + return (MyValue3)test94_mh.invokeExact(this);
      + }
      +
      + @DontCompile
      + public void test94_verifier(boolean warmup) throws Throwable {
      + test94_bool = !test94_bool;
      + MyValue3 vt = test94();
      + vt.verify(test94_bool ? test94_vt1 : test94_vt2);
      + }
      +
      +
           // ========== Test infrastructure ==========
       
           private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
      @@ -2679,7 +2721,7 @@
           }
       
           public static void main(String[] args) throws Throwable {
      - //tests.values().removeIf(p -> !p.getName().equals("test85")); // Run single test
      + tests.values().removeIf(p -> !p.getName().equals("test94")); // Run single test
               if (args.length == 0) {
                   execute_vm("-XX:+IgnoreUnrecognizedVMOptions", "-XX:-BackgroundCompilation",
                           "-XX:+PrintCompilation", "-XX:+PrintInlining", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: