/* * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
inline GCTraceTimeImpl::GCTraceTimeImpl( constchar* title,
LogTargetHandle out_start,
LogTargetHandle out_end,
GCTimer* timer,
GCCause::Cause gc_cause, bool log_heap_usage) :
_logger(title,
gc_cause,
log_heap_usage,
out_start,
out_end),
_timer(title, timer), // Only register the callbacks if they are enabled
_driver((_logger.is_enabled() ? &_logger : NULL),
(timer != NULL ? &_timer : NULL)) {}
// Figure out the first __NO_TAG position and replace it with 'start'. #define INJECT_START_TAG(T1, T2, T3, T4) \
(( T1 == LogTag::__NO_TAG) ? PREFIX_LOG_TAG(start) : T1), \
((T1 != LogTag::__NO_TAG && T2 == LogTag::__NO_TAG) ? PREFIX_LOG_TAG(start) : T2), \
((T2 != LogTag::__NO_TAG && T3 == LogTag::__NO_TAG) ? PREFIX_LOG_TAG(start) : T3), \
((T3 != LogTag::__NO_TAG && T4 == LogTag::__NO_TAG) ? PREFIX_LOG_TAG(start) : T4)
// Shim to convert LogTag templates to LogTargetHandle template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag> class GCTraceTimeLoggerWrapper : public GCTraceTimeLoggerImpl { public:
GCTraceTimeLoggerWrapper(constchar* title, GCCause::Cause gc_cause, bool log_heap_usage) :
GCTraceTimeLoggerImpl(
title,
gc_cause,
log_heap_usage,
LogTargetHandle::create<level, T0, INJECT_START_TAG(T1, T2, T3, T4), GuardTag>(),
LogTargetHandle::create<level, T0, T1, T2, T3, T4, GuardTag>()) {
STATIC_ASSERT(T0 != LogTag::__NO_TAG); // Need some tag to log on.
STATIC_ASSERT(T4 == LogTag::__NO_TAG); // Need to leave at least the last tag for the "start" tag in log_start()
}
};
// Shim to convert LogTag templates to LogTargetHandle template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag> class GCTraceTimeWrapper : public StackObj {
GCTraceTimeImpl _impl; public:
GCTraceTimeWrapper( constchar* title,
GCTimer* timer = NULL,
GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false) :
_impl(title,
LogTargetHandle::create<level, T0, INJECT_START_TAG(T1, T2, T3, T4), GuardTag>(),
LogTargetHandle::create<level, T0, T1, T2, T3, T4, GuardTag>(),
timer,
gc_cause,
log_heap_usage) {
STATIC_ASSERT(T0 != LogTag::__NO_TAG); // Need some tag to log on.
STATIC_ASSERT(T4 == LogTag::__NO_TAG); // Need to leave at least the last tag for the "start" tag in log_start()
}
};
// This is the main macro used by most GCTraceTime users. // // Examples: // GCTraceTime(Info, gc, phase) t("The sub-phase name"); // Log to unified logging on gc+phase=info level. // // GCTraceTime(Info, gc, phase) t("The sub-phase name", timer); // Same as above but also register the times in the GCTimer timer. // // See GCTraceTimeWrapper for the available parameters. #define GCTraceTime(Level, ...) GCTraceTimeWrapper<LogLevel::Level, LOG_TAGS(__VA_ARGS__)>
// The vanilla GCTraceTime macro doesn't cater to all use-cases. // This macro allows the users to create the unified logging callback. // // Example: // GCTraceTimeLogger(Info, gc) logger(_message, GCCause::_no_gc, true); // GCTraceTimePauseTimer timer(_message, g1h->concurrent_mark()->gc_timer_cm()); // GCTraceTimeDriver t(&logger, &timer); #define GCTraceTimeLogger(Level, ...) GCTraceTimeLoggerWrapper<LogLevel::Level, LOG_TAGS(__VA_ARGS__)>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.