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

C2 produces wrong result while unswitching a loop due to lost control dependencies

XMLWordPrintable

    • b27
    • Fix failed

        The attached test produces a wrong result for C2 due to lost control dependencies for loop predicates while unswitching a loop after it was partially peeled.

        The C2 compiled code produces a wrong result for 'iFld' in the attached test case. It is -8 instead of -7. The loop in the test case is partially peeled and then unswitched. The wrong result is produced because a wrong state is transferred to the interpreter when an uncommon trap is hit in the C2 compiled code in the fast version of the unswitched loop.

        The problem is when unswitching the loop, we clone the original loop predicates for the slow and fast version of the loop but we do not account for partially peeled statements that are control dependent on the loop predicates (i.e. need to be executed after the predicates). As a result, these are executed before the cloned loop predicates.

          1. fixed_dependencies.png
            fixed_dependencies.png
            30 kB
          2. FuzzerUtils.class
            8 kB
          3. FuzzerUtils.java
            13 kB
          4. FuzzerUtils$1.class
            0.8 kB
          5. Test.class
            6 kB
          6. Test.java
            9 kB
          7. wrong_dependencies.png
            wrong_dependencies.png
            33 kB

              chagedorn Christian Hagedorn
              lmesnik Leonid Mesnik
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: