updates after merge JEP-349-branch
authormgronlun
Sun, 15 Sep 2019 15:31:04 +0200
branchJEP-349-branch
changeset 58158 369ebc2a11c2
parent 58157 9dca61a7df19
child 58159 892527a70da9
updates after merge
src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp
src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp
src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp
src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp
src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp
src/hotspot/share/jfr/utilities/jfrTypes.hpp
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -41,7 +41,7 @@
 #include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/handles.inline.hpp"
-#include "runtime/mutexLocker.hpp"
+#include "runtime/mutex.hpp"
 #include "runtime/orderAccess.hpp"
 #include "runtime/os.inline.hpp"
 #include "runtime/safepoint.hpp"
@@ -378,18 +378,18 @@
 }
 
 size_t JfrCheckpointManager::write_types() {
-  ResourceMark rm;
-  HandleMark hm;
   Thread* const t = Thread::current();
+  ResourceMark rm(t);
+  HandleMark hm(t);
   JfrCheckpointWriter writer(t, get_epoch_transition_buffer(_epoch_transition_mspace, t), STATICS);
   JfrTypeManager::write_types(writer);
   return writer.used_size();
 }
 
 size_t JfrCheckpointManager::write_threads() {
-  ResourceMark rm;
-  HandleMark hm;
   Thread* const t = Thread::current();
+  ResourceMark rm(t);
+  HandleMark hm(t);
   JfrCheckpointWriter writer(t, get_epoch_transition_buffer(_epoch_transition_mspace, t), THREADS);
   JfrTypeManager::write_threads(writer);
   return writer.used_size();
@@ -428,7 +428,6 @@
 }
 
 void JfrCheckpointManager::write_type_set_for_unloaded_classes() {
-  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   JfrTypeManager::write_type_set_for_unloaded_classes();
 }
 
@@ -463,4 +462,3 @@
   JfrTraceIdEpoch::shift_epoch();
   assert(current_epoch != JfrTraceIdEpoch::current(), "invariant");
 }
-
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -270,13 +270,13 @@
  private:
   JfrCheckpointWriter* _leakp_writer;
   size_t _elements;
-  bool _class_unload;
-  bool _flushpoint;
  public:
-  TypeSetSerialization(bool class_unload, bool flushpoint, JfrCheckpointWriter* leakp_writer = NULL) :
-    _leakp_writer(leakp_writer), _elements(0), _class_unload(class_unload), _flushpoint(flushpoint) {}
-  void write(JfrCheckpointWriter& writer) {
-   _elements = JfrTypeSet::serialize(&writer, _leakp_writer, _class_unload, _flushpoint);
+  TypeSetSerialization(JfrCheckpointWriter* leakp_writer = NULL) :
+    _leakp_writer(leakp_writer), _elements(0) {}
+  void write(JfrCheckpointWriter& writer, bool class_unload, bool flushpoint) {
+    assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
+    assert_locked_or_safepoint(Module_lock);
+   _elements = JfrTypeSet::serialize(&writer, _leakp_writer, class_unload, flushpoint);
   }
   size_t elements() const {
     return _elements;
@@ -284,27 +284,31 @@
 };
 
 void ClassUnloadTypeSet::serialize(JfrCheckpointWriter& writer) {
-  TypeSetSerialization type_set(true, false);
-  type_set.write(writer);
+  TypeSetSerialization type_set;
+  type_set.write(writer, true, false);
 };
 
-TypeSet::TypeSet(JfrCheckpointWriter* leakp_writer) : _leakp_writer(leakp_writer) {}
-
 void FlushTypeSet::serialize(JfrCheckpointWriter& writer) {
   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
-  TypeSetSerialization type_set(false);
-    type_set.write(writer, &leakp_writer);
+  MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+  MutexLocker module_lock(Module_lock);
+  TypeSetSerialization type_set;
+  type_set.write(writer, false, true);
   _elements = type_set.elements();
 }
 
 size_t FlushTypeSet::elements() const {
-    return;
+  return _elements;
+}
 
 TypeSet::TypeSet(JfrCheckpointWriter* leakp_writer) : _leakp_writer(leakp_writer) {}
 
 void TypeSet::serialize(JfrCheckpointWriter& writer) {
-  TypeSetSerialization type_set(false, false, _leakp_writer);
-  type_set.write(writer);
+  assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
+  MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+  MutexLocker module_lock(Module_lock);
+  TypeSetSerialization type_set(_leakp_writer);
+  type_set.write(writer, false, false);
 };
 
 void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Sun Sep 15 15:31:04 2019 +0200
@@ -27,13 +27,11 @@
 
 #include "jfr/metadata/jfrSerializer.hpp"
 
-class JfrThreadConstantSet : public JfrSerializer {
+class TypeSet : public JfrSerializer {
+ private:
+  JfrCheckpointWriter* _leakp_writer;
  public:
-  void serialize(JfrCheckpointWriter& writer);
-};
-
-class JfrThreadGroupConstant : public JfrSerializer {
- public:
+  explicit TypeSet(JfrCheckpointWriter* leakp_writer = NULL);
   void serialize(JfrCheckpointWriter& writer);
 };
 
@@ -48,6 +46,7 @@
   void serialize(JfrCheckpointWriter& writer);
   size_t elements() const;
 };
+
 class FlagValueOriginConstant : public JfrSerializer {
  public:
   void serialize(JfrCheckpointWriter& writer);
@@ -113,11 +112,13 @@
   void serialize(JfrCheckpointWriter& writer);
 };
 
-class TypeSet : public JfrSerializer {
- private:
-  JfrCheckpointWriter* _leakp_writer;
+class JfrThreadConstantSet : public JfrSerializer {
  public:
-  explicit TypeSet(JfrCheckpointWriter* leakp_writer = NULL);
+  void serialize(JfrCheckpointWriter& writer);
+};
+
+class JfrThreadGroupConstant : public JfrSerializer {
+ public:
   void serialize(JfrCheckpointWriter& writer);
 };
 
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -172,10 +172,6 @@
 }
 
 void JfrTypeManager::write_type_set() {
-  assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
-  // can safepoint here because of Module_lock
-  MutexLocker cld_lock(SafepointSynchronize::is_at_safepoint() ? NULL : ClassLoaderDataGraph_lock);
-  MutexLocker lock(SafepointSynchronize::is_at_safepoint() ? NULL : Module_lock);
   if (!LeakProfiler::is_running()) {
     JfrCheckpointWriter writer;
     TypeSet set;
@@ -190,7 +186,6 @@
 }
 
 void JfrTypeManager::write_type_set_for_unloaded_classes() {
-  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   JfrCheckpointWriter writer;
   const JfrCheckpointContext ctx = writer.context();
   ClassUnloadTypeSet class_unload_set;
@@ -205,7 +200,6 @@
 }
 
 size_t JfrTypeManager::flush_type_set() {
-  assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   JfrCheckpointWriter writer;
   FlushTypeSet flush;
   flush.serialize(writer);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -94,6 +94,7 @@
   return true;
 }
 
+void JfrSymbolId::on_unlink(const SymbolEntry* entry) {
   assert(entry != NULL, "invariant");
   const_cast<Symbol*>(entry->literal())->decrement_refcount();
 }
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -29,6 +29,10 @@
 #include "jfr/utilities/jfrTypes.hpp"
 #include "runtime/os.inline.hpp"
 
+static const char* const MAGIC = "FLR";
+static const u2 JFR_VERSION_MAJOR = 2;
+static const u2 JFR_VERSION_MINOR = 0;
+
 static jlong nanos_now() {
   return os::javaTimeMillis() * JfrTimeConverter::NANOS_PER_MILLISEC;
 }
@@ -44,7 +48,7 @@
   _start_nanos(0),
   _previous_start_nanos(invalid_time),
   _last_update_nanos(0),
-  _last_checkpoint_offset(0) {}
+  _last_checkpoint_offset(0),
   _last_metadata_offset(0),
   _generation(1) {}
 
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp	Sun Sep 15 15:31:04 2019 +0200
@@ -27,6 +27,10 @@
 
 #include "jfr/utilities/jfrAllocation.hpp"
 
+const u1 COMPLETE = 0;
+const u1 GUARD = 0xff;
+const u1 PAD = 0;
+
 class JfrChunk : public JfrCHeapObj {
   friend class JfrChunkWriter;
   friend class JfrChunkHeadWriter;
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -26,7 +26,6 @@
 #include "jfr/recorder/repository/jfrChunk.hpp"
 #include "jfr/recorder/repository/jfrChunkWriter.hpp"
 #include "jfr/utilities/jfrTime.hpp"
-#include "jfr/utilities/jfrTypes.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/os.inline.hpp"
 
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp	Sun Sep 15 15:31:04 2019 +0200
@@ -77,7 +77,10 @@
   return last_id != _next_id;
 }
 
-size_t JfrStackTraceRepository::write_impl(JfrChunkWriter& sw, bool clear) {
+size_t JfrStackTraceRepository::write(JfrChunkWriter& sw, bool clear) {
+  if (_entries == 0) {
+    return 0;
+  }
   MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag);
   assert(_entries > 0, "invariant");
   int count = 0;
@@ -103,26 +106,6 @@
   return count;
 }
 
-size_t JfrStackTraceRepository::write(JfrChunkWriter& sw, bool clear) {
-  return _entries > 0 ? write_impl(sw, clear) : 0;
-}
-
-traceid JfrStackTraceRepository::write(JfrCheckpointWriter& writer, traceid id, unsigned int hash) {
-  assert(JfrStacktrace_lock->owned_by_self(), "invariant");
-  const JfrStackTrace* const trace = lookup(hash, id);
-  assert(trace != NULL, "invariant");
-  assert(trace->hash() == hash, "invariant");
-  assert(trace->id() == id, "invariant");
-  trace->write(writer);
-  return id;
-}
-
-void JfrStackTraceRepository::write_metadata(JfrCheckpointWriter& writer) {
-  JfrFrameType fct;
-  writer.write_type(TYPE_FRAMETYPE);
-  fct.serialize(writer);
-}
-
 size_t JfrStackTraceRepository::clear() {
   MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag);
   if (_entries == 0) {
@@ -140,6 +123,8 @@
   const size_t processed = _entries;
   _entries = 0;
   return processed;
+}
+
 traceid JfrStackTraceRepository::record(Thread* thread, int skip /* 0 */) {
   assert(thread == Thread::current(), "invariant");
   JfrThreadLocal* const tl = thread->jfr_thread_local();
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp	Sun Sep 15 15:31:04 2019 +0200
@@ -51,20 +51,18 @@
   JfrStackTraceRepository();
   static JfrStackTraceRepository& instance();
   static JfrStackTraceRepository* create();
+  static void destroy();
   bool initialize();
-  static void destroy();
 
-  size_t write_impl(JfrChunkWriter& cw, bool clear);
-  static void write_metadata(JfrCheckpointWriter& cpw);
-  traceid write(JfrCheckpointWriter& cpw, traceid id, unsigned int hash);
+  bool is_modified() const;
   size_t write(JfrChunkWriter& cw, bool clear);
   size_t clear();
 
+  const JfrStackTrace* lookup(unsigned int hash, traceid id) const;
+
   traceid add_trace(const JfrStackTrace& stacktrace);
   static traceid add(const JfrStackTrace& stacktrace);
   traceid record_for(JavaThread* thread, int skip, JfrStackFrame* frames, u4 max_frames);
-  const JfrStackTrace* lookup(unsigned int hash, traceid id) const;
-  bool is_modified() const;
 
  public:
   static traceid record(Thread* thread, int skip = 0);
--- a/src/hotspot/share/jfr/utilities/jfrTypes.hpp	Sun Sep 15 13:41:19 2019 +0200
+++ b/src/hotspot/share/jfr/utilities/jfrTypes.hpp	Sun Sep 15 15:31:04 2019 +0200
@@ -30,13 +30,6 @@
 typedef u8 traceid;
 typedef int fio_fd;
 
-const char* const MAGIC = "FLR";
-const u2 JFR_VERSION_MAJOR = 2;
-const u2 JFR_VERSION_MINOR = 0;
-const u1 COMPLETE = 0;
-const u1 GUARD = 0xff;
-const u1 PAD = 0;
-
 const int invalid_fd = -1;
 const jlong invalid_offset = -1;
 const int64_t invalid_time = -1;