diff -r 4cab5edc2950 -r 5d043a159d5c src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp --- a/src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp Fri May 17 15:53:21 2019 +0200 +++ b/src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp Fri May 17 16:02:27 2019 +0200 @@ -26,17 +26,20 @@ #define SHARE_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP #include "jfr/recorder/storage/jfrStorageUtils.hpp" +#include "runtime/thread.inline.hpp" template inline bool UnBufferedWriteToChunk::write(T* t, const u1* data, size_t size) { _writer.write_unbuffered(data, size); - _processed += size; + ++_elements; + _size += size; return true; } template inline bool DefaultDiscarder::discard(T* t, const u1* data, size_t size) { - _processed += size; + ++_elements; + _size += size; return true; } @@ -44,7 +47,7 @@ inline bool ConcurrentWriteOp::process(typename Operation::Type* t) { const u1* const current_top = t->concurrent_top(); const size_t unflushed_size = t->pos() - current_top; - if (unflushed_size == 0) { + if (unflushed_size == 0 || t->excluded()) { t->set_concurrent_top(current_top); return true; } @@ -67,7 +70,7 @@ assert(t != NULL, "invariant"); const u1* const current_top = t->top(); const size_t unflushed_size = t->pos() - current_top; - if (unflushed_size == 0) { + if (unflushed_size == 0 || t->excluded()) { return true; } const bool result = _operation.write(t, current_top, unflushed_size); @@ -75,6 +78,28 @@ return result; } +template +static void retired_sensitive_acquire(Type* t) { + assert(t != NULL, "invariant"); + if (t->retired()) { + return; + } + Thread* const thread = Thread::current(); + while (!t->try_acquire(thread)) { + if (t->retired()) { + return; + } + } +} + +template +inline bool ExclusiveOp::process(typename Operation::Type* t) { + retired_sensitive_acquire(t); + assert(t->acquired_by_self() || t->retired(), "invariant"); + // User is required to ensure proper release of the acquisition + return MutexedWriteOp::process(t); +} + template inline bool DiscardOp::process(typename Operation::Type* t) { assert(t != NULL, "invariant");