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

Cleanup use of volatile in taskqueue code

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 15
    • 15
    • hotspot
    • gc
    • b21

    Backports

      Description

        The array elements in a GenericTaskQueue are declared volatile. This doesn't serve any useful purpose. If the necessary memory and compiler barriers are present then making the elements volatile doesn't provide any needed ordering. If if those barriers are not present then the volatile usage isn't sufficient, at least on platforms with weak memory ordering.

        On the contrary, having the array elements declared volatile forces element type to support volatile copy assignment. That leads to problems. For C++14 we need to have some additional user-defined special functions to avoid deprecation warnings from gcc9. But if we have multiple assignment operators then we need to suppress warnings from Visual Studio. And really, we want the element type to be trivially copyable. By removing the unneeded volatile qualification of the array element type we can change most of the used classes to be trivially copyable. (oop is an exception.)

        Another place where the current use of volatile leads to problems is around the manipulation of the _age member. By using explicit relaxed Atomic accesses we can simplify the Age class and its use, eliminating the need for all the volatile-qualified functions in the Age class.

        Attachments

          Issue Links

            Activity

              People

                kbarrett Kim Barrett
                kbarrett Kim Barrett
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: