src/hotspot/share/gc/z/zTracer.cpp
author pliden
Tue, 12 Jun 2018 17:40:28 +0200
changeset 50525 767cdb97f103
child 50749 41a5b2de5ad3
permissions -rw-r--r--
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental) Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke Contributed-by: per.liden@oracle.com, stefan.karlsson@oracle.com, erik.osterlund@oracle.com, mikael.gerdin@oracle.com, kim.barrett@oracle.com, nils.eliasson@oracle.com, rickard.backman@oracle.com, rwestrel@redhat.com, coleen.phillimore@oracle.com, robbin.ehn@oracle.com, gerard.ziemski@oracle.com, hugh.wilkinson@intel.com, sandhya.viswanathan@intel.com, bill.npo.wheeler@intel.com, vinay.k.awasthi@intel.com, yasuenag@gmail.com

/*
 * Copyright (c) 2016, 2017, 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.
 */

#include "precompiled.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zTracer.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.hpp"
#include "jfr/jfrEvents.hpp"
#include "runtime/safepointVerifiers.hpp"

ZTracer* ZTracer::_tracer = NULL;

ZTracer::ZTracer() :
    GCTracer(Z) {}

void ZTracer::initialize() {
  _tracer = new (ResourceObj::C_HEAP, mtGC) ZTracer();
}

void ZTracer::send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value) {
  NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint());

  EventZStatisticsCounter e;
  if (e.should_commit()) {
    e.set_id(counter_id);
    e.set_increment(increment);
    e.set_value(value);
    e.commit();
  }
}

void ZTracer::send_stat_sampler(uint32_t sampler_id, uint64_t value) {
  NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint());

  EventZStatisticsSampler e;
  if (e.should_commit()) {
    e.set_id(sampler_id);
    e.set_value(value);
    e.commit();
  }
}

void ZTracer::send_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
  NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint());

  EventZThreadPhase e(UNTIMED);
  if (e.should_commit()) {
    e.set_gcId(GCId::current_or_undefined());
    e.set_name(name);
    e.set_starttime(start);
    e.set_endtime(end);
    e.commit();
  }
}

void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, bool nonblocking, bool noreserve) {
  NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint());

  EventZPageAllocation e;
  if (e.should_commit()) {
    e.set_pageSize(size);
    e.set_usedAfter(used);
    e.set_freeAfter(free);
    e.set_inCacheAfter(cache);
    e.set_nonBlocking(nonblocking);
    e.set_noReserve(noreserve);
    e.commit();
  }
}

void ZTracer::report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) {
  send_stat_counter(counter.id(), increment, value);
}

void ZTracer::report_stat_sampler(const ZStatSampler& sampler, uint64_t value) {
  send_stat_sampler(sampler.id(), value);
}

void ZTracer::report_thread_phase(const ZStatPhase& phase, const Ticks& start, const Ticks& end) {
  send_thread_phase(phase.name(), start, end);
}

void ZTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) {
  send_thread_phase(name, start, end);
}

void ZTracer::report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) {
  send_page_alloc(size, used, free, cache, flags.non_blocking(), flags.no_reserve());
}