Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/shenandoahGCTraceTime.cpp
38920 views
/*1* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc_implementation/shared/gcTimer.hpp"26#include "gc_implementation/shared/gcTrace.hpp"27#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"28#include "gc_implementation/shenandoah/shenandoahGCTraceTime.hpp"29#include "runtime/globals.hpp"30#include "runtime/os.hpp"31#include "runtime/safepoint.hpp"32#include "runtime/thread.inline.hpp"33#include "runtime/timer.hpp"34#include "utilities/ostream.hpp"35#include "utilities/ticks.hpp"3637ShenandoahGCTraceTime::ShenandoahGCTraceTime(const char* title, bool doit, GCTimer* timer, GCId gc_id, bool print_heap) :38_title(title), _doit(doit), _timer(timer), _start_counter(), _heap(ShenandoahHeap::heap()), _print_heap(print_heap), _gc_id(gc_id) {39if (_doit || _timer != NULL) {40_start_counter.stamp();41}4243if (_timer != NULL) {44_timer->register_gc_phase_start(title, _start_counter);45}4647if (_doit) {48_bytes_before = _heap->used();4950gclog_or_tty->date_stamp(PrintGCDateStamps);51gclog_or_tty->stamp(PrintGCTimeStamps);52if (PrintGCID && !_gc_id.is_undefined()) {53gclog_or_tty->print("#%u: ", _gc_id.id());54}55gclog_or_tty->print("[%s", title);5657// Detailed view prints the "start" message58if (PrintGCDetails) {59gclog_or_tty->print_cr(", start]");60}6162gclog_or_tty->flush();63gclog_or_tty->inc();64}65}6667ShenandoahGCTraceTime::~ShenandoahGCTraceTime() {68Ticks stop_counter;6970if (_doit || _timer != NULL) {71stop_counter.stamp();72}7374if (_timer != NULL) {75_timer->register_gc_phase_end(stop_counter);76}7778if (_doit) {79const Tickspan duration = stop_counter - _start_counter;80double secs = duration.seconds();8182size_t bytes_after = _heap->used();83size_t capacity = _heap->capacity();8485// Detailed view has to restart the logging here, because "start" was printed86if (PrintGCDetails) {87gclog_or_tty->date_stamp(PrintGCDateStamps);88gclog_or_tty->stamp(PrintGCTimeStamps);89if (PrintGCID && !_gc_id.is_undefined()) {90gclog_or_tty->print("#%u: ", _gc_id.id());91}92gclog_or_tty->print("[%s", _title);93}9495if (_print_heap) {96gclog_or_tty->print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s(" SIZE_FORMAT "%s)",97byte_size_in_proper_unit(_bytes_before),98proper_unit_for_byte_size(_bytes_before),99byte_size_in_proper_unit(bytes_after),100proper_unit_for_byte_size(bytes_after),101byte_size_in_proper_unit(capacity),102proper_unit_for_byte_size(capacity));103}104105gclog_or_tty->dec();106gclog_or_tty->print_cr(", %.3f ms]", secs * 1000);107gclog_or_tty->flush();108}109}110111112