Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/g1/g1HRPrinter.hpp
38920 views
/*1* Copyright (c) 2011, 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#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP25#define SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP2627#include "memory/allocation.hpp"28#include "gc_implementation/g1/heapRegion.hpp"2930#define SKIP_RETIRED_FULL_REGIONS 13132class G1HRPrinter VALUE_OBJ_CLASS_SPEC {33public:34typedef enum {35Alloc,36AllocForce,37Retire,38Reuse,39CSet,40EvacFailure,41Cleanup,42PostCompaction,43Commit,44Uncommit45} ActionType;4647typedef enum {48Unset,49Eden,50Survivor,51Old,52SingleHumongous,53StartsHumongous,54ContinuesHumongous55} RegionType;5657typedef enum {58StartGC,59EndGC,60StartFullGC,61EndFullGC62} PhaseType;6364private:65bool _active;6667static const char* action_name(ActionType action);68static const char* region_type_name(RegionType type);69static const char* phase_name(PhaseType phase);7071// Print an action event. This version is used in most scenarios and72// only prints the region's bottom. The parameters type and top are73// optional (the "not set" values are Unset and NULL).74static void print(ActionType action, RegionType type,75HeapRegion* hr, HeapWord* top);7677// Print an action event. This version prints both the region's78// bottom and end. Used for Commit / Uncommit events.79static void print(ActionType action, HeapWord* bottom, HeapWord* end);8081// Print a phase event.82static void print(PhaseType phase, size_t phase_num);8384public:85// In some places we iterate over a list in order to generate output86// for the list's elements. By exposing this we can avoid this87// iteration if the printer is not active.88const bool is_active() { return _active; }8990// Have to set this explicitly as we have to do this during the91// heap's initialize() method, not in the constructor.92void set_active(bool active) { _active = active; }9394// The methods below are convenient wrappers for the print() methods.9596void alloc(HeapRegion* hr, RegionType type, bool force = false) {97if (is_active()) {98print((!force) ? Alloc : AllocForce, type, hr, NULL);99}100}101102void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {103if (is_active()) {104print(Alloc, type, hr, top);105}106}107108void retire(HeapRegion* hr) {109if (is_active()) {110if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {111print(Retire, Unset, hr, hr->top());112}113}114}115116void reuse(HeapRegion* hr) {117if (is_active()) {118print(Reuse, Unset, hr, NULL);119}120}121122void cset(HeapRegion* hr) {123if (is_active()) {124print(CSet, Unset, hr, NULL);125}126}127128void evac_failure(HeapRegion* hr) {129if (is_active()) {130print(EvacFailure, Unset, hr, NULL);131}132}133134void cleanup(HeapRegion* hr) {135if (is_active()) {136print(Cleanup, Unset, hr, NULL);137}138}139140void post_compaction(HeapRegion* hr, RegionType type) {141if (is_active()) {142print(PostCompaction, type, hr, hr->top());143}144}145146void commit(HeapWord* bottom, HeapWord* end) {147if (is_active()) {148print(Commit, bottom, end);149}150}151152void uncommit(HeapWord* bottom, HeapWord* end) {153if (is_active()) {154print(Uncommit, bottom, end);155}156}157158void start_gc(bool full, size_t gc_num) {159if (is_active()) {160if (!full) {161print(StartGC, gc_num);162} else {163print(StartFullGC, gc_num);164}165}166}167168void end_gc(bool full, size_t gc_num) {169if (is_active()) {170if (!full) {171print(EndGC, gc_num);172} else {173print(EndFullGC, gc_num);174}175}176}177178G1HRPrinter() : _active(false) { }179};180181#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP182183184