hotspot/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp
author jwilhelm
Thu, 03 Oct 2013 21:36:29 +0200
changeset 20398 b206c580c45f
parent 10001 8aa7f885326e
child 24424 2658d7834c6e
permissions -rw-r--r--
8025852: Remove unnecessary setters in collector policy classes Summary: Use instance variables directly within the collector policy classes and remove unused setters. Reviewed-by: tschatzl, jcoomes
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
/*
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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
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";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    57
    default:                 ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    58
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    59
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    60
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    61
}
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
const char* G1HRPrinter::phase_name(PhaseType phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    64
  switch (phase) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    65
    case StartGC:     return "StartGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    66
    case EndGC:       return "EndGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    67
    case StartFullGC: return "StartFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    68
    case EndFullGC:   return "EndFullGC";
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    69
    default:          ShouldNotReachHere();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    70
  }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    71
  // trying to keep the Windows compiler happy
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    72
  return NULL;
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    73
}
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
#define G1HR_PREFIX     " G1HR"
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
void G1HRPrinter::print(ActionType action, RegionType type,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    78
                        HeapRegion* hr, HeapWord* top) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    79
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    80
  const char* type_str   = region_type_name(type);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    81
  HeapWord* bottom = hr->bottom();
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    82
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    83
  if (type_str != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    84
    if (top != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    85
      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
    86
                             action_str, type_str, bottom, top);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    87
    } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    88
      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
    89
                             action_str, type_str, bottom);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    90
    }
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    91
  } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    92
    if (top != NULL) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    93
      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
    94
                             action_str, bottom, top);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    95
    } else {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    96
      gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT,
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    97
                             action_str, bottom);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
    98
    }
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
void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   103
  const char* action_str = action_name(action);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   104
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   105
  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
   106
                         action_str, bottom, end);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   107
}
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
void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   110
  const char* phase_str = phase_name(phase);
8aa7f885326e 7049999: G1: Make the G1PrintHeapRegions output consistent and complete
tonyp
parents:
diff changeset
   111
  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
   112
}