< prev index next >

src/hotspot/share/gc/shared/gcTraceTime.inline.hpp

Print this page
rev 58036 : [mq]: asynclog

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2020, 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.

@@ -34,11 +34,12 @@
 #include "memory/universe.hpp"
 #include "utilities/ticks.hpp"
 
 #define LOG_STOP_HEAP_FORMAT SIZE_FORMAT "M->" SIZE_FORMAT "M("  SIZE_FORMAT "M)"
 
-inline void GCTraceTimeImpl::log_start(jlong start_counter) {
+template <typename Handle1, typename Handle2>
+inline void GCTraceTimeImpl<Handle1, Handle2>::log_start(jlong start_counter) {
   if (_out_start.is_enabled()) {
     LogStream out(_out_start);
 
     out.print("%s", _title);
     if (_gc_cause != GCCause::_no_gc) {

@@ -46,11 +47,12 @@
     }
     out.cr();
   }
 }
 
-inline void GCTraceTimeImpl::log_stop(jlong start_counter, jlong stop_counter) {
+template <typename Handle1, typename Handle2>
+inline void GCTraceTimeImpl<Handle1, Handle2>::log_stop(jlong start_counter, jlong stop_counter) {
   double duration_in_ms = TimeHelper::counter_to_millis(stop_counter - start_counter);
   double start_time_in_secs = TimeHelper::counter_to_seconds(start_counter);
   double stop_time_in_secs = TimeHelper::counter_to_seconds(stop_counter);
 
   LogStream out(_out_stop);

@@ -70,17 +72,19 @@
   }
 
   out.print_cr(" %.3fms", duration_in_ms);
 }
 
-inline void GCTraceTimeImpl::time_stamp(Ticks& ticks) {
+template <typename Handle1, typename Handle2>
+inline void GCTraceTimeImpl<Handle1, Handle2>::time_stamp(Ticks& ticks) {
   if (_enabled || _timer != NULL) {
     ticks.stamp();
   }
 }
 
-inline GCTraceTimeImpl::GCTraceTimeImpl(LogTargetHandle out_start, LogTargetHandle out_stop, const char* title, GCTimer* timer, GCCause::Cause gc_cause, bool log_heap_usage) :
+template <typename Handle1, typename Handle2>
+inline GCTraceTimeImpl<Handle1, Handle2>::GCTraceTimeImpl(Handle1 out_start, Handle2 out_stop, const char* title, GCTimer* timer, GCCause::Cause gc_cause, bool log_heap_usage) :
   _out_start(out_start),
   _out_stop(out_stop),
   _enabled(out_stop.is_enabled()),
   _start_ticks(),
   _title(title),

@@ -97,12 +101,12 @@
   }
   if (_timer != NULL) {
     _timer->register_gc_phase_start(_title, _start_ticks);
   }
 }
-
-inline GCTraceTimeImpl::~GCTraceTimeImpl() {
+template <typename Handle1, typename Handle2>
+inline GCTraceTimeImpl<Handle1, Handle2>::~GCTraceTimeImpl() {
   Ticks stop_ticks;
   time_stamp(stop_ticks);
   if (_enabled) {
     log_stop(_start_ticks.value(), stop_ticks.value());
   }

@@ -148,14 +152,27 @@
 
   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()
 }
 
+template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
+GCAsyncTraceTimeImplWrapper<level, T0, T1, T2, T3, T4, GuardTag>::GCAsyncTraceTimeImplWrapper(
+    const char* title, GCTimer* timer, GCCause::Cause gc_cause, bool log_heap_usage)
+    : _impl(
+        AsyncLogTargetHandle::create<level, T0, INJECT_START_TAG(T1, T2, T3, T4), GuardTag>(),
+        AsyncLogTargetHandle::create<level, T0, T1, T2, T3, T4, GuardTag>(),
+        title,
+        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()
+}
+
 #undef INJECT_START_TAG
 
-template <LogLevelType Level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
-GCTraceTimeImplWrapper<Level, T0, T1, T2, T3, T4, GuardTag>::~GCTraceTimeImplWrapper() {}
 
 #define GCTraceTime(Level, ...) GCTraceTimeImplWrapper<LogLevel::Level, LOG_TAGS(__VA_ARGS__)>
 #define GCTraceConcTime(Level, ...) GCTraceConcTimeImpl<LogLevel::Level, LOG_TAGS(__VA_ARGS__)>
 
 #endif // SHARE_GC_SHARED_GCTRACETIME_INLINE_HPP
< prev index next >