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#include "precompiled.hpp"
2603N/A#include "gc_implementation/g1/g1HRPrinter.hpp"
2603N/A#include "gc_implementation/g1/heapRegion.hpp"
2603N/A#include "utilities/ostream.hpp"
2603N/A
2603N/Aconst char* G1HRPrinter::action_name(ActionType action) {
2603N/A switch(action) {
2603N/A case Alloc: return "ALLOC";
2603N/A case AllocForce: return "ALLOC-FORCE";
2603N/A case Retire: return "RETIRE";
2603N/A case Reuse: return "REUSE";
2603N/A case CSet: return "CSET";
2603N/A case EvacFailure: return "EVAC-FAILURE";
2603N/A case Cleanup: return "CLEANUP";
2603N/A case PostCompaction: return "POST-COMPACTION";
2603N/A case Commit: return "COMMIT";
2603N/A case Uncommit: return "UNCOMMIT";
2603N/A default: ShouldNotReachHere();
2603N/A }
2603N/A // trying to keep the Windows compiler happy
2603N/A return NULL;
2603N/A}
2603N/A
2603N/Aconst char* G1HRPrinter::region_type_name(RegionType type) {
2603N/A switch (type) {
2603N/A case Unset: return NULL;
2603N/A case Eden: return "Eden";
2603N/A case Survivor: return "Survivor";
2603N/A case Old: return "Old";
2603N/A case SingleHumongous: return "SingleH";
2603N/A case StartsHumongous: return "StartsH";
2603N/A case ContinuesHumongous: return "ContinuesH";
2603N/A default: ShouldNotReachHere();
2603N/A }
2603N/A // trying to keep the Windows compiler happy
2603N/A return NULL;
2603N/A}
2603N/A
2603N/Aconst char* G1HRPrinter::phase_name(PhaseType phase) {
2603N/A switch (phase) {
2603N/A case StartGC: return "StartGC";
2603N/A case EndGC: return "EndGC";
2603N/A case StartFullGC: return "StartFullGC";
2603N/A case EndFullGC: return "EndFullGC";
2603N/A default: ShouldNotReachHere();
2603N/A }
2603N/A // trying to keep the Windows compiler happy
2603N/A return NULL;
2603N/A}
2603N/A
2603N/A#define G1HR_PREFIX " G1HR"
2603N/A
2603N/Avoid G1HRPrinter::print(ActionType action, RegionType type,
2603N/A HeapRegion* hr, HeapWord* top) {
2603N/A const char* action_str = action_name(action);
2603N/A const char* type_str = region_type_name(type);
2603N/A HeapWord* bottom = hr->bottom();
2603N/A
2603N/A if (type_str != NULL) {
2603N/A if (top != NULL) {
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT,
2603N/A action_str, type_str, bottom, top);
2603N/A } else {
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT,
2603N/A action_str, type_str, bottom);
2603N/A }
2603N/A } else {
2603N/A if (top != NULL) {
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT,
2603N/A action_str, bottom, top);
2603N/A } else {
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT,
2603N/A action_str, bottom);
2603N/A }
2603N/A }
2603N/A}
2603N/A
2603N/Avoid G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
2603N/A const char* action_str = action_name(action);
2603N/A
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]",
2603N/A action_str, bottom, end);
2603N/A}
2603N/A
2603N/Avoid G1HRPrinter::print(PhaseType phase, size_t phase_num) {
2603N/A const char* phase_str = phase_name(phase);
2603N/A gclog_or_tty->print_cr(G1HR_PREFIX" #%s "SIZE_FORMAT, phase_str, phase_num);
2603N/A}