# HG changeset patch # User brutisso # Date 1444301052 -7200 # Node ID 77349b58b4c0ffdd2c5dcc146ae772d79c3e47c0 # Parent eda79f89d495778e813363fa319622115fbd9af0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails Reviewed-by: jwilhelm, david diff -r eda79f89d495 -r 77349b58b4c0 hotspot/src/share/vm/gc/shared/collectedHeap.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(); diff -r eda79f89d495 -r 77349b58b4c0 hotspot/src/share/vm/gc/shared/gcId.cpp --- 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); +} diff -r eda79f89d495 -r 77349b58b4c0 hotspot/src/share/vm/gc/shared/gcId.hpp --- 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 diff -r eda79f89d495 -r 77349b58b4c0 hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp --- 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();