hotspot/src/share/vm/gc/g1/g1Log.cpp
author tschatzl
Wed, 25 Nov 2015 14:43:29 +0100
changeset 34300 6075c1e0e913
parent 30764 fec48bf5a827
permissions -rw-r--r--
8136679: JFR event for adaptive IHOP Reviewed-by: tbenson, mgerdin, sangheki, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     1
/*
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     4
 *
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     8
 *
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    13
 * accompanied this code).
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    14
 *
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    18
 *
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    21
 * questions.
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    22
 *
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    23
 */
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    24
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30574
diff changeset
    26
#include "gc/g1/g1Log.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30574
diff changeset
    27
#include "gc/g1/g1_globals.hpp"
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    28
#include "runtime/globals_extension.hpp"
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    29
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    30
G1Log::LogLevel G1Log::_level = G1Log::LevelNone;
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    31
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    32
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    33
// Updates _level based on PrintGC and PrintGCDetails values (unless
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    34
// G1LogLevel is set explicitly)
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    35
// - PrintGC maps to "fine".
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    36
// - PrintGCDetails maps to "finer".
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    37
void G1Log::update_level() {
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    38
  if (FLAG_IS_DEFAULT(G1LogLevel)) {
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    39
    _level = LevelNone;
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    40
    if (PrintGCDetails) {
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    41
      _level = LevelFiner;
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    42
    } else if (PrintGC) {
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    43
      _level = LevelFine;
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    44
    }
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    45
  }
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    46
}
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    47
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    48
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    49
// If G1LogLevel has not been set up we will use the values of PrintGC
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    50
// and PrintGCDetails for the logging level.
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    51
void G1Log::init() {
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    52
  if (!FLAG_IS_DEFAULT(G1LogLevel)) {
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    53
    // PrintGC flags change won't have any affect, because G1LogLevel
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    54
    // is set explicitly
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    55
    if (G1LogLevel[0] == '\0' || strncmp("none", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    56
      _level = LevelNone;
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    57
    } else if (strncmp("fine", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    58
      _level = LevelFine;
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    59
    } else if (strncmp("finer", G1LogLevel, 5) == 0 && G1LogLevel[5] == '\0') {
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    60
      _level = LevelFiner;
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    61
    } else if (strncmp("finest", G1LogLevel, 6) == 0 && G1LogLevel[6] == '\0') {
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    62
      _level = LevelFinest;
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    63
    } else {
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    64
      warning("Unknown logging level '%s', should be one of 'fine', 'finer' or 'finest'.", G1LogLevel);
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    65
    }
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    66
  } else {
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    67
    update_level();
12378
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    68
  }
ed44b9ecfa2f 7160728: Introduce an extra logging level for G1 logging
brutisso
parents:
diff changeset
    69
}
30574
c38efb747c8a 8073476: G1 logging ignores changes to PrintGC* flags via MXBeans
dfazunen
parents: 12378
diff changeset
    70