8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
authorbrutisso
Thu, 08 Oct 2015 12:44:12 +0200
changeset 33146 77349b58b4c0
parent 33145 eda79f89d495
child 33147 52e5fbc71615
child 33148 68fa8b6c4340
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails Reviewed-by: jwilhelm, david
hotspot/src/share/vm/gc/shared/collectedHeap.cpp
hotspot/src/share/vm/gc/shared/gcId.cpp
hotspot/src/share/vm/gc/shared/gcId.hpp
hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Thu Oct 08 22:35:20 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Thu Oct 08 12:44:12 2015 +0200
@@ -573,12 +573,14 @@
 
 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
   if (HeapDumpBeforeFullGC) {
+    GCIdMarkAndRestore gc_id_mark;
     GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer);
     // We are doing a full collection and a heap dump before
     // full collection has been requested.
     HeapDumper::dump_heap();
   }
   if (PrintClassHistogramBeforeFullGC) {
+    GCIdMarkAndRestore gc_id_mark;
     GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer);
     VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */);
     inspector.doit();
@@ -587,10 +589,12 @@
 
 void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
   if (HeapDumpAfterFullGC) {
+    GCIdMarkAndRestore gc_id_mark;
     GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer);
     HeapDumper::dump_heap();
   }
   if (PrintClassHistogramAfterFullGC) {
+    GCIdMarkAndRestore gc_id_mark;
     GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer);
     VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */);
     inspector.doit();
--- a/hotspot/src/share/vm/gc/shared/gcId.cpp	Thu Oct 08 22:35:20 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/gcId.cpp	Thu Oct 08 12:44:12 2015 +0200
@@ -59,3 +59,11 @@
   currentNamedthread()->set_gc_id(GCId::undefined());
 }
 
+GCIdMarkAndRestore::GCIdMarkAndRestore() : _gc_id(GCId::create()) {
+  _previous_gc_id = GCId::current(); // will assert that the GC Id is not undefinied
+  currentNamedthread()->set_gc_id(_gc_id);
+}
+
+GCIdMarkAndRestore::~GCIdMarkAndRestore() {
+  currentNamedthread()->set_gc_id(_previous_gc_id);
+}
--- a/hotspot/src/share/vm/gc/shared/gcId.hpp	Thu Oct 08 22:35:20 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/gcId.hpp	Thu Oct 08 12:44:12 2015 +0200
@@ -29,6 +29,7 @@
 
 class GCId : public AllStatic {
   friend class GCIdMark;
+  friend class GCIdMarkAndRestore;
   static uint _next_id;
   static const uint UNDEFINED = (uint)-1;
   static const uint create();
@@ -49,4 +50,12 @@
   ~GCIdMark();
 };
 
+class GCIdMarkAndRestore : public StackObj {
+  uint _gc_id;
+  uint _previous_gc_id;
+ public:
+  GCIdMarkAndRestore();
+  ~GCIdMarkAndRestore();
+};
+
 #endif // SHARE_VM_GC_SHARED_GCID_HPP
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Thu Oct 08 22:35:20 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Thu Oct 08 12:44:12 2015 +0200
@@ -488,7 +488,7 @@
     bool must_restore_marks_for_biased_locking = false;
 
     if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
-      GCIdMark gc_id_mark;
+      GCIdMarkAndRestore gc_id_mark;
       if (!complete) {
         // The full_collections increment was missed above.
         increment_total_full_collections();