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

Cleanup use of volatile in taskqueue code


    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 15
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:



        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.


            Issue Links



                • Assignee:
                  kbarrett Kim Barrett
                  kbarrett Kim Barrett
                • Votes:
                  0 Vote for this issue
                  3 Start watching this issue


                  • Created: