diff -r a5f5e680ea32 -r ec7d6d8effc7 src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp --- a/src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp Tue May 21 13:06:52 2019 -0400 +++ b/src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp Tue May 21 20:53:27 2019 +0200 @@ -26,6 +26,7 @@ #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) { @@ -75,6 +76,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");