author | dholmes |
Fri, 04 Dec 2015 04:06:37 -0500 | |
changeset 34633 | 2a6c7c7b30a7 |
parent 33105 | 294e48b4f704 |
child 35061 | be6025ebffea |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_SHARED_GCCAUSE_HPP |
26 |
#define SHARE_VM_GC_SHARED_GCCAUSE_HPP |
|
7397 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
||
1 | 30 |
// |
31 |
// This class exposes implementation details of the various |
|
32 |
// collector(s), and we need to be very careful with it. If |
|
33 |
// use of this class grows, we should split it into public |
|
22551 | 34 |
// and implementation-private "causes". |
1 | 35 |
// |
36 |
||
37 |
class GCCause : public AllStatic { |
|
38 |
public: |
|
39 |
enum Cause { |
|
40 |
/* public */ |
|
41 |
_java_lang_system_gc, |
|
42 |
_full_gc_alot, |
|
43 |
_scavenge_alot, |
|
44 |
_allocation_profiler, |
|
45 |
_jvmti_force_gc, |
|
46 |
_gc_locker, |
|
47 |
_heap_inspection, |
|
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 | 53 |
|
54 |
/* implementation independent, but reserved for GC use */ |
|
55 |
_no_gc, |
|
56 |
_no_cause_specified, |
|
57 |
_allocation_failure, |
|
58 |
||
59 |
/* implementation specific */ |
|
60 |
||
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 | 63 |
|
64 |
_cms_generation_full, |
|
65 |
_cms_initial_mark, |
|
66 |
_cms_final_remark, |
|
18025 | 67 |
_cms_concurrent_mark, |
1 | 68 |
|
69 |
_old_generation_expanded_on_last_scavenge, |
|
70 |
_old_generation_too_full_to_scavenge, |
|
71 |
_adaptive_size_policy, |
|
72 |
||
2344 | 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 | 75 |
|
1 | 76 |
_last_ditch_collection, |
31032
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30764
diff
changeset
|
77 |
|
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30764
diff
changeset
|
78 |
_dcmd_gc_run, |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30764
diff
changeset
|
79 |
|
1 | 80 |
_last_gc_cause |
81 |
}; |
|
82 |
||
83 |
inline static bool is_user_requested_gc(GCCause::Cause cause) { |
|
84 |
return (cause == GCCause::_java_lang_system_gc || |
|
31032
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30764
diff
changeset
|
85 |
cause == GCCause::_dcmd_gc_run); |
1 | 86 |
} |
1374 | 87 |
|
1 | 88 |
inline static bool is_serviceability_requested_gc(GCCause::Cause |
89 |
cause) { |
|
90 |
return (cause == GCCause::_jvmti_force_gc || |
|
91 |
cause == GCCause::_heap_inspection || |
|
92 |
cause == GCCause::_heap_dump); |
|
93 |
} |
|
1374 | 94 |
|
31634
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
95 |
// Causes for collection of the tenured gernation |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
96 |
inline static bool is_tenured_allocation_failure_gc(GCCause::Cause cause) { |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
97 |
assert(cause != GCCause::_old_generation_too_full_to_scavenge && |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31634
diff
changeset
|
98 |
cause != GCCause::_old_generation_expanded_on_last_scavenge, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31634
diff
changeset
|
99 |
"This GCCause may be correct but is not expected yet: %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31634
diff
changeset
|
100 |
to_string(cause)); |
31634
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
101 |
// _tenured_generation_full or _cms_generation_full for full tenured generations |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
102 |
// _adaptive_size_policy for a full collection after a young GC |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
103 |
// _allocation_failure is the generic cause a collection which could result |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
104 |
// in the collection of the tenured generation if there is not enough space |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
105 |
// in the tenured generation to support a young GC. |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
106 |
// _last_ditch_collection is a collection done to include SoftReferences. |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
107 |
return (cause == GCCause::_tenured_generation_full || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
108 |
cause == GCCause::_cms_generation_full || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
109 |
cause == GCCause::_adaptive_size_policy || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
110 |
cause == GCCause::_allocation_failure || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
111 |
cause == GCCause::_last_ditch_collection); |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
112 |
} |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
113 |
|
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
114 |
// Causes for collection of the young generation |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
115 |
inline static bool is_allocation_failure_gc(GCCause::Cause cause) { |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
116 |
// _allocation_failure is the generic cause a collection for allocation failure |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
117 |
// _adaptive_size_policy is for a collecton done before a full GC |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
118 |
// _last_ditch_collection is a collection done to include SoftReferences. |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
119 |
return (cause == GCCause::_allocation_failure || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
120 |
cause == GCCause::_adaptive_size_policy || |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
121 |
cause == GCCause::_last_ditch_collection); |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
122 |
} |
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31032
diff
changeset
|
123 |
|
1 | 124 |
// Return a string describing the GCCause. |
125 |
static const char* to_string(GCCause::Cause cause); |
|
126 |
}; |
|
7397 | 127 |
|
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
128 |
// 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
|
129 |
// as a string. |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
130 |
class GCCauseString : StackObj { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
131 |
private: |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
132 |
static const int _length = 128; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
133 |
char _buffer[_length]; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
134 |
int _position; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
135 |
|
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
136 |
public: |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
137 |
GCCauseString(const char* prefix, GCCause::Cause cause) { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
138 |
if (PrintGCCause) { |
15095
8ce5dcdbeb26
8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents:
13728
diff
changeset
|
139 |
_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
|
140 |
} else { |
15095
8ce5dcdbeb26
8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents:
13728
diff
changeset
|
141 |
_position = jio_snprintf(_buffer, _length, "%s ", prefix); |
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
142 |
} |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
143 |
assert(_position >= 0 && _position <= _length, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31634
diff
changeset
|
144 |
"Need to increase the buffer size in GCCauseString? %d", _position); |
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
145 |
} |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
146 |
|
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
147 |
GCCauseString& append(const char* str) { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
148 |
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
|
149 |
_position += res; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
150 |
assert(res >= 0 && _position <= _length, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31634
diff
changeset
|
151 |
"Need to increase the buffer size in GCCauseString? %d", res); |
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
152 |
return *this; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
153 |
} |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
154 |
|
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
155 |
operator const char*() { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
156 |
return _buffer; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
157 |
} |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
158 |
}; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
11576
diff
changeset
|
159 |
|
30764 | 160 |
#endif // SHARE_VM_GC_SHARED_GCCAUSE_HPP |