compiler/cha/TypeProfileFinalMethod.java fails with assertEquals expected: 0 but was: 2

XMLWordPrintable

    • b24
    • x86_64, aarch64
    • linux, windows

      ## Failure Analysis

      The failing `assertEquals` checks how many times `compiler.cha.TypeProfileFinalMethod$Child1::m` gets inlined in C2 compilations of `compiler.cha.TypeProfileFinalMethod$Launcher::test2`. However, `test2` is not always compiled as the test author likely intends. This is especially noticeable with `-Xcomp`, when the method gets inlined in `compiler.cha.TypeProfileFinalMethod$Launcher::main` and subsequently does not get compiled at all:

      ```
      4746 2441 b 3 compiler.cha.TypeProfileFinalMethod$Launcher::main (79 bytes)
                                    @ 0 compiler.cha.TypeProfileFinalMethod$Launcher::addCompilerDirectives (59 bytes) failed to inline: callee is too large
                                    @ 15 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes) failed to inline: callee is too large
                                    @ 33 compiler.cha.TypeProfileFinalMethod$Launcher::test2 (5 bytes) inline
                                      @ 1 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes) failed to inline: callee is too large
                                    @ 47 compiler.cha.TypeProfileFinalMethod$Child2::<init> (5 bytes) failed to inline: callee's klass not linked yet
                                    @ 56 java/io/PrintStream::println (not loaded) failed to inline: not inlineable
                                    @ 68 compiler.cha.TypeProfileFinalMethod$Launcher::test2 (5 bytes) inline
                                      @ 1 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes) failed to inline: callee is too large
      4747 2442 b 3 compiler.cha.TypeProfileFinalMethod$Launcher::addCompilerDirectives (59 bytes)
                                    @ 0 jdk/test/whitebox/WhiteBox::getWhiteBox (not loaded) failed to inline: not inlineable
                                    @ 6 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 11 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 14 java/lang/invoke/MethodHandle::invokeBasic (not loaded) failed to inline: not inlineable
                                    @ 22 jdk/test/whitebox/WhiteBox::addCompilerDirective (not loaded) failed to inline: not inlineable
                                    @ 28 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 33 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 38 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 43 java/lang/Class::getName (not loaded) failed to inline: not inlineable
                                    @ 46 java/lang/invoke/MethodHandle::invokeBasic (not loaded) failed to inline: not inlineable
                                    @ 54 jdk/test/whitebox/WhiteBox::addCompilerDirective (not loaded) failed to inline: not inlineable
      4748 2443 b 4 compiler.cha.TypeProfileFinalMethod$Launcher::addCompilerDirectives (59 bytes)
      1 compiler directives added
      1 compiler directives added
      1 compiler directives added
      1 compiler directives added
      5630 2667 b 3 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes)
                                    @ 2 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes) failed to inline: disallowed by CompileCommand
                                    @ 14 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: no static binding
                                    @ 28 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: no static binding
      5631 2668 b 3 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes)
                                    @ 4 compiler.cha.TypeProfileFinalMethod$Child1::<init> (5 bytes) failed to inline: callee's klass not linked yet
      5635 2672 b 4 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes)
                                    @ 2 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes) failed to inline: disallowed by CompileCommand
                                    @ 14 compiler.cha.TypeProfileFinalMethod$Child1::m (2 bytes) inline (hot)
                                    @ 28 compiler.cha.TypeProfileFinalMethod$Child1::m (2 bytes) inline (hot)
      5640 2673 b 4 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes)
                                    @ 4 compiler.cha.TypeProfileFinalMethod$Child1::<init> (5 bytes) inline (hot)
                                      @ 1 compiler.cha.TypeProfileFinalMethod$Parent::<init> (5 bytes) failed to inline: failed initial checks
      ======== break CHA
      5694 2724 b 3 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes)
                                    @ 2 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes) failed to inline: disallowed by CompileCommand
                                    @ 14 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: no static binding
                                    @ 28 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: no static binding
      5695 2725 b 4 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes)
                                    @ 2 compiler.cha.TypeProfileFinalMethod$Launcher::getInstance (8 bytes) failed to inline: disallowed by CompileCommand
                                    @ 14 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: virtual call
                                    @ 28 compiler.cha.TypeProfileFinalMethod$Parent::m (0 bytes) failed to inline: virtual call
      ```

      As such, the assert fails.

      In general, the test can fail even if `test2` is C2 compiled due to not inlining `test1` in `test2` as the test author expects. It is unclear exactly under which circumstances this occurs, but we can fix it by simply force-inlining `test1` in `test2`.

      ## Original Description

      The following test failed in the JDK24 CI:

      compiler/cha/TypeProfileFinalMethod.java

      Here's a snippet from the log file:

      #section:driver
      ----------messages:(7/266)----------
      command: driver compiler.cha.TypeProfileFinalMethod
      reason: User specified action: run driver compiler.cha.TypeProfileFinalMethod
      started: Thu Sep 26 05:21:20 UTC 2024
      Mode: agentvm
      Agent id: 14
      finished: Thu Sep 26 05:21:35 UTC 2024
      elapsed time (seconds): 14.222
      ----------configuration:(14/1910)----------

      <snip>

      ----------System.out:(14/2851)----------
      Command line: [/opt/mach5/mesos/work_dir/jib-master/install/jdk-24+17-1928/linux-x64-debug.jdk/jdk-24/fastdebug/bin/java -cp /opt/mach5/mesos/work_dir/slaves/f5c641a8-8835-4313-b2e9-9724f4dc0f29-S1568/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/b8804081-c132-43c1-9653-1ca6a7fcbc39/runs/e7f89e99-abf2-4a56-a722-99088a107100/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_not_fast_compiler/classes/0/compiler/cha/TypeProfileFinalMethod.d:/opt/mach5/mesos/work_dir/jib-master/install/jdk-24+17-1928/src.full/open/test/hotspot/jtreg/compiler/cha:/opt/mach5/mesos/work_dir/slaves/f5c641a8-8835-4313-b2e9-9724f4dc0f29-S1568/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/b8804081-c132-43c1-9653-1ca6a7fcbc39/runs/e7f89e99-abf2-4a56-a722-99088a107100/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_not_fast_compiler/classes/0/test/lib:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.4/1/bundles/jtreg-7.4+1.zip/jtreg/lib/jtreg.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.4/1/bundles/jtreg-7.4+1.zip/jtreg/lib/junit-platform-console-standalone-1.10.2.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.4/1/bundles/jtreg-7.4+1.zip/jtreg/lib/testng-7.3.0.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.4/1/bundles/jtreg-7.4+1.zip/jtreg/lib/jcommander-1.82.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/7.4/1/bundles/jtreg-7.4+1.zip/jtreg/lib/guice-5.1.0.jar -XX:MaxRAMPercentage=4.16667 -Dtest.boot.jdk=/opt/mach5/mesos/work_dir/jib-master/install/jdk/22/36/bundles/linux-x64/jdk-22_linux-x64_bin.tar.gz/jdk-22 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/f5c641a8-8835-4313-b2e9-9724f4dc0f29-S1568/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/b8804081-c132-43c1-9653-1ca6a7fcbc39/runs/e7f89e99-abf2-4a56-a722-99088a107100/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_not_fast_compiler/tmp -Xcomp -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation -Xbootclasspath/a:. -Xbatch -XX:-UseOnStackReplacement -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:Tier3InvocationThreshold=200 -XX:Tier4InvocationThreshold=5000 compiler.cha.TypeProfileFinalMethod$Launcher ]
      [2024-09-26T05:21:21.136187713Z] Gathering output for process 792907
      [2024-09-26T05:21:21.279218225Z] Waiting for completion for process 792907
      [2024-09-26T05:21:35.119714507Z] Waiting for completion finished for process 792907
      Output and diagnostic info for process 792907 was saved into 'pid-792907-output.log'
      debug output
      1 compiler directives added
      1 compiler directives added
      1 compiler directives added
      1 compiler directives added
                                  @ 1 compiler.cha.TypeProfileFinalMethod$Launcher::test1 (41 bytes) failed to inline: too big
      ======== break CHA

      debug output end
      ----------System.err:(13/728)----------
      java.lang.RuntimeException: assertEquals expected: 0 but was: 2
      at jdk.test.lib.Asserts.fail(Asserts.java:691)
      at jdk.test.lib.Asserts.assertEquals(Asserts.java:204)
      at jdk.test.lib.Asserts.assertEquals(Asserts.java:191)
      at compiler.cha.TypeProfileFinalMethod.main(TypeProfileFinalMethod.java:64)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:573)
      at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
      at java.base/java.lang.Thread.run(Thread.java:1576)

      JavaTest Message: Test threw exception: java.lang.RuntimeException
      JavaTest Message: shutting down test

      result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: assertEquals expected: 0 but was: 2

            Assignee:
            Daniel Lunden
            Reporter:
            Daniel Daugherty
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: