Unify atomic exchange and compare exchange

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 26
    • Affects Version/s: None
    • Component/s: hotspot
    • master

      AtomicAccess::xchg is only required to support 4 bytes and sizeof(intptr_t) size.
      This restriction added a lot of extra logic to the Atomic implementation because
      we have a set of features we must support (including compare exchange) for 1, 4 and 8 byte atomics on all platforms. We have some checks for unsupported 8 byte compare exchange (`VM_Version::supports_cx8()`), but the Atomic class does not try to handle these for generating its supported functions. On such a platform we would more than likely get a linking error.

      I propose we change requirement for exchange to 1, 4 and 8 bytes to achieve parity with compare exchange. Initially by implementing exchange via the `AtomicAccess::XchgUsingCmpxch`. And have follow up RFEs for each applicable platform where we specialize `AtomicAccess::PlatformXchg<1>`.

      This enhancement both simplifies the Atomic implementation and provides exchange capabilities for types like `bool` and enums represented by a byte.

            Assignee:
            Axel Boldt-Christmas
            Reporter:
            Axel Boldt-Christmas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: