tonyp@2975: /* drchase@6680: * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. tonyp@2975: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. tonyp@2975: * tonyp@2975: * This code is free software; you can redistribute it and/or modify it tonyp@2975: * under the terms of the GNU General Public License version 2 only, as tonyp@2975: * published by the Free Software Foundation. tonyp@2975: * tonyp@2975: * This code is distributed in the hope that it will be useful, but WITHOUT tonyp@2975: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or tonyp@2975: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License tonyp@2975: * version 2 for more details (a copy is included in the LICENSE file that tonyp@2975: * accompanied this code). tonyp@2975: * tonyp@2975: * You should have received a copy of the GNU General Public License version tonyp@2975: * 2 along with this work; if not, write to the Free Software Foundation, tonyp@2975: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. tonyp@2975: * tonyp@2975: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA tonyp@2975: * or visit www.oracle.com if you need additional information or have any tonyp@2975: * questions. tonyp@2975: * tonyp@2975: */ tonyp@2975: tonyp@2975: #include "precompiled.hpp" tonyp@2975: #include "gc_implementation/g1/g1HRPrinter.hpp" tonyp@2975: #include "gc_implementation/g1/heapRegion.hpp" tonyp@2975: #include "utilities/ostream.hpp" tonyp@2975: drchase@6680: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC drchase@6680: tonyp@2975: const char* G1HRPrinter::action_name(ActionType action) { tonyp@2975: switch(action) { tonyp@2975: case Alloc: return "ALLOC"; tonyp@2975: case AllocForce: return "ALLOC-FORCE"; tonyp@2975: case Retire: return "RETIRE"; tonyp@2975: case Reuse: return "REUSE"; tonyp@2975: case CSet: return "CSET"; tonyp@2975: case EvacFailure: return "EVAC-FAILURE"; tonyp@2975: case Cleanup: return "CLEANUP"; tonyp@2975: case PostCompaction: return "POST-COMPACTION"; tonyp@2975: case Commit: return "COMMIT"; tonyp@2975: case Uncommit: return "UNCOMMIT"; tonyp@2975: default: ShouldNotReachHere(); tonyp@2975: } tonyp@2975: // trying to keep the Windows compiler happy tonyp@2975: return NULL; tonyp@2975: } tonyp@2975: tonyp@2975: const char* G1HRPrinter::region_type_name(RegionType type) { tonyp@2975: switch (type) { tonyp@2975: case Unset: return NULL; tonyp@2975: case Eden: return "Eden"; tonyp@2975: case Survivor: return "Survivor"; tonyp@2975: case Old: return "Old"; tonyp@2975: case SingleHumongous: return "SingleH"; tonyp@2975: case StartsHumongous: return "StartsH"; tonyp@2975: case ContinuesHumongous: return "ContinuesH"; tonyp@2975: default: ShouldNotReachHere(); tonyp@2975: } tonyp@2975: // trying to keep the Windows compiler happy tonyp@2975: return NULL; tonyp@2975: } tonyp@2975: tonyp@2975: const char* G1HRPrinter::phase_name(PhaseType phase) { tonyp@2975: switch (phase) { tonyp@2975: case StartGC: return "StartGC"; tonyp@2975: case EndGC: return "EndGC"; tonyp@2975: case StartFullGC: return "StartFullGC"; tonyp@2975: case EndFullGC: return "EndFullGC"; tonyp@2975: default: ShouldNotReachHere(); tonyp@2975: } tonyp@2975: // trying to keep the Windows compiler happy tonyp@2975: return NULL; tonyp@2975: } tonyp@2975: tonyp@2975: #define G1HR_PREFIX " G1HR" tonyp@2975: tonyp@2975: void G1HRPrinter::print(ActionType action, RegionType type, tonyp@2975: HeapRegion* hr, HeapWord* top) { tonyp@2975: const char* action_str = action_name(action); tonyp@2975: const char* type_str = region_type_name(type); tonyp@2975: HeapWord* bottom = hr->bottom(); tonyp@2975: tonyp@2975: if (type_str != NULL) { tonyp@2975: if (top != NULL) { kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT " " PTR_FORMAT, tonyp@2975: action_str, type_str, bottom, top); tonyp@2975: } else { kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT, tonyp@2975: action_str, type_str, bottom); tonyp@2975: } tonyp@2975: } else { tonyp@2975: if (top != NULL) { kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT " " PTR_FORMAT, tonyp@2975: action_str, bottom, top); tonyp@2975: } else { kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT, tonyp@2975: action_str, bottom); tonyp@2975: } tonyp@2975: } tonyp@2975: } tonyp@2975: tonyp@2975: void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) { tonyp@2975: const char* action_str = action_name(action); tonyp@2975: kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " %s [" PTR_FORMAT "," PTR_FORMAT "]", tonyp@2975: action_str, bottom, end); tonyp@2975: } tonyp@2975: tonyp@2975: void G1HRPrinter::print(PhaseType phase, size_t phase_num) { tonyp@2975: const char* phase_str = phase_name(phase); kevinw@9327: gclog_or_tty->print_cr(G1HR_PREFIX " #%s " SIZE_FORMAT, phase_str, phase_num); tonyp@2975: }