--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp Sun Aug 25 15:13:16 2019 +0200
@@ -407,6 +407,10 @@
JfrTypeManager::write_type_set_for_unloaded_classes();
}
+bool JfrCheckpointManager::is_type_set_checkpoint_required() const {
+ return JfrTraceIdEpoch::is_klass_tagged_in_epoch();
+}
+
size_t JfrCheckpointManager::flush_type_set() {
const size_t elements = JfrTypeManager::flush_type_set();
flush();
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.hpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.hpp Sun Aug 25 15:13:16 2019 +0200
@@ -95,6 +95,7 @@
public:
void register_service_thread(const Thread* t);
+ bool is_type_set_checkpoint_required() const;
size_t flush_type_set();
static void write_type_set_for_unloaded_classes();
static void create_thread_checkpoint(Thread* t);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp Sun Aug 25 15:13:16 2019 +0200
@@ -28,8 +28,9 @@
#include "classfile/classLoaderData.hpp"
#include "classfile/moduleEntry.hpp"
#include "classfile/packageEntry.hpp"
+#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
+#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
-#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
#include "oops/arrayKlass.hpp"
#include "oops/klass.hpp"
#include "oops/instanceKlass.hpp"
@@ -57,7 +58,11 @@
inline traceid JfrTraceId::use(const Klass* klass) {
assert(klass != NULL, "invariant");
- return set_used_and_get(klass);
+ const traceid id = set_used_and_get(klass);
+ if (IS_NOT_SERIALIZED(klass)) {
+ JfrTraceIdEpoch::set_klass_tagged_in_epoch();
+ }
+ return id;
}
inline traceid JfrTraceId::use(const Method* method) {
@@ -71,6 +76,9 @@
SET_METHOD_FLAG_USED_THIS_EPOCH(method);
SET_METHOD_AND_CLASS_USED_THIS_EPOCH(klass);
assert(METHOD_AND_CLASS_USED_THIS_EPOCH(klass), "invariant");
+ if (IS_NOT_SERIALIZED(klass)) {
+ JfrTraceIdEpoch::set_klass_tagged_in_epoch();
+ }
return (METHOD_ID(klass, method));
}
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp Sun Aug 25 15:13:16 2019 +0200
@@ -31,6 +31,8 @@
// The regular epoch shift happens only during a safepoint.
// The fence is there only for the emergency dump case which happens outside of safepoint.
bool JfrTraceIdEpoch::_epoch_state = false;
+bool volatile JfrTraceIdEpoch::_klass_tagged_in_epoch = false;
+
void JfrTraceIdEpoch::shift_epoch() {
_epoch_state = !_epoch_state;
if (!SafepointSynchronize::is_at_safepoint()) {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp Sun Aug 25 15:13:16 2019 +0200
@@ -26,7 +26,7 @@
#define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
#include "memory/allocation.hpp"
-#include "jfr/utilities/jfrTypes.hpp"
+#include "runtime/orderAccess.hpp"
#define USED_BIT 1
#define METHOD_USED_BIT (USED_BIT << 2)
@@ -44,6 +44,8 @@
friend class JfrCheckpointManager;
private:
static bool _epoch_state;
+ static bool volatile _klass_tagged_in_epoch;
+
static void shift_epoch();
public:
@@ -86,6 +88,20 @@
static traceid method_and_class_in_use_prev_epoch_bits() {
return _epoch_state ? METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS : METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS;
}
+
+ static bool is_klass_tagged_in_epoch() {
+ if (OrderAccess::load_acquire(&_klass_tagged_in_epoch)) {
+ OrderAccess::release_store(&_klass_tagged_in_epoch, false);
+ return true;
+ }
+ return false;
+ }
+
+ static void set_klass_tagged_in_epoch() {
+ if (!OrderAccess::load_acquire(&_klass_tagged_in_epoch)) {
+ OrderAccess::release_store(&_klass_tagged_in_epoch, true);
+ }
+ }
};
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Sun Aug 25 13:27:54 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Sun Aug 25 15:13:16 2019 +0200
@@ -614,7 +614,9 @@
if (_string_pool.is_modified()) {
total_elements += flush_stringpool(_string_pool, _chunkwriter);
}
- total_elements += flush_typeset(_checkpoint_manager, _chunkwriter);
+ if (_checkpoint_manager.is_type_set_checkpoint_required()) {
+ total_elements += flush_typeset(_checkpoint_manager, _chunkwriter);
+ }
return total_elements;
}