8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"

Tue, 22 Oct 2019 20:55:30 +0800

author
ddong
date
Tue, 22 Oct 2019 20:55:30 +0800
changeset 9887
78f156419d26
parent 9886
986b79fabfa0
child 9888
0fa5faa321f7

8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
Reviewed-by: dholmes, dcubed, egahlin

src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp file | annotate | diff | comparison | revisions
src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp	Tue Oct 29 19:53:30 2019 -0300
     1.2 +++ b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp	Tue Oct 22 20:55:30 2019 +0800
     1.3 @@ -27,7 +27,6 @@
     1.4  
     1.5  #include "jfr/utilities/jfrTypes.hpp"
     1.6  #include "runtime/atomic.inline.hpp"
     1.7 -#include "runtime/orderAccess.inline.hpp"
     1.8  #include "utilities/macros.hpp"
     1.9  
    1.10  #ifdef VM_LITTLE_ENDIAN
    1.11 @@ -40,46 +39,45 @@
    1.12  
    1.13  inline void set_bits(jbyte bits, jbyte* const dest) {
    1.14    assert(dest != NULL, "invariant");
    1.15 -  const jbyte current = OrderAccess::load_acquire(dest);
    1.16 -  if (bits != (current & bits)) {
    1.17 +  if (bits != (*dest & bits)) {
    1.18      *dest |= bits;
    1.19    }
    1.20  }
    1.21  
    1.22 -inline void set_mask(jbyte mask, jbyte* const dest) {
    1.23 -  assert(dest != NULL, "invariant");
    1.24 -  const jbyte current = OrderAccess::load_acquire(dest);
    1.25 -  if (mask != (current & mask)) {
    1.26 -    *dest &= mask;
    1.27 -  }
    1.28 +inline jbyte traceid_and(jbyte current, jbyte bits) {
    1.29 +  return current & bits;
    1.30  }
    1.31  
    1.32 -inline void set_bits_cas(jbyte bits, jbyte* const dest) {
    1.33 +inline jbyte traceid_or(jbyte current, jbyte bits) {
    1.34 +  return current | bits;
    1.35 +}
    1.36 +
    1.37 +inline jbyte traceid_xor(jbyte current, jbyte bits) {
    1.38 +  return current ^ bits;
    1.39 +}
    1.40 +
    1.41 +template <jbyte op(jbyte, jbyte)>
    1.42 +inline void set_bits_cas_form(jbyte bits, jbyte* const dest) {
    1.43    assert(dest != NULL, "invariant");
    1.44    do {
    1.45 -    const jbyte current = OrderAccess::load_acquire(dest);
    1.46 -    if (bits == (current & bits)) {
    1.47 -      return;
    1.48 -    }
    1.49 -    const jbyte new_value = current | bits;
    1.50 +    const jbyte current = *dest;
    1.51 +    const jbyte new_value = op(current, bits);
    1.52      if (Atomic::cmpxchg(new_value, dest, current) == current) {
    1.53        return;
    1.54      }
    1.55    } while (true);
    1.56  }
    1.57  
    1.58 +inline void set_bits_cas(jbyte bits, jbyte* const dest) {
    1.59 +  set_bits_cas_form<traceid_or>(bits, dest);
    1.60 +}
    1.61 +
    1.62  inline void clear_bits_cas(jbyte bits, jbyte* const dest) {
    1.63 -  assert(dest != NULL, "invariant");
    1.64 -  do {
    1.65 -    const jbyte current = OrderAccess::load_acquire(dest);
    1.66 -    if (bits != (current & bits)) {
    1.67 -      return;
    1.68 -    }
    1.69 -    const jbyte new_value = current ^ bits;
    1.70 -    if (Atomic::cmpxchg(new_value, dest, current) == current) {
    1.71 -      return;
    1.72 -    }
    1.73 -  } while (true);
    1.74 +  set_bits_cas_form<traceid_xor>(bits, dest);
    1.75 +}
    1.76 +
    1.77 +inline void set_mask(jbyte mask, jbyte* const dest) {
    1.78 +  set_bits_cas_form<traceid_and>(mask, dest);
    1.79  }
    1.80  
    1.81  inline void set_traceid_bits(jbyte bits, traceid* dest) {
     2.1 --- a/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp	Tue Oct 29 19:53:30 2019 -0300
     2.2 +++ b/src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp	Tue Oct 22 20:55:30 2019 +0800
     2.3 @@ -108,7 +108,7 @@
     2.4  #define SET_USED_THIS_EPOCH(ptr)        (SET_TAG(ptr, IN_USE_THIS_EPOCH_BIT))
     2.5  #define SET_USED_PREV_EPOCH(ptr)        (SET_TAG_CAS(ptr, IN_USE_PREV_EPOCH_BIT))
     2.6  #define SET_LEAKP_USED_THIS_EPOCH(ptr)  (SET_LEAKP_TAG(ptr, IN_USE_THIS_EPOCH_BIT))
     2.7 -#define SET_LEAKP_USED_PREV_EPOCH(ptr)  (SET_LEAKP_TAG(ptr, IN_USE_PREV_EPOCH_BIT))
     2.8 +#define SET_LEAKP_USED_PREV_EPOCH(ptr)  (SET_LEAKP_TAG_CAS(ptr, IN_USE_PREV_EPOCH_BIT))
     2.9  #define SET_METHOD_AND_CLASS_USED_THIS_EPOCH(kls) (SET_TAG(kls, METHOD_AND_CLASS_IN_USE_THIS_EPOCH_BITS))
    2.10  
    2.11  #define USED_THIS_EPOCH(ptr)            (((ptr)->trace_id() & IN_USE_THIS_EPOCH_BIT) != 0)

mercurial