hotspot/src/share/vm/gc/g1/g1HRPrinter.cpp
author tschatzl
Thu, 06 Aug 2015 15:49:50 +0200
changeset 32185 49a57ff2c3cb
parent 31592 43f48e165466
child 33786 ac8da6513351
permissions -rw-r--r--
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp Summary: Fix naming of G1ParGCAllocator, decrease dependencies between G1CollectedHeap, G1Allocator and G1AllocRegion, additional documentation. Reviewed-by: mgerdin, jmasa, kbarrett
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
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
     2
 * Copyright (c) 2011, 2015, 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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
    26
#include "gc/g1/g1HRPrinter.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
    27
#include "gc/g1/heapRegion.hpp"
10001
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
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    30
const char* G1HRPrinter::action_name(ActionType action) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    31
  switch(action) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    32
    case Alloc:          return "ALLOC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    33
    case AllocForce:     return "ALLOC-FORCE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    34
    case Retire:         return "RETIRE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    35
    case Reuse:          return "REUSE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    36
    case CSet:           return "CSET";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    37
    case EvacFailure:    return "EVAC-FAILURE";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    38
    case Cleanup:        return "CLEANUP";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    39
    case PostCompaction: return "POST-COMPACTION";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    40
    case Commit:         return "COMMIT";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    41
    case Uncommit:       return "UNCOMMIT";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    42
    default:             ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    43
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    44
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    45
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    46
}
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    47
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    48
const char* G1HRPrinter::region_type_name(RegionType type) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    49
  switch (type) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    50
    case Unset:              return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    51
    case Eden:               return "Eden";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    52
    case Survivor:           return "Survivor";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    53
    case Old:                return "Old";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    54
    case SingleHumongous:    return "SingleH";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    55
    case StartsHumongous:    return "StartsH";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    56
    case ContinuesHumongous: return "ContinuesH";
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    57
    case Archive:            return "Archive";
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    58
    default:                 ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    59
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    60
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    61
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    62
}
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
const char* G1HRPrinter::phase_name(PhaseType phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    65
  switch (phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    66
    case StartGC:     return "StartGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    67
    case EndGC:       return "EndGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    68
    case StartFullGC: return "StartFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    69
    case EndFullGC:   return "EndFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    70
    default:          ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    71
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    72
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    73
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    74
}
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
#define G1HR_PREFIX     " G1HR"
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    77
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    78
void G1HRPrinter::print(ActionType action, RegionType type,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    79
                        HeapRegion* hr, HeapWord* top) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    80
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    81
  const char* type_str   = region_type_name(type);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    82
  HeapWord* bottom = hr->bottom();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    83
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    84
  if (type_str != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    85
    if (top != NULL) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
    86
      gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT " " PTR_FORMAT,
29796
7a04e5c250d1 8076054: g1: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
    87
                             action_str, type_str, p2i(bottom), p2i(top));
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    88
    } else {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
    89
      gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT,
29796
7a04e5c250d1 8076054: g1: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
    90
                             action_str, type_str, p2i(bottom));
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    91
    }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    92
  } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    93
    if (top != NULL) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
    94
      gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT " " PTR_FORMAT,
29796
7a04e5c250d1 8076054: g1: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
    95
                             action_str, p2i(bottom), p2i(top));
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    96
    } else {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
    97
      gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT,
29796
7a04e5c250d1 8076054: g1: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
    98
                             action_str, p2i(bottom));
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    99
    }
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
void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   104
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   105
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
   106
  gclog_or_tty->print_cr(G1HR_PREFIX " %s [" PTR_FORMAT "," PTR_FORMAT "]",
29796
7a04e5c250d1 8076054: g1: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
   107
                         action_str, p2i(bottom), p2i(end));
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   108
}
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
void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   111
  const char* phase_str = phase_name(phase);
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
   112
  gclog_or_tty->print_cr(G1HR_PREFIX " #%s " SIZE_FORMAT, phase_str, phase_num);
10001
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   113
}