epoch aware serialization tagging JEP-349-branch
authormgronlun
Sun, 25 Aug 2019 19:09:22 +0200
branchJEP-349-branch
changeset 57874 cd496c5a3823
parent 57873 68134337dbf8
child 57878 bffba8d6611a
epoch aware serialization tagging
src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp	Sun Aug 25 15:13:16 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp	Sun Aug 25 19:09:22 2019 +0200
@@ -58,11 +58,12 @@
 
 inline traceid JfrTraceId::use(const Klass* klass) {
   assert(klass != NULL, "invariant");
-  const traceid id = set_used_and_get(klass);
-  if (IS_NOT_SERIALIZED(klass)) {
+  if (SHOULD_TAG(klass)) {
     JfrTraceIdEpoch::set_klass_tagged_in_epoch();
+    return set_used_and_get(klass);
   }
-  return id;
+  assert(USED_THIS_EPOCH(klass), "invariant");
+  return TRACE_ID(klass);
 }
 
 inline traceid JfrTraceId::use(const Method* method) {
@@ -74,11 +75,11 @@
   assert(klass != NULL, "invariant");
   assert(method != NULL, "invariant");
   SET_METHOD_FLAG_USED_THIS_EPOCH(method);
-  SET_METHOD_AND_CLASS_USED_THIS_EPOCH(klass);
+  if (SHOULD_TAG_KLASS_METHOD(klass)) {
+    JfrTraceIdEpoch::set_klass_tagged_in_epoch();
+    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/jfrTraceIdMacros.hpp	Sun Aug 25 15:13:16 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp	Sun Aug 25 19:09:22 2019 +0200
@@ -88,9 +88,11 @@
 
 // predicates
 #define USED_THIS_EPOCH(ptr)                      (TRACE_ID_PREDICATE(ptr, (TRANSIENT_BIT | IN_USE_THIS_EPOCH_BIT)))
+#define NOT_USED_THIS_EPOCH(ptr)                  (!USED_THIS_EPOCH(ptr))
 #define USED_PREV_EPOCH(ptr)                      (TRACE_ID_PREDICATE(ptr, (TRANSIENT_BIT | IN_USE_PREV_EPOCH_BIT)))
 #define USED_ANY_EPOCH(ptr)                       (TRACE_ID_PREDICATE(ptr, (TRANSIENT_BIT | USED_EPOCH_2_BIT | USED_EPOCH_1_BIT)))
 #define METHOD_USED_THIS_EPOCH(kls)               (TRACE_ID_PREDICATE(kls, (TRANSIENT_BIT | METHOD_IN_USE_THIS_EPOCH_BIT)))
+#define METHOD_NOT_USED_THIS_EPOCH(kls)           (!METHOD_USED_THIS_EPOCH(kls))
 #define METHOD_USED_PREV_EPOCH(kls)               (TRACE_ID_PREDICATE(kls, (TRANSIENT_BIT | METHOD_IN_USE_PREV_EPOCH_BIT)))
 #define METHOD_USED_ANY_EPOCH(kls)                (TRACE_ID_PREDICATE(kls, (TRANSIENT_BIT | METHOD_IN_USE_PREV_EPOCH_BIT | METHOD_IN_USE_THIS_EPOCH_BIT)))
 #define METHOD_AND_CLASS_USED_THIS_EPOCH(kls)     (TRACE_ID_PREDICATE(kls, (TRANSIENT_BIT | METHOD_AND_CLASS_IN_USE_THIS_EPOCH_BITS)))
@@ -124,6 +126,8 @@
 #define SET_TRANSIENT(ptr)                        (TRACE_ID_META_TAG(ptr, USED_BIT))
 #define IS_SERIALIZED(ptr)                        (TRACE_ID_PREDICATE(ptr, SERIALIZED_BIT))
 #define IS_NOT_SERIALIZED(ptr)                    (!IS_SERIALIZED(ptr))
+#define SHOULD_TAG(ptr)                           ((IS_NOT_SERIALIZED(ptr)) || (NOT_USED_THIS_EPOCH(ptr)))
+#define SHOULD_TAG_KLASS_METHOD(ptr)              ((IS_NOT_SERIALIZED(ptr)) || (METHOD_NOT_USED_THIS_EPOCH(ptr)))
 #define SET_SERIALIZED(ptr)                       (TRACE_ID_META_TAG(ptr, (USED_BIT << 1)))
 #define CLEAR_SERIALIZED(ptr)                     (TRACE_ID_META_CLEAR(ptr, (~(USED_BIT << 1 | USED_BIT))))
 #define IS_METHOD_SERIALIZED(method)              (METHOD_FLAG_PREDICATE(method, SERIALIZED_BIT))