# HG changeset patch # User mgronlun # Date 1591625510 -7200 # Mon Jun 08 16:11:50 2020 +0200 # Node ID 90c142d619e3eab3c692e70624b94a3ccbaddaef # Parent c1c690f4dd9c2d3e50e3f754a0ff5b2fe6c928a3 [mq]: 32_bit_workaround diff --git a/src/hotspot/share/jfr/recorder/storage/jfrMemorySpace.inline.hpp b/src/hotspot/share/jfr/recorder/storage/jfrMemorySpace.inline.hpp --- a/src/hotspot/share/jfr/recorder/storage/jfrMemorySpace.inline.hpp +++ b/src/hotspot/share/jfr/recorder/storage/jfrMemorySpace.inline.hpp @@ -27,6 +27,7 @@ #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp" #include "jfr/recorder/storage/jfrMemorySpace.hpp" +#include "runtime/atomic.hpp" #include "runtime/os.hpp" template class RetrievalPolicy, typename FreeListType, typename FullListType, bool epoch_aware> diff --git a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp b/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp --- a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp +++ b/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp @@ -40,7 +40,6 @@ #include "jfr/utilities/jfrTime.hpp" #include "jfr/writers/jfrNativeEventWriter.hpp" #include "logging/log.hpp" -#include "runtime/atomic.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.inline.hpp" #include "runtime/safepoint.hpp" diff --git a/src/hotspot/share/jfr/utilities/jfrVersionSystem.hpp b/src/hotspot/share/jfr/utilities/jfrVersionSystem.hpp --- a/src/hotspot/share/jfr/utilities/jfrVersionSystem.hpp +++ b/src/hotspot/share/jfr/utilities/jfrVersionSystem.hpp @@ -108,6 +108,7 @@ }; PaddedTip _tip; NodePtr _head; + volatile int _spinlock; NodePtr acquire(); void release(NodePtr node); diff --git a/src/hotspot/share/jfr/utilities/jfrVersionSystem.inline.hpp b/src/hotspot/share/jfr/utilities/jfrVersionSystem.inline.hpp --- a/src/hotspot/share/jfr/utilities/jfrVersionSystem.inline.hpp +++ b/src/hotspot/share/jfr/utilities/jfrVersionSystem.inline.hpp @@ -25,9 +25,11 @@ #ifndef SHARE_JFR_UTILITIES_JFRVERSIONSYSTEM_INLINE_HPP #define SHARE_JFR_UTILITIES_JFRVERSIONSYSTEM_INLINE_HPP +#include "jfr/utilities/jfrSpinlockHelper.hpp" #include "jfr/utilities/jfrVersionSystem.hpp" #include "runtime/atomic.hpp" #include "runtime/os.inline.hpp" +#include "runtime/vm_version.hpp" inline JfrVersionSystem::Node::Node() : _next(NULL), _version(0), _live(true) {} @@ -39,7 +41,7 @@ Atomic::release_store_fence(&_version, version); } -inline JfrVersionSystem::JfrVersionSystem() : _tip(), _head(NULL) { +inline JfrVersionSystem::JfrVersionSystem() : _tip(), _head(NULL), _spinlock(0) { _tip._value = 1; } @@ -63,7 +65,17 @@ } inline JfrVersionSystem::Type JfrVersionSystem::increment() { - return Atomic::add(&_tip._value, (traceid)1); + if (!VM_Version::supports_cx8()) { + JfrSpinlockHelper lock(&_spinlock); + return ++_tip._value; + } + traceid cmp; + traceid xchg; + do { + cmp = _tip._value; + xchg = cmp + 1; + } while (Atomic::cmpxchg(&_tip._value, cmp, xchg) != cmp); + return xchg; } inline JfrVersionSystem::NodePtr JfrVersionSystem::acquire() {