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

Atomic::cmpxchg for jbyte is missing a fence on initial failure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • None
    • b135

      The generalized jbyte version has to perform a real cmpxchg on a full word (jint) so it has to isolate the correct byte within the word. We have a loop:

       while (cur_as_bytes[offset] == compare_value) {
          jint res = cmpxchg(new_val, dest_int, cur);
          if (res == cur) break;
          cur = res;
          new_val = cur;
          new_val_as_bytes[offset] = exchange_value;
        }

      but if we fail the initial comparison there is no fence, as required by the semantics for cmpxchg as defined in atomic.hpp.

      This was discovered during the review of JDK-8155949.

            dholmes David Holmes
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: