hotspot/src/share/vm/gc_interface/gcCause.hpp
author ysuenaga
Wed, 04 Feb 2015 22:21:08 +0900
changeset 28836 d9c497544bf3
parent 27900 d24cd7a1ed38
child 28935 a0a29e3b7864
permissions -rw-r--r--
8068589: GCCause should distinguish jcmd GC.run from System.gc() Summary: GCCause which is caused by GC.run diagnostic command should be different from System.gc() . Reviewed-by: sla, tamao
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 18025
diff changeset
     2
 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_INTERFACE_GCCAUSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_INTERFACE_GCCAUSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// This class exposes implementation details of the various
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// collector(s), and we need to be very careful with it. If
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// use of this class grows, we should split it into public
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
    34
// and implementation-private "causes".
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class GCCause : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  enum Cause {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    /* public */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    _java_lang_system_gc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    _full_gc_alot,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    _scavenge_alot,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    _allocation_profiler,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    _jvmti_force_gc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    _gc_locker,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _heap_inspection,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    _heap_dump,
26183
bbe259d3c8bc 8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents: 22551
diff changeset
    49
    _wb_young_gc,
27900
d24cd7a1ed38 8065579: WB method to start G1 concurrent mark cycle should be introduced
tschatzl
parents: 27008
diff changeset
    50
    _wb_conc_mark,
27008
10d6c1e39d87 8059466: Force young GC to initiate marking cycle when stat update is requested
sjohanss
parents: 26845
diff changeset
    51
    _update_allocation_context_stats_inc,
10d6c1e39d87 8059466: Force young GC to initiate marking cycle when stat update is requested
sjohanss
parents: 26845
diff changeset
    52
    _update_allocation_context_stats_full,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    /* implementation independent, but reserved for GC use */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _no_gc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    _no_cause_specified,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    _allocation_failure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    /* implementation specific */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    _tenured_generation_full,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12630
diff changeset
    62
    _metadata_GC_threshold,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    _cms_generation_full,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    _cms_initial_mark,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    _cms_final_remark,
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15095
diff changeset
    67
    _cms_concurrent_mark,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _old_generation_expanded_on_last_scavenge,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    _old_generation_too_full_to_scavenge,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    _adaptive_size_policy,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
2344
f2e09ba7ceab 6543938: G1: remove the concept of popularity
apetrusenko
parents: 1374
diff changeset
    73
    _g1_inc_collection_pause,
11576
e0bef5ca4602 6976060: G1: humongous object allocations should initiate marking cycles when necessary
brutisso
parents: 8295
diff changeset
    74
    _g1_humongous_allocation,
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    75
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    _last_ditch_collection,
28836
d9c497544bf3 8068589: GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents: 27900
diff changeset
    77
d9c497544bf3 8068589: GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents: 27900
diff changeset
    78
    _dcmd_gc_run,
d9c497544bf3 8068589: GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents: 27900
diff changeset
    79
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    _last_gc_cause
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  inline static bool is_user_requested_gc(GCCause::Cause cause) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    return (cause == GCCause::_java_lang_system_gc ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
            cause == GCCause::_jvmti_force_gc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    87
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  inline static bool is_serviceability_requested_gc(GCCause::Cause
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
                                                             cause) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    return (cause == GCCause::_jvmti_force_gc ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
            cause == GCCause::_heap_inspection ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
            cause == GCCause::_heap_dump);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    94
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Return a string describing the GCCause.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  static const char* to_string(GCCause::Cause cause);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    98
12630
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
    99
// Helper class for doing logging that includes the GC Cause
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   100
// as a string.
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   101
class GCCauseString : StackObj {
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   102
 private:
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   103
   static const int _length = 128;
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   104
   char _buffer[_length];
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   105
   int _position;
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   106
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   107
 public:
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   108
   GCCauseString(const char* prefix, GCCause::Cause cause) {
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   109
     if (PrintGCCause) {
15095
8ce5dcdbeb26 8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents: 13728
diff changeset
   110
      _position = jio_snprintf(_buffer, _length, "%s (%s) ", prefix, GCCause::to_string(cause));
12630
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   111
     } else {
15095
8ce5dcdbeb26 8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents: 13728
diff changeset
   112
      _position = jio_snprintf(_buffer, _length, "%s ", prefix);
12630
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   113
     }
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   114
     assert(_position >= 0 && _position <= _length,
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   115
       err_msg("Need to increase the buffer size in GCCauseString? %d", _position));
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   116
   }
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   117
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   118
   GCCauseString& append(const char* str) {
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   119
     int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   120
     _position += res;
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   121
     assert(res >= 0 && _position <= _length,
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   122
       err_msg("Need to increase the buffer size in GCCauseString? %d", res));
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   123
     return *this;
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   124
   }
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   125
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   126
   operator const char*() {
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   127
     return _buffer;
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   128
   }
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   129
};
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 11576
diff changeset
   130
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   131
#endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP