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

RISC-V: Zero extended narrow oop passed to Atomic::cmpxchg

XMLWordPrintable

    • b18
    • riscv

        Rv64 ABI says all 32-bit types must be sign extended when in a integer registers.
        When loading the to be exchanged narrow oop with load reserved word it automatically sign extends it.
        The branch not equal instruction always compares the full register (64-bit), if the compare narrow oop is not sign extended it fails.
        (even if the 4 byte narrow oops are identical)

        We have only seen this issue with Shenandoah and gcc 10/11.
        Modified tests:
        FAILED: gc/shenandoah/compiler/TestReferenceCAS.java#C1
        FAILED: gc/shenandoah/compiler/TestReferenceCAS.java#C1-2
        FAILED: gc/shenandoah/compiler/TestReferenceCAS.java#C2
        FAILED: gc/shenandoah/compiler/TestReferenceCAS.java#FULL
        FAILED: gc/shenandoah/compiler/TestReferenceCAS.java#Xint
        Passed: gc/shenandoah/compiler/TestReferenceCAS.java#Xint-G1

        Since we fail with Xint only the issue seems to be with Unsafe_CompareAndExchangeReference.

        A bigger about this is that there may be more places where we don't notice this, but can result in very unexpected behavior as any branch compare may fail.

        The issue is not reproduce with gcc 12/13.

              rehn Robbin Ehn
              rehn Robbin Ehn
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: