2603N/A/*
2603N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2603N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2603N/A *
2603N/A * This code is free software; you can redistribute it and/or modify it
2603N/A * under the terms of the GNU General Public License version 2 only, as
2603N/A * published by the Free Software Foundation.
2603N/A *
2603N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2603N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2603N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2603N/A * version 2 for more details (a copy is included in the LICENSE file that
2603N/A * accompanied this code).
2603N/A *
2603N/A * You should have received a copy of the GNU General Public License version
2603N/A * 2 along with this work; if not, write to the Free Software Foundation,
2603N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2603N/A *
2603N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2603N/A * or visit www.oracle.com if you need additional information or have any
2603N/A * questions.
2603N/A *
2603N/A */
2603N/A
2603N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
2603N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
2603N/A
2603N/A#include "memory/allocation.hpp"
2603N/A#include "gc_implementation/g1/heapRegion.hpp"
2603N/A
2603N/A#define SKIP_RETIRED_FULL_REGIONS 1
2603N/A
2603N/Aclass G1HRPrinter VALUE_OBJ_CLASS_SPEC {
2603N/Apublic:
2603N/A typedef enum {
2603N/A Alloc,
2603N/A AllocForce,
2603N/A Retire,
2603N/A Reuse,
2603N/A CSet,
2603N/A EvacFailure,
2603N/A Cleanup,
2603N/A PostCompaction,
2603N/A Commit,
2603N/A Uncommit
2603N/A } ActionType;
2603N/A
2603N/A typedef enum {
2603N/A Unset,
2603N/A Eden,
2603N/A Survivor,
2603N/A Old,
2603N/A SingleHumongous,
2603N/A StartsHumongous,
2603N/A ContinuesHumongous
2603N/A } RegionType;
2603N/A
2603N/A typedef enum {
2603N/A StartGC,
2603N/A EndGC,
2603N/A StartFullGC,
2603N/A EndFullGC
2603N/A } PhaseType;
2603N/A
2603N/Aprivate:
2603N/A bool _active;
2603N/A
2603N/A static const char* action_name(ActionType action);
2603N/A static const char* region_type_name(RegionType type);
2603N/A static const char* phase_name(PhaseType phase);
2603N/A
2603N/A // Print an action event. This version is used in most scenarios and
2603N/A // only prints the region's bottom. The parameters type and top are
2603N/A // optional (the "not set" values are Unset and NULL).
2603N/A static void print(ActionType action, RegionType type,
2603N/A HeapRegion* hr, HeapWord* top);
2603N/A
2603N/A // Print an action event. This version prints both the region's
2603N/A // bottom and end. Used for Commit / Uncommit events.
2603N/A static void print(ActionType action, HeapWord* bottom, HeapWord* end);
2603N/A
2603N/A // Print a phase event.
2603N/A static void print(PhaseType phase, size_t phase_num);
2603N/A
2603N/Apublic:
2603N/A // In some places we iterate over a list in order to generate output
2603N/A // for the list's elements. By exposing this we can avoid this
2603N/A // iteration if the printer is not active.
2603N/A const bool is_active() { return _active; }
2603N/A
2603N/A // Have to set this explicitly as we have to do this during the
2603N/A // heap's initialize() method, not in the constructor.
2603N/A void set_active(bool active) { _active = active; }
2603N/A
2603N/A // The methods below are convenient wrappers for the print() methods.
2603N/A
2603N/A void alloc(HeapRegion* hr, RegionType type, bool force = false) {
2603N/A if (is_active()) {
2603N/A print((!force) ? Alloc : AllocForce, type, hr, NULL);
2603N/A }
2603N/A }
2603N/A
2603N/A void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
2603N/A if (is_active()) {
2603N/A print(Alloc, type, hr, top);
2603N/A }
2603N/A }
2603N/A
2603N/A void retire(HeapRegion* hr) {
2603N/A if (is_active()) {
2603N/A if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
2603N/A print(Retire, Unset, hr, hr->top());
2603N/A }
2603N/A }
2603N/A }
2603N/A
2603N/A void reuse(HeapRegion* hr) {
2603N/A if (is_active()) {
2603N/A print(Reuse, Unset, hr, NULL);
2603N/A }
2603N/A }
2603N/A
2603N/A void cset(HeapRegion* hr) {
2603N/A if (is_active()) {
2603N/A print(CSet, Unset, hr, NULL);
2603N/A }
2603N/A }
2603N/A
2603N/A void evac_failure(HeapRegion* hr) {
2603N/A if (is_active()) {
2603N/A print(EvacFailure, Unset, hr, NULL);
2603N/A }
2603N/A }
2603N/A
2603N/A void cleanup(HeapRegion* hr) {
2603N/A if (is_active()) {
2603N/A print(Cleanup, Unset, hr, NULL);
2603N/A }
2603N/A }
2603N/A
2603N/A void post_compaction(HeapRegion* hr, RegionType type) {
2603N/A if (is_active()) {
2603N/A print(PostCompaction, type, hr, hr->top());
2603N/A }
2603N/A }
2603N/A
2603N/A void commit(HeapWord* bottom, HeapWord* end) {
2603N/A if (is_active()) {
2603N/A print(Commit, bottom, end);
2603N/A }
2603N/A }
2603N/A
2603N/A void uncommit(HeapWord* bottom, HeapWord* end) {
2603N/A if (is_active()) {
2603N/A print(Uncommit, bottom, end);
2603N/A }
2603N/A }
2603N/A
2603N/A void start_gc(bool full, size_t gc_num) {
2603N/A if (is_active()) {
2603N/A if (!full) {
2603N/A print(StartGC, gc_num);
2603N/A } else {
2603N/A print(StartFullGC, gc_num);
2603N/A }
2603N/A }
2603N/A }
2603N/A
2603N/A void end_gc(bool full, size_t gc_num) {
2603N/A if (is_active()) {
2603N/A if (!full) {
2603N/A print(EndGC, gc_num);
2603N/A } else {
2603N/A print(EndFullGC, gc_num);
2603N/A }
2603N/A }
2603N/A }
2603N/A
2603N/A G1HRPrinter() : _active(false) { }
2603N/A};
2603N/A
2603N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP