8066566: Refactor ParNewGeneration to contain ParNewTracer
Reviewed-by: ehelin, kbarrett
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Feb 11 14:47:21 2015 +0100
@@ -308,7 +308,7 @@
inline ParScanThreadState& thread_state(int i);
- void trace_promotion_failed(YoungGCTracer& gc_tracer);
+ void trace_promotion_failed(const YoungGCTracer* gc_tracer);
void reset(int active_workers, bool promotion_failed);
void flush();
@@ -357,10 +357,10 @@
return ((ParScanThreadState*)_data)[i];
}
-void ParScanThreadStateSet::trace_promotion_failed(YoungGCTracer& gc_tracer) {
+void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_tracer) {
for (int i = 0; i < length(); ++i) {
if (thread_state(i).promotion_failed()) {
- gc_tracer.report_promotion_failed(thread_state(i).promotion_failed_info());
+ gc_tracer->report_promotion_failed(thread_state(i).promotion_failed_info());
thread_state(i).promotion_failed_info().reset();
}
}
@@ -883,7 +883,7 @@
// A Generation that does parallel young-gen collection.
-void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) {
+void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set) {
assert(_promo_failure_scan_stack.is_empty(), "post condition");
_promo_failure_scan_stack.clear(true); // Clear cached segments.
@@ -899,10 +899,10 @@
_next_gen->promotion_failure_occurred();
// Trace promotion failure in the parallel GC threads
- thread_state_set.trace_promotion_failed(gc_tracer);
+ thread_state_set.trace_promotion_failed(gc_tracer());
// Single threaded code may have reported promotion failure to the global state
if (_promotion_failed_info.has_failed()) {
- gc_tracer.report_promotion_failed(_promotion_failed_info);
+ _gc_tracer.report_promotion_failed(_promotion_failed_info);
}
// Reset the PromotionFailureALot counters.
NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
@@ -941,9 +941,8 @@
}
assert(to()->is_empty(), "Else not collection_attempt_is_safe");
- ParNewTracer gc_tracer;
- gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
- gch->trace_heap_before_gc(&gc_tracer);
+ _gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
+ gch->trace_heap_before_gc(gc_tracer());
init_assuming_no_promotion_failure();
@@ -952,7 +951,7 @@
size_policy->minor_collection_begin();
}
- GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id());
+ GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, _gc_tracer.gc_id());
// Capture heap used before collection (for printing).
size_t gch_prev_used = gch->used();
@@ -994,7 +993,7 @@
// Trace and reset failed promotion info.
if (promotion_failed()) {
- thread_state_set.trace_promotion_failed(gc_tracer);
+ thread_state_set.trace_promotion_failed(gc_tracer());
}
// Process (weak) reference objects found during scavenge.
@@ -1015,16 +1014,16 @@
ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
stats = rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, &task_executor,
- _gc_timer, gc_tracer.gc_id());
+ _gc_timer, _gc_tracer.gc_id());
} else {
thread_state_set.flush();
gch->set_par_threads(0); // 0 ==> non-parallel.
gch->save_marks();
stats = rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, NULL,
- _gc_timer, gc_tracer.gc_id());
+ _gc_timer, _gc_tracer.gc_id());
}
- gc_tracer.report_gc_reference_stats(stats);
+ _gc_tracer.report_gc_reference_stats(stats);
if (!promotion_failed()) {
// Swap the survivor spaces.
eden()->clear(SpaceDecorator::Mangle);
@@ -1049,7 +1048,7 @@
adjust_desired_tenuring_threshold();
} else {
- handle_promotion_failed(gch, thread_state_set, gc_tracer);
+ handle_promotion_failed(gch, thread_state_set);
}
// set new iteration safe limit for the survivor spaces
from()->set_concurrent_iteration_safe_limit(from()->top());
@@ -1088,12 +1087,12 @@
}
rp->verify_no_references_recorded();
- gch->trace_heap_after_gc(&gc_tracer);
- gc_tracer.report_tenuring_threshold(tenuring_threshold());
+ gch->trace_heap_after_gc(gc_tracer());
+ _gc_tracer.report_tenuring_threshold(tenuring_threshold());
_gc_timer->register_gc_end();
- gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
+ _gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
}
static int sum;
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Wed Feb 11 14:47:21 2015 +0100
@@ -333,6 +333,9 @@
// references to live referent.
DefNewGeneration::IsAliveClosure _is_alive_closure;
+ // GC tracer that should be used during collection.
+ ParNewTracer _gc_tracer;
+
static oop real_forwardee_slow(oop obj);
static void waste_some_time();
@@ -340,7 +343,7 @@
// word being overwritten with a self-forwarding-pointer.
void preserve_mark_if_necessary(oop obj, markOop m);
- void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer);
+ void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set);
protected:
@@ -411,6 +414,10 @@
return _plab_stats.desired_plab_sz();
}
+ const ParNewTracer* gc_tracer() const {
+ return &_gc_tracer;
+ }
+
static oop real_forwardee(oop obj);
DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);)
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Wed Feb 11 14:47:21 2015 +0100
@@ -663,7 +663,7 @@
}
}
-void ParallelScavengeHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
+void ParallelScavengeHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
const PSHeapSummary& heap_summary = create_ps_heap_summary();
gc_tracer->report_gc_heap_summary(when, heap_summary);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Wed Feb 11 14:47:21 2015 +0100
@@ -64,7 +64,7 @@
// The task manager
static GCTaskManager* _gc_task_manager;
- void trace_heap(GCWhen::Type when, GCTracer* tracer);
+ void trace_heap(GCWhen::Type when, const GCTracer* tracer);
protected:
static inline size_t total_invocations();
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp Wed Feb 11 14:47:21 2015 +0100
@@ -162,7 +162,7 @@
_tenuring_threshold = UNSET_TENURING_THRESHOLD;
}
-void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
+void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) const {
assert_set_gc_id();
send_promotion_failed_event(pf_info);
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp Wed Feb 11 14:47:21 2015 +0100
@@ -153,7 +153,7 @@
virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
public:
- void report_promotion_failed(const PromotionFailedInfo& pf_info);
+ void report_promotion_failed(const PromotionFailedInfo& pf_info) const;
void report_tenuring_threshold(const uint tenuring_threshold);
/*
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Wed Feb 11 14:47:21 2015 +0100
@@ -132,7 +132,7 @@
assert_locked_or_safepoint(CodeCache_lock);
}
-void CollectedHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
const GCHeapSummary& heap_summary = create_heap_summary();
gc_tracer->report_gc_heap_summary(when, heap_summary);
@@ -140,11 +140,11 @@
gc_tracer->report_metaspace_summary(when, metaspace_summary);
}
-void CollectedHeap::trace_heap_before_gc(GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap_before_gc(const GCTracer* gc_tracer) {
trace_heap(GCWhen::BeforeGC, gc_tracer);
}
-void CollectedHeap::trace_heap_after_gc(GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap_after_gc(const GCTracer* gc_tracer) {
trace_heap(GCWhen::AfterGC, gc_tracer);
}
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Tue Feb 10 17:41:19 2015 -0500
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Wed Feb 11 14:47:21 2015 +0100
@@ -175,7 +175,7 @@
// Fill with a single object (either an int array or a java.lang.Object).
static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
- virtual void trace_heap(GCWhen::Type when, GCTracer* tracer);
+ virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
// Verification functions
virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
@@ -606,8 +606,8 @@
virtual void register_nmethod(nmethod* nm);
virtual void unregister_nmethod(nmethod* nm);
- void trace_heap_before_gc(GCTracer* gc_tracer);
- void trace_heap_after_gc(GCTracer* gc_tracer);
+ void trace_heap_before_gc(const GCTracer* gc_tracer);
+ void trace_heap_after_gc(const GCTracer* gc_tracer);
// Heap verification
virtual void verify(bool silent, VerifyOption option) = 0;