hotspot/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp
author pliden
Tue, 03 Jun 2014 10:37:46 +0200
changeset 24844 d1345c68cea9
parent 24424 2658d7834c6e
child 29796 7a04e5c250d1
permissions -rw-r--r--
8040807: G1: Enable G1CollectedHeap::stop() Reviewed-by: brutisso, jmasa, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10001
diff changeset
     2
 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     4
 *
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     8
 *
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    13
 * accompanied this code).
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    14
 *
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    18
 *
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    21
 * questions.
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    22
 *
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    23
 */
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    24
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    25
#include "precompiled.hpp"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    26
#include "gc_implementation/g1/g1HRPrinter.hpp"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    27
#include "gc_implementation/g1/heapRegion.hpp"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    28
#include "utilities/ostream.hpp"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    29
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10001
diff changeset
    30
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10001
diff changeset
    31
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    32
const char* G1HRPrinter::action_name(ActionType action) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    33
  switch(action) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    34
    case Alloc:          return "ALLOC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    35
    case AllocForce:     return "ALLOC-FORCE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    36
    case Retire:         return "RETIRE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    37
    case Reuse:          return "REUSE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    38
    case CSet:           return "CSET";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    39
    case EvacFailure:    return "EVAC-FAILURE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    40
    case Cleanup:        return "CLEANUP";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    41
    case PostCompaction: return "POST-COMPACTION";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    42
    case Commit:         return "COMMIT";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    43
    case Uncommit:       return "UNCOMMIT";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    44
    default:             ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    45
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    46
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    47
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    48
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    49
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    50
const char* G1HRPrinter::region_type_name(RegionType type) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    51
  switch (type) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    52
    case Unset:              return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    53
    case Eden:               return "Eden";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    54
    case Survivor:           return "Survivor";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    55
    case Old:                return "Old";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    56
    case SingleHumongous:    return "SingleH";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    57
    case StartsHumongous:    return "StartsH";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    58
    case ContinuesHumongous: return "ContinuesH";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    59
    default:                 ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    60
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    61
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    62
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    63
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    64
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    65
const char* G1HRPrinter::phase_name(PhaseType phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    66
  switch (phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    67
    case StartGC:     return "StartGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    68
    case EndGC:       return "EndGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    69
    case StartFullGC: return "StartFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    70
    case EndFullGC:   return "EndFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    71
    default:          ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    72
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    73
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    74
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    75
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    76
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    77
#define G1HR_PREFIX     " G1HR"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    78
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    79
void G1HRPrinter::print(ActionType action, RegionType type,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    80
                        HeapRegion* hr, HeapWord* top) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    81
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    82
  const char* type_str   = region_type_name(type);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    83
  HeapWord* bottom = hr->bottom();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    84
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    85
  if (type_str != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    86
    if (top != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    87
      gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    88
                             action_str, type_str, bottom, top);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    89
    } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    90
      gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    91
                             action_str, type_str, bottom);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    92
    }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    93
  } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    94
    if (top != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    95
      gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    96
                             action_str, bottom, top);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    97
    } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    98
      gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    99
                             action_str, bottom);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   100
    }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   101
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   102
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   103
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   104
void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   105
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   106
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   107
  gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]",
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   108
                         action_str, bottom, end);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   109
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   110
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   111
void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   112
  const char* phase_str = phase_name(phase);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   113
  gclog_or_tty->print_cr(G1HR_PREFIX" #%s "SIZE_FORMAT, phase_str, phase_num);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   114
}