8152300: Convert G1_ALLOC_REGION_TRACING to unified logging

Reviewed-by: sjohanss, stefank
This commit is contained in:
Bengt Rutisson 2016-03-22 13:41:52 +01:00
parent dc360cad53
commit d444e55969
3 changed files with 38 additions and 38 deletions

View File

@ -26,6 +26,7 @@
#include "gc/g1/g1AllocRegion.inline.hpp" #include "gc/g1/g1AllocRegion.inline.hpp"
#include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1EvacStats.inline.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/orderAccess.inline.hpp" #include "runtime/orderAccess.inline.hpp"
G1CollectedHeap* G1AllocRegion::_g1h = NULL; G1CollectedHeap* G1AllocRegion::_g1h = NULL;
@ -194,44 +195,53 @@ HeapRegion* G1AllocRegion::release() {
return (alloc_region == _dummy_region) ? NULL : alloc_region; return (alloc_region == _dummy_region) ? NULL : alloc_region;
} }
#if G1_ALLOC_REGION_TRACING #ifndef PRODUCT
void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) { void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) {
// All the calls to trace that set either just the size or the size // All the calls to trace that set either just the size or the size
// and the result are considered part of level 2 tracing and are // and the result are considered part of detailed tracing and are
// skipped during level 1 tracing. // skipped during other tracing.
if ((actual_word_size == 0 && result == NULL) || (G1_ALLOC_REGION_TRACING > 1)) {
const size_t buffer_length = 128;
char hr_buffer[buffer_length];
char rest_buffer[buffer_length];
HeapRegion* alloc_region = _alloc_region; LogHandle(gc, alloc, region) log;
if (alloc_region == NULL) {
jio_snprintf(hr_buffer, buffer_length, "NULL"); if (!log.is_debug()) {
} else if (alloc_region == _dummy_region) { return;
jio_snprintf(hr_buffer, buffer_length, "DUMMY"); }
bool detailed_info = log.is_trace();
if ((actual_word_size == 0 && result == NULL) || detailed_info) {
ResourceMark rm;
outputStream* out;
if (detailed_info) {
out = log.trace_stream();
} else { } else {
jio_snprintf(hr_buffer, buffer_length, out = log.debug_stream();
HR_FORMAT, HR_FORMAT_PARAMS(alloc_region));
} }
if (G1_ALLOC_REGION_TRACING > 1) { out->print("%s: %u ", _name, _count);
if (_alloc_region == NULL) {
out->print("NULL");
} else if (_alloc_region == _dummy_region) {
out->print("DUMMY");
} else {
out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region));
}
out->print(" : %s", str);
if (detailed_info) {
if (result != NULL) { if (result != NULL) {
jio_snprintf(rest_buffer, buffer_length, "min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT, out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT,
min_word_size, desired_word_size, actual_word_size, result); min_word_size, desired_word_size, actual_word_size, p2i(result));
} else if (min_word_size != 0) { } else if (min_word_size != 0) {
jio_snprintf(rest_buffer, buffer_length, "min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size); out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size);
} else {
jio_snprintf(rest_buffer, buffer_length, "");
} }
} else {
jio_snprintf(rest_buffer, buffer_length, "");
} }
out->cr();
tty->print_cr("[%s] %u %s : %s %s",
_name, _count, hr_buffer, str, rest_buffer);
} }
} }
#endif // G1_ALLOC_REGION_TRACING #endif // PRODUCT
G1AllocRegion::G1AllocRegion(const char* name, G1AllocRegion::G1AllocRegion(const char* name,
bool bot_updates) bool bot_updates)

View File

@ -31,9 +31,6 @@
class G1CollectedHeap; class G1CollectedHeap;
// 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing
#define G1_ALLOC_REGION_TRACING 0
// A class that holds a region that is active in satisfying allocation // A class that holds a region that is active in satisfying allocation
// requests, potentially issued in parallel. When the active region is // requests, potentially issued in parallel. When the active region is
// full it will be retired and replaced with a new one. The // full it will be retired and replaced with a new one. The
@ -213,19 +210,11 @@ public:
// is returned after it's been retired. // is returned after it's been retired.
virtual HeapRegion* release(); virtual HeapRegion* release();
#if G1_ALLOC_REGION_TRACING
void trace(const char* str, void trace(const char* str,
size_t min_word_size = 0, size_t min_word_size = 0,
size_t desired_word_size = 0, size_t desired_word_size = 0,
size_t actual_word_size = 0, size_t actual_word_size = 0,
HeapWord* result = NULL); HeapWord* result = NULL) PRODUCT_RETURN;
#else // G1_ALLOC_REGION_TRACING
void trace(const char* str,
size_t min_word_size = 0,
size_t desired_word_size = 0,
size_t actual_word_size = 0,
HeapWord* result = NULL) { }
#endif // G1_ALLOC_REGION_TRACING
}; };
class MutatorAllocRegion : public G1AllocRegion { class MutatorAllocRegion : public G1AllocRegion {

View File

@ -42,6 +42,7 @@
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, age)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, age)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc, region)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, barrier)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, barrier)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, classhisto)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, classhisto)) \
LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, compaction)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, compaction)) \