8066566: Refactor ParNewGeneration to contain ParNewTracer

Reviewed-by: ehelin, kbarrett
This commit is contained in:
Marcus Larsson 2015-02-11 14:47:21 +01:00
parent 2c63608419
commit 20bfd4cf7c
8 changed files with 35 additions and 29 deletions

View file

@ -308,7 +308,7 @@ public:
inline ParScanThreadState& thread_state(int i); 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 reset(int active_workers, bool promotion_failed);
void flush(); void flush();
@ -357,10 +357,10 @@ inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i)
return ((ParScanThreadState*)_data)[i]; 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) { for (int i = 0; i < length(); ++i) {
if (thread_state(i).promotion_failed()) { 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(); thread_state(i).promotion_failed_info().reset();
} }
} }
@ -883,7 +883,7 @@ void EvacuateFollowersClosureGeneral::do_void() {
// A Generation that does parallel young-gen collection. // 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"); assert(_promo_failure_scan_stack.is_empty(), "post condition");
_promo_failure_scan_stack.clear(true); // Clear cached segments. _promo_failure_scan_stack.clear(true); // Clear cached segments.
@ -899,10 +899,10 @@ void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThr
_next_gen->promotion_failure_occurred(); _next_gen->promotion_failure_occurred();
// Trace promotion failure in the parallel GC threads // 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 // Single threaded code may have reported promotion failure to the global state
if (_promotion_failed_info.has_failed()) { 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. // Reset the PromotionFailureALot counters.
NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();) NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
@ -941,9 +941,8 @@ void ParNewGeneration::collect(bool full,
} }
assert(to()->is_empty(), "Else not collection_attempt_is_safe"); 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());
gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start()); gch->trace_heap_before_gc(gc_tracer());
gch->trace_heap_before_gc(&gc_tracer);
init_assuming_no_promotion_failure(); init_assuming_no_promotion_failure();
@ -952,7 +951,7 @@ void ParNewGeneration::collect(bool full,
size_policy->minor_collection_begin(); 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). // Capture heap used before collection (for printing).
size_t gch_prev_used = gch->used(); size_t gch_prev_used = gch->used();
@ -994,7 +993,7 @@ void ParNewGeneration::collect(bool full,
// Trace and reset failed promotion info. // Trace and reset failed promotion info.
if (promotion_failed()) { 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. // Process (weak) reference objects found during scavenge.
@ -1015,16 +1014,16 @@ void ParNewGeneration::collect(bool full,
ParNewRefProcTaskExecutor task_executor(*this, thread_state_set); ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
stats = rp->process_discovered_references(&is_alive, &keep_alive, stats = rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, &task_executor, &evacuate_followers, &task_executor,
_gc_timer, gc_tracer.gc_id()); _gc_timer, _gc_tracer.gc_id());
} else { } else {
thread_state_set.flush(); thread_state_set.flush();
gch->set_par_threads(0); // 0 ==> non-parallel. gch->set_par_threads(0); // 0 ==> non-parallel.
gch->save_marks(); gch->save_marks();
stats = rp->process_discovered_references(&is_alive, &keep_alive, stats = rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, NULL, &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()) { if (!promotion_failed()) {
// Swap the survivor spaces. // Swap the survivor spaces.
eden()->clear(SpaceDecorator::Mangle); eden()->clear(SpaceDecorator::Mangle);
@ -1049,7 +1048,7 @@ void ParNewGeneration::collect(bool full,
adjust_desired_tenuring_threshold(); adjust_desired_tenuring_threshold();
} else { } 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 // set new iteration safe limit for the survivor spaces
from()->set_concurrent_iteration_safe_limit(from()->top()); from()->set_concurrent_iteration_safe_limit(from()->top());
@ -1088,12 +1087,12 @@ void ParNewGeneration::collect(bool full,
} }
rp->verify_no_references_recorded(); rp->verify_no_references_recorded();
gch->trace_heap_after_gc(&gc_tracer); gch->trace_heap_after_gc(gc_tracer());
gc_tracer.report_tenuring_threshold(tenuring_threshold()); _gc_tracer.report_tenuring_threshold(tenuring_threshold());
_gc_timer->register_gc_end(); _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; static int sum;

View file

@ -333,6 +333,9 @@ class ParNewGeneration: public DefNewGeneration {
// references to live referent. // references to live referent.
DefNewGeneration::IsAliveClosure _is_alive_closure; DefNewGeneration::IsAliveClosure _is_alive_closure;
// GC tracer that should be used during collection.
ParNewTracer _gc_tracer;
static oop real_forwardee_slow(oop obj); static oop real_forwardee_slow(oop obj);
static void waste_some_time(); static void waste_some_time();
@ -340,7 +343,7 @@ class ParNewGeneration: public DefNewGeneration {
// word being overwritten with a self-forwarding-pointer. // word being overwritten with a self-forwarding-pointer.
void preserve_mark_if_necessary(oop obj, markOop m); 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: protected:
@ -411,6 +414,10 @@ class ParNewGeneration: public DefNewGeneration {
return _plab_stats.desired_plab_sz(); return _plab_stats.desired_plab_sz();
} }
const ParNewTracer* gc_tracer() const {
return &_gc_tracer;
}
static oop real_forwardee(oop obj); static oop real_forwardee(oop obj);
DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);) DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);)

View file

@ -663,7 +663,7 @@ void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
} }
} }
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(); const PSHeapSummary& heap_summary = create_ps_heap_summary();
gc_tracer->report_gc_heap_summary(when, heap_summary); gc_tracer->report_gc_heap_summary(when, heap_summary);

View file

@ -64,7 +64,7 @@ class ParallelScavengeHeap : public CollectedHeap {
// The task manager // The task manager
static GCTaskManager* _gc_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: protected:
static inline size_t total_invocations(); static inline size_t total_invocations();

View file

@ -162,7 +162,7 @@ void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* t
_tenuring_threshold = UNSET_TENURING_THRESHOLD; _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(); assert_set_gc_id();
send_promotion_failed_event(pf_info); send_promotion_failed_event(pf_info);

View file

@ -153,7 +153,7 @@ class YoungGCTracer : public GCTracer {
virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
public: 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); void report_tenuring_threshold(const uint tenuring_threshold);
/* /*

View file

@ -132,7 +132,7 @@ void CollectedHeap::unregister_nmethod(nmethod* nm) {
assert_locked_or_safepoint(CodeCache_lock); 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(); const GCHeapSummary& heap_summary = create_heap_summary();
gc_tracer->report_gc_heap_summary(when, heap_summary); gc_tracer->report_gc_heap_summary(when, heap_summary);
@ -140,11 +140,11 @@ void CollectedHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
gc_tracer->report_metaspace_summary(when, metaspace_summary); 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); 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); trace_heap(GCWhen::AfterGC, gc_tracer);
} }

View file

@ -175,7 +175,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
// Fill with a single object (either an int array or a java.lang.Object). // 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); 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 // Verification functions
virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size) virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
@ -606,8 +606,8 @@ class CollectedHeap : public CHeapObj<mtInternal> {
virtual void register_nmethod(nmethod* nm); virtual void register_nmethod(nmethod* nm);
virtual void unregister_nmethod(nmethod* nm); virtual void unregister_nmethod(nmethod* nm);
void trace_heap_before_gc(GCTracer* gc_tracer); void trace_heap_before_gc(const GCTracer* gc_tracer);
void trace_heap_after_gc(GCTracer* gc_tracer); void trace_heap_after_gc(const GCTracer* gc_tracer);
// Heap verification // Heap verification
virtual void verify(bool silent, VerifyOption option) = 0; virtual void verify(bool silent, VerifyOption option) = 0;