diff --git a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp index 70793ced813efe56425e157237a9b59705190c35..64ffa81d0dc8ff102c332a87db103a6429b0dae2 100644 --- a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp +++ b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp @@ -27,7 +27,6 @@ #include "jfr/utilities/jfrTypes.hpp" #include "runtime/atomic.inline.hpp" -#include "runtime/orderAccess.inline.hpp" #include "utilities/macros.hpp" #ifdef VM_LITTLE_ENDIAN @@ -40,46 +39,45 @@ static const int leakp_offset = low_offset - 1; inline void set_bits(jbyte bits, jbyte* const dest) { assert(dest != NULL, "invariant"); - const jbyte current = OrderAccess::load_acquire(dest); - if (bits != (current & bits)) { + if (bits != (*dest & bits)) { *dest |= bits; } } -inline void set_mask(jbyte mask, jbyte* const dest) { - assert(dest != NULL, "invariant"); - const jbyte current = OrderAccess::load_acquire(dest); - if (mask != (current & mask)) { - *dest &= mask; - } +inline jbyte traceid_and(jbyte current, jbyte bits) { + return current & bits; } -inline void set_bits_cas(jbyte bits, jbyte* const dest) { +inline jbyte traceid_or(jbyte current, jbyte bits) { + return current | bits; +} + +inline jbyte traceid_xor(jbyte current, jbyte bits) { + return current ^ bits; +} + +template +inline void set_bits_cas_form(jbyte bits, jbyte* const dest) { assert(dest != NULL, "invariant"); do { - const jbyte current = OrderAccess::load_acquire(dest); - if (bits == (current & bits)) { - return; - } - const jbyte new_value = current | bits; + const jbyte current = *dest; + const jbyte new_value = op(current, bits); if (Atomic::cmpxchg(new_value, dest, current) == current) { return; } } while (true); } +inline void set_bits_cas(jbyte bits, jbyte* const dest) { + set_bits_cas_form(bits, dest); +} + inline void clear_bits_cas(jbyte bits, jbyte* const dest) { - assert(dest != NULL, "invariant"); - do { - const jbyte current = OrderAccess::load_acquire(dest); - if (bits != (current & bits)) { - return; - } - const jbyte new_value = current ^ bits; - if (Atomic::cmpxchg(new_value, dest, current) == current) { - return; - } - } while (true); + set_bits_cas_form(bits, dest); +} + +inline void set_mask(jbyte mask, jbyte* const dest) { + set_bits_cas_form(mask, dest); } inline void set_traceid_bits(jbyte bits, traceid* dest) { diff --git a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp index 810372939dddb0bfe684f4e3a8d171a63f5f9db8..466883e58e076e82fb13251dd06eb8fea50b137d 100644 --- a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp +++ b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp @@ -108,7 +108,7 @@ #define SET_USED_THIS_EPOCH(ptr) (SET_TAG(ptr, IN_USE_THIS_EPOCH_BIT)) #define SET_USED_PREV_EPOCH(ptr) (SET_TAG_CAS(ptr, IN_USE_PREV_EPOCH_BIT)) #define SET_LEAKP_USED_THIS_EPOCH(ptr) (SET_LEAKP_TAG(ptr, IN_USE_THIS_EPOCH_BIT)) -#define SET_LEAKP_USED_PREV_EPOCH(ptr) (SET_LEAKP_TAG(ptr, IN_USE_PREV_EPOCH_BIT)) +#define SET_LEAKP_USED_PREV_EPOCH(ptr) (SET_LEAKP_TAG_CAS(ptr, IN_USE_PREV_EPOCH_BIT)) #define SET_METHOD_AND_CLASS_USED_THIS_EPOCH(kls) (SET_TAG(kls, METHOD_AND_CLASS_IN_USE_THIS_EPOCH_BITS)) #define USED_THIS_EPOCH(ptr) (((ptr)->trace_id() & IN_USE_THIS_EPOCH_BIT) != 0)