1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,114 @@ 1.4 +/* 1.5 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "gc_implementation/g1/g1HRPrinter.hpp" 1.30 +#include "gc_implementation/g1/heapRegion.hpp" 1.31 +#include "utilities/ostream.hpp" 1.32 + 1.33 +PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 1.34 + 1.35 +const char* G1HRPrinter::action_name(ActionType action) { 1.36 + switch(action) { 1.37 + case Alloc: return "ALLOC"; 1.38 + case AllocForce: return "ALLOC-FORCE"; 1.39 + case Retire: return "RETIRE"; 1.40 + case Reuse: return "REUSE"; 1.41 + case CSet: return "CSET"; 1.42 + case EvacFailure: return "EVAC-FAILURE"; 1.43 + case Cleanup: return "CLEANUP"; 1.44 + case PostCompaction: return "POST-COMPACTION"; 1.45 + case Commit: return "COMMIT"; 1.46 + case Uncommit: return "UNCOMMIT"; 1.47 + default: ShouldNotReachHere(); 1.48 + } 1.49 + // trying to keep the Windows compiler happy 1.50 + return NULL; 1.51 +} 1.52 + 1.53 +const char* G1HRPrinter::region_type_name(RegionType type) { 1.54 + switch (type) { 1.55 + case Unset: return NULL; 1.56 + case Eden: return "Eden"; 1.57 + case Survivor: return "Survivor"; 1.58 + case Old: return "Old"; 1.59 + case SingleHumongous: return "SingleH"; 1.60 + case StartsHumongous: return "StartsH"; 1.61 + case ContinuesHumongous: return "ContinuesH"; 1.62 + default: ShouldNotReachHere(); 1.63 + } 1.64 + // trying to keep the Windows compiler happy 1.65 + return NULL; 1.66 +} 1.67 + 1.68 +const char* G1HRPrinter::phase_name(PhaseType phase) { 1.69 + switch (phase) { 1.70 + case StartGC: return "StartGC"; 1.71 + case EndGC: return "EndGC"; 1.72 + case StartFullGC: return "StartFullGC"; 1.73 + case EndFullGC: return "EndFullGC"; 1.74 + default: ShouldNotReachHere(); 1.75 + } 1.76 + // trying to keep the Windows compiler happy 1.77 + return NULL; 1.78 +} 1.79 + 1.80 +#define G1HR_PREFIX " G1HR" 1.81 + 1.82 +void G1HRPrinter::print(ActionType action, RegionType type, 1.83 + HeapRegion* hr, HeapWord* top) { 1.84 + const char* action_str = action_name(action); 1.85 + const char* type_str = region_type_name(type); 1.86 + HeapWord* bottom = hr->bottom(); 1.87 + 1.88 + if (type_str != NULL) { 1.89 + if (top != NULL) { 1.90 + gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT, 1.91 + action_str, type_str, bottom, top); 1.92 + } else { 1.93 + gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT, 1.94 + action_str, type_str, bottom); 1.95 + } 1.96 + } else { 1.97 + if (top != NULL) { 1.98 + gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT, 1.99 + action_str, bottom, top); 1.100 + } else { 1.101 + gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT, 1.102 + action_str, bottom); 1.103 + } 1.104 + } 1.105 +} 1.106 + 1.107 +void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) { 1.108 + const char* action_str = action_name(action); 1.109 + 1.110 + gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]", 1.111 + action_str, bottom, end); 1.112 +} 1.113 + 1.114 +void G1HRPrinter::print(PhaseType phase, size_t phase_num) { 1.115 + const char* phase_str = phase_name(phase); 1.116 + gclog_or_tty->print_cr(G1HR_PREFIX" #%s "SIZE_FORMAT, phase_str, phase_num); 1.117 +}