8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
authorbrutisso
Fri, 09 Oct 2015 20:31:56 +0200
changeset 33152 6ad7fe735042
parent 33150 9e514d10a7bf
child 33153 b9545e2c94df
8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953 Reviewed-by: ecaspole, jwilhelm
hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp
hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/gc/shared/gcId.cpp
hotspot/src/share/vm/gc/shared/gcId.hpp
--- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp	Fri Oct 09 15:48:30 2015 +0200
+++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp	Fri Oct 09 20:31:56 2015 +0200
@@ -109,7 +109,7 @@
       break;
     }
 
-    GCIdMark gc_id_mark;
+    assert(GCId::current() != GCId::undefined(), "GC id should have been set up by the initial mark GC.");
     {
       ResourceMark rm;
       HandleMark   hm;
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Fri Oct 09 15:48:30 2015 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Fri Oct 09 20:31:56 2015 +0200
@@ -2612,15 +2612,18 @@
 }
 
 void G1CollectedHeap::register_concurrent_cycle_start(const Ticks& start_time) {
+  GCIdMarkAndRestore conc_gc_id_mark;
   collector_state()->set_concurrent_cycle_started(true);
   _gc_timer_cm->register_gc_start(start_time);
 
   _gc_tracer_cm->report_gc_start(gc_cause(), _gc_timer_cm->gc_start());
   trace_heap_before_gc(_gc_tracer_cm);
+  _cmThread->set_gc_id(GCId::current());
 }
 
 void G1CollectedHeap::register_concurrent_cycle_end() {
   if (collector_state()->concurrent_cycle_started()) {
+    GCIdMarkAndRestore conc_gc_id_mark(_cmThread->gc_id());
     if (_cm->has_aborted()) {
       _gc_tracer_cm->report_concurrent_mode_failure();
     }
@@ -2643,6 +2646,7 @@
     //   but before the concurrent cycle end has been registered.
     // Make sure that we only send the heap information once.
     if (!_heap_summary_sent) {
+      GCIdMarkAndRestore conc_gc_id_mark(_cmThread->gc_id());
       trace_heap_after_gc(_gc_tracer_cm);
       _heap_summary_sent = true;
     }
--- a/hotspot/src/share/vm/gc/shared/gcId.cpp	Fri Oct 09 15:48:30 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/gcId.cpp	Fri Oct 09 20:31:56 2015 +0200
@@ -60,6 +60,11 @@
 }
 
 GCIdMarkAndRestore::GCIdMarkAndRestore() : _gc_id(GCId::create()) {
+  _previous_gc_id = GCId::current(); // will assert that the GC Id is not undefined
+  currentNamedthread()->set_gc_id(_gc_id);
+}
+
+GCIdMarkAndRestore::GCIdMarkAndRestore(uint gc_id) : _gc_id(gc_id) {
   _previous_gc_id = GCId::current(); // will assert that the GC Id is not undefinied
   currentNamedthread()->set_gc_id(_gc_id);
 }
--- a/hotspot/src/share/vm/gc/shared/gcId.hpp	Fri Oct 09 15:48:30 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/gcId.hpp	Fri Oct 09 20:31:56 2015 +0200
@@ -55,6 +55,7 @@
   uint _previous_gc_id;
  public:
   GCIdMarkAndRestore();
+  GCIdMarkAndRestore(uint gc_id);
   ~GCIdMarkAndRestore();
 };