From ab6e48fd9bce9024fb62e96a924f1e78a4b2c3d4 Mon Sep 17 00:00:00 2001 From: ddong Date: Tue, 22 Oct 2019 20:55:30 +0800 Subject: [PATCH] 8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant" Reviewed-by: dholmes, dcubed, egahlin --- .../types/traceid/jfrTraceIdBits.inline.hpp | 50 +++++++++---------- .../types/traceid/jfrTraceIdMacros.hpp | 2 +- 2 files changed, 25 insertions(+), 27 deletions(-) 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 70793ced8..64ffa81d0 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 810372939..466883e58 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) -- GitLab