8228834: Regression caused by JDK-8214542 not installing complete checkpoint data to candidates
authormgronlun
Fri, 02 Aug 2019 10:43:30 +0200
changeset 57644 446dcfc2a925
parent 57643 5dae3de0e04b
child 57645 152cd40a1d36
8228834: Regression caused by JDK-8214542 not installing complete checkpoint data to candidates Reviewed-by: egahlin
src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp
src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp	Thu Aug 01 10:47:51 2019 -0700
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp	Fri Aug 02 10:43:30 2019 +0200
@@ -181,34 +181,33 @@
   }
 };
 
-void ObjectSampleCheckpoint::install(JfrCheckpointWriter& writer, bool class_unload) {
+void ObjectSampleCheckpoint::install(JfrCheckpointWriter& writer, bool class_unload, bool type_set) {
   if (!writer.has_data()) {
     return;
   }
 
   assert(writer.has_data(), "invariant");
   const JfrCheckpointBlobHandle h_cp = writer.checkpoint_blob();
+  CheckpointInstall install(h_cp);
 
   // Class unload implies a safepoint.
   // Not class unload implies the object sampler is locked, because it was claimed exclusively earlier.
   // Therefore: direct access the object sampler instance is safe.
-  const ObjectSampler* const object_sampler = ObjectSampler::sampler();
+  ObjectSampler* const object_sampler = ObjectSampler::sampler();
   assert(object_sampler != NULL, "invariant");
 
   ObjectSample* const last = const_cast<ObjectSample*>(object_sampler->last());
   const ObjectSample* const last_resolved = object_sampler->last_resolved();
-  CheckpointInstall install(h_cp);
 
-  if (class_unload) {
-    // all samples need class unload information
-    do_samples(last, NULL, install);
-    return;
-  }
-
-  // only new samples since last resolved checkpoint
+  // install only to new samples since last resolved checkpoint
   if (last != last_resolved) {
     do_samples(last, last_resolved, install);
-    const_cast<ObjectSampler*>(object_sampler)->set_last_resolved(last);
+    if (class_unload) {
+      return;
+    }
+    if (type_set) {
+      object_sampler->set_last_resolved(last);
+    }
   }
 }
 
@@ -289,6 +288,6 @@
   JfrStackTraceRepository::write_metadata(writer);
 
   // install the stacktrace checkpoint information to the candidates
-  ObjectSampleCheckpoint::install(writer, false);
+  ObjectSampleCheckpoint::install(writer, false, false);
   return true;
 }
--- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp	Thu Aug 01 10:47:51 2019 -0700
+++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp	Fri Aug 02 10:43:30 2019 +0200
@@ -35,7 +35,7 @@
 
 class ObjectSampleCheckpoint : AllStatic {
  public:
-  static void install(JfrCheckpointWriter& writer, bool class_unload);
+  static void install(JfrCheckpointWriter& writer, bool class_unload, bool type_set);
   static void write(ObjectSampler* sampler, EdgeStore* edge_store, bool emit_all, Thread* thread);
   static int mark(ObjectSampler* sampler, ObjectSampleMarker& marker, bool emit_all);
 };
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Thu Aug 01 10:47:51 2019 -0700
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Fri Aug 02 10:43:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -311,7 +311,7 @@
   if (LeakProfiler::is_running()) {
     JfrCheckpointWriter leakp_writer(false, true, Thread::current());
     type_set.write(writer, &leakp_writer);
-    ObjectSampleCheckpoint::install(leakp_writer, true);
+    ObjectSampleCheckpoint::install(leakp_writer, true, true);
     return;
   }
   type_set.write(writer, NULL);
@@ -322,7 +322,7 @@
   if (LeakProfiler::is_running()) {
     JfrCheckpointWriter leakp_writer(false, true, Thread::current());
     type_set.write(writer, &leakp_writer);
-    ObjectSampleCheckpoint::install(leakp_writer, false);
+    ObjectSampleCheckpoint::install(leakp_writer, false, true);
     return;
   }
   type_set.write(writer, NULL);