src/share/vm/gc_implementation/g1/g1HRPrinter.cpp

changeset 2975
5f6f2615433a
child 6680
78bbf4d43a14
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp	Fri Jun 24 12:38:49 2011 -0400
     1.3 @@ -0,0 +1,112 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, 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 +const char* G1HRPrinter::action_name(ActionType action) {
    1.34 +  switch(action) {
    1.35 +    case Alloc:          return "ALLOC";
    1.36 +    case AllocForce:     return "ALLOC-FORCE";
    1.37 +    case Retire:         return "RETIRE";
    1.38 +    case Reuse:          return "REUSE";
    1.39 +    case CSet:           return "CSET";
    1.40 +    case EvacFailure:    return "EVAC-FAILURE";
    1.41 +    case Cleanup:        return "CLEANUP";
    1.42 +    case PostCompaction: return "POST-COMPACTION";
    1.43 +    case Commit:         return "COMMIT";
    1.44 +    case Uncommit:       return "UNCOMMIT";
    1.45 +    default:             ShouldNotReachHere();
    1.46 +  }
    1.47 +  // trying to keep the Windows compiler happy
    1.48 +  return NULL;
    1.49 +}
    1.50 +
    1.51 +const char* G1HRPrinter::region_type_name(RegionType type) {
    1.52 +  switch (type) {
    1.53 +    case Unset:              return NULL;
    1.54 +    case Eden:               return "Eden";
    1.55 +    case Survivor:           return "Survivor";
    1.56 +    case Old:                return "Old";
    1.57 +    case SingleHumongous:    return "SingleH";
    1.58 +    case StartsHumongous:    return "StartsH";
    1.59 +    case ContinuesHumongous: return "ContinuesH";
    1.60 +    default:                 ShouldNotReachHere();
    1.61 +  }
    1.62 +  // trying to keep the Windows compiler happy
    1.63 +  return NULL;
    1.64 +}
    1.65 +
    1.66 +const char* G1HRPrinter::phase_name(PhaseType phase) {
    1.67 +  switch (phase) {
    1.68 +    case StartGC:     return "StartGC";
    1.69 +    case EndGC:       return "EndGC";
    1.70 +    case StartFullGC: return "StartFullGC";
    1.71 +    case EndFullGC:   return "EndFullGC";
    1.72 +    default:          ShouldNotReachHere();
    1.73 +  }
    1.74 +  // trying to keep the Windows compiler happy
    1.75 +  return NULL;
    1.76 +}
    1.77 +
    1.78 +#define G1HR_PREFIX     " G1HR"
    1.79 +
    1.80 +void G1HRPrinter::print(ActionType action, RegionType type,
    1.81 +                        HeapRegion* hr, HeapWord* top) {
    1.82 +  const char* action_str = action_name(action);
    1.83 +  const char* type_str   = region_type_name(type);
    1.84 +  HeapWord* bottom = hr->bottom();
    1.85 +
    1.86 +  if (type_str != NULL) {
    1.87 +    if (top != NULL) {
    1.88 +      gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT,
    1.89 +                             action_str, type_str, bottom, top);
    1.90 +    } else {
    1.91 +      gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT,
    1.92 +                             action_str, type_str, bottom);
    1.93 +    }
    1.94 +  } else {
    1.95 +    if (top != NULL) {
    1.96 +      gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT,
    1.97 +                             action_str, bottom, top);
    1.98 +    } else {
    1.99 +      gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT,
   1.100 +                             action_str, bottom);
   1.101 +    }
   1.102 +  }
   1.103 +}
   1.104 +
   1.105 +void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
   1.106 +  const char* action_str = action_name(action);
   1.107 +
   1.108 +  gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]",
   1.109 +                         action_str, bottom, end);
   1.110 +}
   1.111 +
   1.112 +void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
   1.113 +  const char* phase_str = phase_name(phase);
   1.114 +  gclog_or_tty->print_cr(G1HR_PREFIX" #%s "SIZE_FORMAT, phase_str, phase_num);
   1.115 +}

mercurial