< prev index next >
src/share/vm/gc/cms/parNewGeneration.cpp
Print this page
@@ -43,10 +43,11 @@
#include "gc/shared/space.hpp"
#include "gc/shared/spaceDecorator.hpp"
#include "gc/shared/strongRootsScope.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "gc/shared/workgroup.hpp"
+#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/handles.hpp"
@@ -268,12 +269,12 @@
void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj, size_t word_sz) {
to_space_alloc_buffer()->undo_allocation(obj, word_sz);
}
void ParScanThreadState::print_promotion_failure_size() {
- if (_promotion_failed_info.has_failed() && PrintPromotionFailure) {
- gclog_or_tty->print(" (%d: promotion failure size = " SIZE_FORMAT ") ",
+ if (_promotion_failed_info.has_failed()) {
+ log_trace(gc, promotion)(" (%d: promotion failure size = " SIZE_FORMAT ") ",
_thread_num, _promotion_failed_info.first_size());
}
}
class ParScanThreadStateSet: private ResourceArray {
@@ -296,15 +297,15 @@
void reset(uint active_workers, bool promotion_failed);
void flush();
#if TASKQUEUE_STATS
static void
- print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
- void print_termination_stats(outputStream* const st = gclog_or_tty);
+ print_termination_stats_hdr(outputStream* const st);
+ void print_termination_stats();
static void
- print_taskqueue_stats_hdr(outputStream* const st = gclog_or_tty);
- void print_taskqueue_stats(outputStream* const st = gclog_or_tty);
+ print_taskqueue_stats_hdr(outputStream* const st);
+ void print_taskqueue_stats();
void reset_stats();
#endif // TASKQUEUE_STATS
private:
ParallelTaskTerminator& _term;
@@ -381,11 +382,19 @@
st->print_raw_cr(" elapsed --strong roots-- -------termination-------");
st->print_raw_cr("thr ms ms % ms % attempts");
st->print_raw_cr("--- --------- --------- ------ --------- ------ --------");
}
-void ParScanThreadStateSet::print_termination_stats(outputStream* const st) {
+void ParScanThreadStateSet::print_termination_stats() {
+ LogHandle(gc, task, stats) log;
+ if (!log.is_debug()) {
+ return;
+ }
+
+ ResourceMark rm;
+ outputStream* st = log.debug_stream();
+
print_termination_stats_hdr(st);
for (int i = 0; i < length(); ++i) {
const ParScanThreadState & pss = thread_state(i);
const double elapsed_ms = pss.elapsed_time() * 1000.0;
@@ -402,11 +411,17 @@
st->print_raw_cr("GC Task Stats");
st->print_raw("thr "); TaskQueueStats::print_header(1, st); st->cr();
st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr();
}
-void ParScanThreadStateSet::print_taskqueue_stats(outputStream* const st) {
+void ParScanThreadStateSet::print_taskqueue_stats() {
+ LogHandle(gc, task, stats) log;
+ if (!log.is_develop()) {
+ return;
+ }
+ ResourceMark rm;
+ outputStream* st = log.develop_stream();
print_taskqueue_stats_hdr(st);
TaskQueueStats totals;
for (int i = 0; i < length(); ++i) {
const ParScanThreadState & pss = thread_state(i);
@@ -821,13 +836,11 @@
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.
remove_forwarding_pointers();
- if (PrintGCDetails) {
- gclog_or_tty->print(" (promotion failed)");
- }
+ log_info(gc, promotion)("Promotion failed");
// All the spaces are in play for mark-sweep.
swap_spaces(); // Make life simpler for CMS || rescan; see 6483690.
from()->set_next_compaction_space(to());
gch->set_incremental_collection_failed();
// Inform the next generation that a promotion failure occurred.
@@ -880,13 +893,11 @@
if (UseAdaptiveSizePolicy) {
set_survivor_overflow(false);
size_policy->minor_collection_begin();
}
- GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL);
- // Capture heap used before collection (for printing).
- size_t gch_prev_used = gch->used();
+ GCTraceTime(Trace, gc) t1("ParNew", NULL, gch->gc_cause());
age_table()->clear();
to()->clear(SpaceDecorator::Mangle);
gch->save_marks();
@@ -988,16 +999,12 @@
if (ResizePLAB) {
plab_stats()->adjust_desired_plab_sz();
}
- if (PrintGC && !PrintGCDetails) {
- gch->print_heap_change(gch_prev_used);
- }
-
- TASKQUEUE_STATS_ONLY(if (PrintTerminationStats) thread_state_set.print_termination_stats());
- TASKQUEUE_STATS_ONLY(if (PrintTaskqueue) thread_state_set.print_taskqueue_stats());
+ TASKQUEUE_STATS_ONLY(thread_state_set.print_termination_stats());
+ TASKQUEUE_STATS_ONLY(thread_state_set.print_taskqueue_stats());
if (UseAdaptiveSizePolicy) {
size_policy->minor_collection_end(gch->gc_cause());
size_policy->avg_survived()->sample(from()->used());
}
@@ -1146,19 +1153,15 @@
new_obj->incr_age();
par_scan_state->age_table()->add(new_obj, sz);
}
assert(new_obj != NULL, "just checking");
-#ifndef PRODUCT
// This code must come after the CAS test, or it will print incorrect
// information.
- if (TraceScavenge) {
- gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
+ log_develop(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
is_in_reserved(new_obj) ? "copying" : "tenuring",
new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
- }
-#endif
if (forward_ptr == NULL) {
oop obj_to_push = new_obj;
if (par_scan_state->should_be_partially_scanned(obj_to_push, old)) {
// Length field used as index of next element to be scanned.
@@ -1176,13 +1179,11 @@
simulate_overflow = true;
}
)
if (simulate_overflow || !par_scan_state->work_queue()->push(obj_to_push)) {
// Add stats for overflow pushes.
- if (Verbose && PrintGCDetails) {
- gclog_or_tty->print("queue overflow!\n");
- }
+ log_develop(gc)("Queue overflow");
push_on_overflow_list(old, par_scan_state);
TASKQUEUE_STATS_ONLY(par_scan_state->taskqueue_stats().record_overflow(0));
}
return new_obj;
< prev index next >