src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp
branchJEP-349-branch
changeset 58823 6a21dba79b81
parent 58112 e7754025004b
equal deleted inserted replaced
58806:a7d850b47b19 58823:6a21dba79b81
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
    26 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
    27 #include "runtime/safepoint.hpp"
    27 #include "runtime/safepoint.hpp"
    28 #include "runtime/orderAccess.hpp"
       
    29 
    28 
    30 // Alternating epochs on each rotation allow for concurrent tagging.
    29 // Alternating epochs on each rotation allow for concurrent tagging.
    31 // The regular epoch shift happens only during a safepoint.
    30 // The epoch shift happens only during a safepoint.
    32 // The fence is there only for the emergency dump case which happens outside of safepoint.
       
    33 bool JfrTraceIdEpoch::_epoch_state = false;
    31 bool JfrTraceIdEpoch::_epoch_state = false;
    34 bool volatile JfrTraceIdEpoch::_tag_state = false;
    32 bool volatile JfrTraceIdEpoch::_tag_state = false;
    35 
    33 
    36 void JfrTraceIdEpoch::shift_epoch() {
    34 void JfrTraceIdEpoch::shift_epoch() {
       
    35   assert(SafepointSynchronize::is_at_safepoint(), "invariant");
    37   _epoch_state = !_epoch_state;
    36   _epoch_state = !_epoch_state;
    38   if (!SafepointSynchronize::is_at_safepoint()) {
       
    39     OrderAccess::fence();
       
    40   }
       
    41 }
    37 }