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

CHA ignores default methods during analysis leading to incorrect code generation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: hs25, 8, 8u20
    • Fix Version/s: hs25
    • Component/s: hotspot
    • Environment:

      Java(TM) SE Runtime Environment (build 1.8.0-ea-b120)

      Related JavaFX bug report that the issue occured in b112.

    • Subcomponent:
    • Resolved In Build:
      b68
    • Verification:
      Verified

      Backports

        Description

        See JavaFX bug: https://javafx-jira.kenai.com/browse/RT-34355

        Download and run the sample. Switch between 0 and 1 fixed columns a few times. After a while, the table changes, because ColumnDefinitionIF#editableIf() has been called on CVPriceColumnDefinition.

        There's no change in stack trace before and after.

        Before it's:

        at vsa.vfx.experiment.demo.table.vfxtable.main.CVPriceColumnDefinition.editableIf(CVPriceColumnDefinition.java:40)
        at vsa.vfx.experiment.demo.table.vfxtable.main.TextFieldColumnDefinition.collaborator(TextFieldColumnDefinition.java:44)
        at vsa.vfx.experiment.demo.table.vfxtable.main.CVPriceColumnDefinition.collaborator(CVPriceColumnDefinition.java:18)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns.lambda$1(VfxTableColumns.java:32)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns$$Lambda$14/2025470705.call(Unknown Source)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:80)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:46)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.createCell(TableRowSkinBase.java:652)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.recreateCells(TableRowSkinBase.java:646)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.checkState(TableRowSkinBase.java:591)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.layoutChildren(TableRowSkinBase.java:246)
        at javafx.scene.control.Control.layoutChildren(Control.java:574)
        at javafx.scene.Parent.layout(Parent.java:1076)
        ...

        After it changes to:
        at vsa.vfx.experiment.demo.table.vfxtable.main.ColumnDefinitionIF.editableIf(ColumnDefinitionIF.java:43)
        at vsa.vfx.experiment.demo.table.vfxtable.main.TextFieldColumnDefinition.collaborator(TextFieldColumnDefinition.java:44)
        at vsa.vfx.experiment.demo.table.vfxtable.main.CVPriceColumnDefinition.collaborator(CVPriceColumnDefinition.java:18)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns.lambda$1(VfxTableColumns.java:32)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns$$Lambda$14/2025470705.call(Unknown Source)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:80)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:46)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.createCell(TableRowSkinBase.java:652)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.recreateCells(TableRowSkinBase.java:646)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.checkState(TableRowSkinBase.java:591)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.layoutChildren(TableRowSkinBase.java:246)
        at javafx.scene.control.Control.layoutChildren(Control.java:574)
        at javafx.scene.Parent.layout(Parent.java:1076)
        ...

        And sometimes I get:
        at vsa.vfx.experiment.demo.table.vfxtable.main.CVPriceColumnDefinition.editableIf(CVPriceColumnDefinition.java:40)
        at vsa.vfx.experiment.demo.table.vfxtable.main.TextFieldColumnDefinition.collaborator(TextFieldColumnDefinition.java:44)
        at vsa.vfx.experiment.demo.table.vfxtable.main.CVNameColumnDefinition.collaborator(CVNameColumnDefinition.java:12)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns.lambda$1(VfxTableColumns.java:32)
        at vsa.vfx.control.table.vfxtables.VfxTableColumns$$Lambda$14/2025470705.call(Unknown Source)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:80)
        at com.sun.javafx.scene.control.skin.TableRowSkin.getCell(TableRowSkin.java:46)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.createCell(TableRowSkinBase.java:652)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.recreateCells(TableRowSkinBase.java:646)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.checkState(TableRowSkinBase.java:591)
        at com.sun.javafx.scene.control.skin.TableRowSkinBase.layoutChildren(TableRowSkinBase.java:246)
        at javafx.scene.control.Control.layoutChildren(Control.java:574)
        at javafx.scene.Parent.layout(Parent.java:1076)
                ...


        I've tried to create some simpler sample, but was unsuccessful.

          Issue Links

            Activity

            Hide
            vlivanov Vladimir Ivanov added a comment - - edited
            ILW = HHH = P1

            Impact: High: incorrect code: wrong method is invoked
            Likelihood: High: simple class hierarchies with default methods are affected
            Workaround: High: No workaround.

            Justification:
            JVM produces incorrect code when it inlines wrong method. From a user's perspective, it's scary (silent state corruption) and very hard to diagnose.

            Evaluation:
            Class Hierarchy Analysis (CHA) erroneously ignores default methods when looking for versions of a method in a class hierarchy. It leads to a situation when VM considers a call site as monomorphic and inlines some method, but the call site isn't actually monomorphic and in some cases wrong method is invoked. VM doesn't issue any guards because CHA is assumed to give precise info, so such checks are redundant.
            The fix is to take default methods into account doing CHA analysis.

            Risk Assessment: Very low.
            The fix is conservative: strictly reduce a number of cases when a call site is considered monomorphic by CHA. No new optimization opportunities are added.

            Testing (in progress): failing application, regression test, vm.defmeth.testlist, JDK regression tests
            Show
            vlivanov Vladimir Ivanov added a comment - - edited ILW = HHH = P1 Impact: High: incorrect code: wrong method is invoked Likelihood: High: simple class hierarchies with default methods are affected Workaround: High: No workaround. Justification: JVM produces incorrect code when it inlines wrong method. From a user's perspective, it's scary (silent state corruption) and very hard to diagnose. Evaluation: Class Hierarchy Analysis (CHA) erroneously ignores default methods when looking for versions of a method in a class hierarchy. It leads to a situation when VM considers a call site as monomorphic and inlines some method, but the call site isn't actually monomorphic and in some cases wrong method is invoked. VM doesn't issue any guards because CHA is assumed to give precise info, so such checks are redundant. The fix is to take default methods into account doing CHA analysis. Risk Assessment: Very low. The fix is conservative: strictly reduce a number of cases when a call site is considered monomorphic by CHA. No new optimization opportunities are added. Testing (in progress): failing application, regression test, vm.defmeth.testlist, JDK regression tests
            Hide
            maxelsso Mathias Axelsson (Inactive) added a comment -
            Release team: Approved for fixing
            Show
            maxelsso Mathias Axelsson (Inactive) added a comment - Release team: Approved for fixing
            Hide
            amurillo Alejandro Murillo (Inactive) added a comment -
            Thsi bug is also causing the following 3 hs-main nightly testing failures:
            java/util/stream/boottest/java/util/stream/DoubleNodeTest.java
            java/util/stream/boottest/java/util/stream/IntNodeTest.java
            java/util/stream/boottest/java/util/stream/LongNodeTest.java
            Show
            amurillo Alejandro Murillo (Inactive) added a comment - Thsi bug is also causing the following 3 hs-main nightly testing failures: java/util/stream/boottest/java/util/stream/DoubleNodeTest.java java/util/stream/boottest/java/util/stream/IntNodeTest.java java/util/stream/boottest/java/util/stream/LongNodeTest.java
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/709018897c81
            User: vlivanov
            Date: 2014-01-23 00:02:01 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/709018897c81 User: vlivanov Date: 2014-01-23 00:02:01 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/709018897c81
            User: amurillo
            Date: 2014-01-23 23:09:27 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/709018897c81 User: amurillo Date: 2014-01-23 23:09:27 +0000

              People

              • Assignee:
                vlivanov Vladimir Ivanov
                Reporter:
                msladecek Martin Sládeček
              • Votes:
                0 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: