author | mgronlun |
Mon, 28 Oct 2019 18:43:04 +0100 | |
branch | JEP-349-branch |
changeset 58823 | 6a21dba79b81 |
parent 58259 | b6efcf2217f1 |
parent 58786 | 7909763ad193 |
child 58826 | fb51e2ae730e |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51444
diff
changeset
|
26 |
#include "classfile/classLoaderDataGraph.hpp" |
50113 | 27 |
#include "classfile/javaClasses.inline.hpp" |
28 |
#include "classfile/moduleEntry.hpp" |
|
29 |
#include "classfile/packageEntry.hpp" |
|
30 |
#include "classfile/symbolTable.hpp" |
|
31 |
#include "jfr/jfr.hpp" |
|
32 |
#include "jfr/jni/jfrGetAllEventClasses.hpp" |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
33 |
#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp" |
50113 | 34 |
#include "jfr/recorder/checkpoint/types/jfrTypeSet.hpp" |
35 |
#include "jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp" |
|
36 |
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp" |
|
37 |
#include "jfr/utilities/jfrHashtable.hpp" |
|
38 |
#include "jfr/utilities/jfrTypes.hpp" |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
39 |
#include "jfr/writers/jfrTypeWriterHost.hpp" |
50113 | 40 |
#include "memory/iterator.hpp" |
41 |
#include "memory/resourceArea.hpp" |
|
42 |
#include "oops/instanceKlass.hpp" |
|
43 |
#include "oops/objArrayKlass.hpp" |
|
44 |
#include "oops/oop.inline.hpp" |
|
45 |
#include "utilities/accessFlags.hpp" |
|
58823 | 46 |
#include "utilities/bitMap.inline.hpp" |
50113 | 47 |
|
48 |
typedef const Klass* KlassPtr; |
|
49 |
typedef const PackageEntry* PkgPtr; |
|
50 |
typedef const ModuleEntry* ModPtr; |
|
51 |
typedef const ClassLoaderData* CldPtr; |
|
52 |
typedef const Method* MethodPtr; |
|
53 |
typedef const Symbol* SymbolPtr; |
|
54 |
typedef const JfrSymbolId::SymbolEntry* SymbolEntryPtr; |
|
55 |
typedef const JfrSymbolId::CStringEntry* CStringEntryPtr; |
|
56 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
57 |
static JfrCheckpointWriter* _writer = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
58 |
static JfrCheckpointWriter* _leakp_writer = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
59 |
static JfrArtifactSet* _artifacts = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
60 |
static JfrArtifactClosure* _subsystem_callback = NULL; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
61 |
static bool _class_unload = false; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
62 |
static bool _flushpoint = false; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
63 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
64 |
// incremented on each rotation |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
65 |
static u8 checkpoint_id = 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
66 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
67 |
// creates a unique id by combining a checkpoint relative symbol id (2^24) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
68 |
// with the current checkpoint id (2^40) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
69 |
#define CREATE_SYMBOL_ID(sym_id) (((u8)((checkpoint_id << 24) | sym_id))) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
70 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
71 |
static traceid create_symbol_id(traceid artifact_id) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
72 |
return artifact_id != 0 ? CREATE_SYMBOL_ID(artifact_id) : 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
73 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
74 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
75 |
static bool current_epoch() { |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
76 |
return _class_unload || _flushpoint; |
50113 | 77 |
} |
78 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
79 |
static bool previous_epoch() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
80 |
return !current_epoch(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
81 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
82 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
83 |
static bool is_complete() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
84 |
return !_artifacts->has_klass_entries() && current_epoch(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
85 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
86 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
87 |
static traceid mark_symbol(KlassPtr klass, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
88 |
return klass != NULL ? create_symbol_id(_artifacts->mark(klass, leakp)) : 0; |
50113 | 89 |
} |
90 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
91 |
static traceid mark_symbol(Symbol* symbol, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
92 |
return symbol != NULL ? create_symbol_id(_artifacts->mark(symbol, leakp)) : 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
93 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
94 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
95 |
static traceid get_bootstrap_name(bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
96 |
return create_symbol_id(_artifacts->bootstrap_name(leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
97 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
98 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
99 |
template <typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
100 |
static traceid artifact_id(const T* ptr) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
101 |
assert(ptr != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
102 |
return TRACE_ID(ptr); |
50113 | 103 |
} |
104 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
105 |
static traceid package_id(KlassPtr klass, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
106 |
assert(klass != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
107 |
PkgPtr pkg_entry = klass->package(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
108 |
if (pkg_entry == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
109 |
return 0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
110 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
111 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
112 |
SET_LEAKP(pkg_entry); |
50113 | 113 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
114 |
// package implicitly tagged already |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
115 |
return artifact_id(pkg_entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
116 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
117 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
118 |
static traceid module_id(PkgPtr pkg, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
119 |
assert(pkg != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
120 |
ModPtr module_entry = pkg->module(); |
58823 | 121 |
if (module_entry == NULL) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
122 |
return 0; |
50113 | 123 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
124 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
125 |
SET_LEAKP(module_entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
126 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
127 |
SET_TRANSIENT(module_entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
128 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
129 |
return artifact_id(module_entry); |
50113 | 130 |
} |
131 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
132 |
static traceid method_id(KlassPtr klass, MethodPtr method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
133 |
assert(klass != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
134 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
135 |
return METHOD_ID(klass, method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
136 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
137 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
138 |
static traceid cld_id(CldPtr cld, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
139 |
assert(cld != NULL, "invariant"); |
58823 | 140 |
assert(!cld->is_unsafe_anonymous(), "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
141 |
if (leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
142 |
SET_LEAKP(cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
143 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
144 |
SET_TRANSIENT(cld); |
50113 | 145 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
146 |
return artifact_id(cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
147 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
148 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
149 |
template <typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
150 |
static s4 get_flags(const T* ptr) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
151 |
assert(ptr != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
152 |
return ptr->access_flags().get_flags(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
153 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
154 |
|
58823 | 155 |
static bool is_unsafe_anonymous(const Klass* klass) { |
156 |
assert(klass != NULL, "invariant"); |
|
157 |
return klass->is_instance_klass() && ((const InstanceKlass*)klass)->is_unsafe_anonymous(); |
|
158 |
} |
|
159 |
||
160 |
static ClassLoaderData* get_cld(const Klass* klass) { |
|
161 |
assert(klass != NULL, "invariant"); |
|
162 |
return is_unsafe_anonymous(klass) ? |
|
163 |
InstanceKlass::cast(klass)->unsafe_anonymous_host()->class_loader_data() : klass->class_loader_data(); |
|
164 |
} |
|
165 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
166 |
template <typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
167 |
static void set_serialized(const T* ptr) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
168 |
assert(ptr != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
169 |
SET_SERIALIZED(ptr); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
170 |
assert(IS_SERIALIZED(ptr), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
171 |
} |
50113 | 172 |
|
173 |
/* |
|
174 |
* In C++03, functions used as template parameters must have external linkage; |
|
175 |
* this restriction was removed in C++11. Change back to "static" and |
|
176 |
* rename functions when C++11 becomes available. |
|
177 |
* |
|
178 |
* The weird naming is an effort to decrease the risk of name clashes. |
|
179 |
*/ |
|
180 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
181 |
static int write_klass(JfrCheckpointWriter* writer, KlassPtr klass, bool leakp) { |
50113 | 182 |
assert(writer != NULL, "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
183 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
184 |
assert(klass != NULL, "invariant"); |
50113 | 185 |
traceid pkg_id = 0; |
186 |
KlassPtr theklass = klass; |
|
187 |
if (theklass->is_objArray_klass()) { |
|
188 |
const ObjArrayKlass* obj_arr_klass = ObjArrayKlass::cast(klass); |
|
189 |
theklass = obj_arr_klass->bottom_klass(); |
|
190 |
} |
|
191 |
if (theklass->is_instance_klass()) { |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
192 |
pkg_id = package_id(theklass, leakp); |
50113 | 193 |
} else { |
194 |
assert(theklass->is_typeArray_klass(), "invariant"); |
|
195 |
} |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
196 |
writer->write(artifact_id(klass)); |
58823 | 197 |
writer->write(cld_id(get_cld(klass), leakp)); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
198 |
writer->write(mark_symbol(klass, leakp)); |
50113 | 199 |
writer->write(pkg_id); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
200 |
writer->write(get_flags(klass)); |
50113 | 201 |
return 1; |
202 |
} |
|
203 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
204 |
int write__klass(JfrCheckpointWriter* writer, const void* k) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
205 |
assert(k != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
206 |
KlassPtr klass = (KlassPtr)k; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
207 |
set_serialized(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
208 |
return write_klass(writer, klass, false); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
209 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
210 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
211 |
int write__klass__leakp(JfrCheckpointWriter* writer, const void* k) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
212 |
assert(k != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
213 |
KlassPtr klass = (KlassPtr)k; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
214 |
return write_klass(writer, klass, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
215 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
216 |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
217 |
static bool is_implied(const Klass* klass) { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
218 |
assert(klass != NULL, "invariant"); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
219 |
return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()) || klass == SystemDictionary::Object_klass(); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
220 |
} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
221 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
222 |
static void do_implied(Klass* klass) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
223 |
assert(klass != NULL, "invariant"); |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
224 |
if (is_implied(klass)) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
225 |
if (_leakp_writer != NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
226 |
SET_LEAKP(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
227 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
228 |
_subsystem_callback->do_artifact(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
229 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
230 |
} |
50113 | 231 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
232 |
static void do_unloaded_klass(Klass* klass) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
233 |
assert(klass != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
234 |
assert(_subsystem_callback != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
235 |
if (IS_JDK_JFR_EVENT_SUBKLASS(klass)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
236 |
JfrEventClasses::increment_unloaded_event_class(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
237 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
238 |
if (USED_THIS_EPOCH(klass)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
239 |
ObjectSampleCheckpoint::on_klass_unload(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
240 |
_subsystem_callback->do_artifact(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
241 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
242 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
243 |
do_implied(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
244 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
245 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
246 |
static void do_klass(Klass* klass) { |
50113 | 247 |
assert(klass != NULL, "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
248 |
assert(_subsystem_callback != NULL, "invariant"); |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
249 |
if (_flushpoint) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
250 |
if (USED_THIS_EPOCH(klass)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
251 |
_subsystem_callback->do_artifact(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
252 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
253 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
254 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
255 |
if (USED_PREV_EPOCH(klass)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
256 |
_subsystem_callback->do_artifact(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
257 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
258 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
259 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
260 |
do_implied(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
261 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
262 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
263 |
static void do_klasses() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
264 |
if (_class_unload) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
265 |
ClassLoaderDataGraph::classes_unloading_do(&do_unloaded_klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
266 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
267 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
268 |
ClassLoaderDataGraph::classes_do(&do_klass); |
50113 | 269 |
} |
270 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
271 |
typedef SerializePredicate<KlassPtr> KlassPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
272 |
typedef JfrPredicatedTypeWriterImplHost<KlassPtr, KlassPredicate, write__klass> KlassWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
273 |
typedef JfrTypeWriterHost<KlassWriterImpl, TYPE_CLASS> KlassWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
274 |
typedef CompositeFunctor<KlassPtr, KlassWriter, KlassArtifactRegistrator> KlassWriterRegistration; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
275 |
typedef JfrArtifactCallbackHost<KlassPtr, KlassWriterRegistration> KlassCallback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
276 |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
277 |
template <> |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
278 |
class LeakPredicate<const Klass*> { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
279 |
public: |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
280 |
LeakPredicate(bool class_unload) {} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
281 |
bool operator()(const Klass* klass) { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
282 |
assert(klass != NULL, "invariant"); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
283 |
return IS_LEAKP(klass) || is_implied(klass); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
284 |
} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
285 |
}; |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
286 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
287 |
typedef LeakPredicate<KlassPtr> LeakKlassPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
288 |
typedef JfrPredicatedTypeWriterImplHost<KlassPtr, LeakKlassPredicate, write__klass__leakp> LeakKlassWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
289 |
typedef JfrTypeWriterHost<LeakKlassWriterImpl, TYPE_CLASS> LeakKlassWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
290 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
291 |
typedef CompositeFunctor<KlassPtr, LeakKlassWriter, KlassWriter> CompositeKlassWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
292 |
typedef CompositeFunctor<KlassPtr, CompositeKlassWriter, KlassArtifactRegistrator> CompositeKlassWriterRegistration; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
293 |
typedef JfrArtifactCallbackHost<KlassPtr, CompositeKlassWriterRegistration> CompositeKlassCallback; |
50113 | 294 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
295 |
static bool write_klasses() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
296 |
assert(!_artifacts->has_klass_entries(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
297 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
298 |
KlassArtifactRegistrator reg(_artifacts); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
299 |
KlassWriter kw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
300 |
KlassWriterRegistration kwr(&kw, ®); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
301 |
if (_leakp_writer == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
302 |
KlassCallback callback(&kwr); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
303 |
_subsystem_callback = &callback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
304 |
do_klasses(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
305 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
306 |
LeakKlassWriter lkw(_leakp_writer, _artifacts, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
307 |
CompositeKlassWriter ckw(&lkw, &kw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
308 |
CompositeKlassWriterRegistration ckwr(&ckw, ®); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
309 |
CompositeKlassCallback callback(&ckwr); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
310 |
_subsystem_callback = &callback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
311 |
do_klasses(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
312 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
313 |
if (is_complete()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
314 |
return false; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
315 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
316 |
_artifacts->tally(kw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
317 |
return true; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
318 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
319 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
320 |
template <typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
321 |
static void do_previous_epoch_artifact(JfrArtifactClosure* callback, T* value) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
322 |
assert(callback != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
323 |
assert(value != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
324 |
if (USED_PREV_EPOCH(value)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
325 |
callback->do_artifact(value); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
326 |
assert(IS_NOT_SERIALIZED(value), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
327 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
328 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
329 |
if (IS_SERIALIZED(value)) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
330 |
CLEAR_SERIALIZED(value); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
331 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
332 |
assert(IS_NOT_SERIALIZED(value), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
333 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
334 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
335 |
static int write_package(JfrCheckpointWriter* writer, PkgPtr pkg, bool leakp) { |
50113 | 336 |
assert(writer != NULL, "invariant"); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
337 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
338 |
assert(pkg != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
339 |
writer->write(artifact_id(pkg)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
340 |
writer->write(mark_symbol(pkg->name(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
341 |
writer->write(module_id(pkg, leakp)); |
50113 | 342 |
writer->write((bool)pkg->is_exported()); |
343 |
return 1; |
|
344 |
} |
|
345 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
346 |
int write__package(JfrCheckpointWriter* writer, const void* p) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
347 |
assert(p != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
348 |
PkgPtr pkg = (PkgPtr)p; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
349 |
set_serialized(pkg); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
350 |
return write_package(writer, pkg, false); |
50113 | 351 |
} |
352 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
353 |
int write__package__leakp(JfrCheckpointWriter* writer, const void* p) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
354 |
assert(p != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
355 |
PkgPtr pkg = (PkgPtr)p; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
356 |
CLEAR_LEAKP(pkg); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
357 |
return write_package(writer, pkg, true); |
50113 | 358 |
} |
359 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
360 |
static void do_package(PackageEntry* entry) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
361 |
do_previous_epoch_artifact(_subsystem_callback, entry); |
50113 | 362 |
} |
363 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
364 |
static void do_packages() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
365 |
ClassLoaderDataGraph::packages_do(&do_package); |
50113 | 366 |
} |
367 |
||
368 |
class PackageFieldSelector { |
|
369 |
public: |
|
370 |
typedef PkgPtr TypePtr; |
|
371 |
static TypePtr select(KlassPtr klass) { |
|
372 |
assert(klass != NULL, "invariant"); |
|
373 |
return ((InstanceKlass*)klass)->package(); |
|
374 |
} |
|
375 |
}; |
|
376 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
377 |
typedef SerializePredicate<PkgPtr> PackagePredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
378 |
typedef JfrPredicatedTypeWriterImplHost<PkgPtr, PackagePredicate, write__package> PackageWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
379 |
typedef JfrTypeWriterHost<PackageWriterImpl, TYPE_PACKAGE> PackageWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
380 |
typedef CompositeFunctor<PkgPtr, PackageWriter, ClearArtifact<PkgPtr> > PackageWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
381 |
typedef KlassToFieldEnvelope<PackageFieldSelector, PackageWriter> KlassPackageWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
382 |
typedef JfrArtifactCallbackHost<PkgPtr, PackageWriterWithClear> PackageCallback; |
50113 | 383 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
384 |
typedef LeakPredicate<PkgPtr> LeakPackagePredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
385 |
typedef JfrPredicatedTypeWriterImplHost<PkgPtr, LeakPackagePredicate, write__package__leakp> LeakPackageWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
386 |
typedef JfrTypeWriterHost<LeakPackageWriterImpl, TYPE_PACKAGE> LeakPackageWriter; |
50113 | 387 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
388 |
typedef CompositeFunctor<PkgPtr, LeakPackageWriter, PackageWriter> CompositePackageWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
389 |
typedef KlassToFieldEnvelope<PackageFieldSelector, CompositePackageWriter> KlassCompositePackageWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
390 |
typedef KlassToFieldEnvelope<PackageFieldSelector, PackageWriterWithClear> KlassPackageWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
391 |
typedef CompositeFunctor<PkgPtr, CompositePackageWriter, ClearArtifact<PkgPtr> > CompositePackageWriterWithClear; |
50113 | 392 |
typedef JfrArtifactCallbackHost<PkgPtr, CompositePackageWriterWithClear> CompositePackageCallback; |
393 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
394 |
static void write_packages() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
395 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
396 |
PackageWriter pw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
397 |
KlassPackageWriter kpw(&pw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
398 |
if (current_epoch()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
399 |
_artifacts->iterate_klasses(kpw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
400 |
_artifacts->tally(pw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
401 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
402 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
403 |
assert(previous_epoch(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
404 |
if (_leakp_writer == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
405 |
_artifacts->iterate_klasses(kpw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
406 |
ClearArtifact<PkgPtr> clear; |
50113 | 407 |
PackageWriterWithClear pwwc(&pw, &clear); |
408 |
PackageCallback callback(&pwwc); |
|
409 |
_subsystem_callback = &callback; |
|
410 |
do_packages(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
411 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
412 |
LeakPackageWriter lpw(_leakp_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
413 |
CompositePackageWriter cpw(&lpw, &pw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
414 |
KlassCompositePackageWriter kcpw(&cpw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
415 |
_artifacts->iterate_klasses(kcpw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
416 |
ClearArtifact<PkgPtr> clear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
417 |
CompositePackageWriterWithClear cpwwc(&cpw, &clear); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
418 |
CompositePackageCallback callback(&cpwwc); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
419 |
_subsystem_callback = &callback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
420 |
do_packages(); |
50113 | 421 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
422 |
_artifacts->tally(pw); |
50113 | 423 |
} |
424 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
425 |
static int write_module(JfrCheckpointWriter* writer, ModPtr mod, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
426 |
assert(mod != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
427 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
428 |
writer->write(artifact_id(mod)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
429 |
writer->write(mark_symbol(mod->name(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
430 |
writer->write(mark_symbol(mod->version(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
431 |
writer->write(mark_symbol(mod->location(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
432 |
writer->write(cld_id(mod->loader_data(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
433 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
434 |
} |
50113 | 435 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
436 |
int write__module(JfrCheckpointWriter* writer, const void* m) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
437 |
assert(m != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
438 |
ModPtr mod = (ModPtr)m; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
439 |
set_serialized(mod); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
440 |
return write_module(writer, mod, false); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
441 |
} |
50113 | 442 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
443 |
int write__module__leakp(JfrCheckpointWriter* writer, const void* m) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
444 |
assert(m != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
445 |
ModPtr mod = (ModPtr)m; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
446 |
CLEAR_LEAKP(mod); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
447 |
return write_module(writer, mod, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
448 |
} |
50113 | 449 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
450 |
static void do_module(ModuleEntry* entry) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
451 |
do_previous_epoch_artifact(_subsystem_callback, entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
452 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
453 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
454 |
static void do_modules() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
455 |
ClassLoaderDataGraph::modules_do(&do_module); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
456 |
} |
50113 | 457 |
|
458 |
class ModuleFieldSelector { |
|
459 |
public: |
|
460 |
typedef ModPtr TypePtr; |
|
461 |
static TypePtr select(KlassPtr klass) { |
|
462 |
assert(klass != NULL, "invariant"); |
|
463 |
PkgPtr pkg = klass->package(); |
|
464 |
return pkg != NULL ? pkg->module() : NULL; |
|
465 |
} |
|
466 |
}; |
|
467 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
468 |
typedef SerializePredicate<ModPtr> ModulePredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
469 |
typedef JfrPredicatedTypeWriterImplHost<ModPtr, ModulePredicate, write__module> ModuleWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
470 |
typedef JfrTypeWriterHost<ModuleWriterImpl, TYPE_MODULE> ModuleWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
471 |
typedef CompositeFunctor<ModPtr, ModuleWriter, ClearArtifact<ModPtr> > ModuleWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
472 |
typedef JfrArtifactCallbackHost<ModPtr, ModuleWriterWithClear> ModuleCallback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
473 |
typedef KlassToFieldEnvelope<ModuleFieldSelector, ModuleWriter> KlassModuleWriter; |
50113 | 474 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
475 |
typedef LeakPredicate<ModPtr> LeakModulePredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
476 |
typedef JfrPredicatedTypeWriterImplHost<ModPtr, LeakModulePredicate, write__module__leakp> LeakModuleWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
477 |
typedef JfrTypeWriterHost<LeakModuleWriterImpl, TYPE_MODULE> LeakModuleWriter; |
50113 | 478 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
479 |
typedef CompositeFunctor<ModPtr, LeakModuleWriter, ModuleWriter> CompositeModuleWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
480 |
typedef KlassToFieldEnvelope<ModuleFieldSelector, CompositeModuleWriter> KlassCompositeModuleWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
481 |
typedef CompositeFunctor<ModPtr, CompositeModuleWriter, ClearArtifact<ModPtr> > CompositeModuleWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
482 |
typedef JfrArtifactCallbackHost<ModPtr, CompositeModuleWriterWithClear> CompositeModuleCallback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
483 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
484 |
static void write_modules() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
485 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
486 |
ModuleWriter mw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
487 |
KlassModuleWriter kmw(&mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
488 |
if (current_epoch()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
489 |
_artifacts->iterate_klasses(kmw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
490 |
_artifacts->tally(mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
491 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
492 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
493 |
assert(previous_epoch(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
494 |
if (_leakp_writer == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
495 |
_artifacts->iterate_klasses(kmw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
496 |
ClearArtifact<ModPtr> clear; |
50113 | 497 |
ModuleWriterWithClear mwwc(&mw, &clear); |
498 |
ModuleCallback callback(&mwwc); |
|
499 |
_subsystem_callback = &callback; |
|
500 |
do_modules(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
501 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
502 |
LeakModuleWriter lmw(_leakp_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
503 |
CompositeModuleWriter cmw(&lmw, &mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
504 |
KlassCompositeModuleWriter kcpw(&cmw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
505 |
_artifacts->iterate_klasses(kcpw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
506 |
ClearArtifact<ModPtr> clear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
507 |
CompositeModuleWriterWithClear cmwwc(&cmw, &clear); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
508 |
CompositeModuleCallback callback(&cmwwc); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
509 |
_subsystem_callback = &callback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
510 |
do_modules(); |
50113 | 511 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
512 |
_artifacts->tally(mw); |
50113 | 513 |
} |
514 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
515 |
static int write_classloader(JfrCheckpointWriter* writer, CldPtr cld, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
516 |
assert(cld != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
517 |
assert(!cld->is_unsafe_anonymous(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
518 |
// class loader type |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
519 |
const Klass* class_loader_klass = cld->class_loader_klass(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
520 |
if (class_loader_klass == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
521 |
// (primordial) boot class loader |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
522 |
writer->write(artifact_id(cld)); // class loader instance id |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
523 |
writer->write((traceid)0); // class loader type id (absence of) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
524 |
writer->write(get_bootstrap_name(leakp)); // maps to synthetic name -> "bootstrap" |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
525 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
526 |
writer->write(artifact_id(cld)); // class loader instance id |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
527 |
writer->write(artifact_id(class_loader_klass)); // class loader type id |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
528 |
writer->write(mark_symbol(cld->name(), leakp)); // class loader instance name |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
529 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
530 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
531 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
532 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
533 |
int write__classloader(JfrCheckpointWriter* writer, const void* c) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
534 |
assert(c != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
535 |
CldPtr cld = (CldPtr)c; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
536 |
set_serialized(cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
537 |
return write_classloader(writer, cld, false); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
538 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
539 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
540 |
int write__classloader__leakp(JfrCheckpointWriter* writer, const void* c) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
541 |
assert(c != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
542 |
CldPtr cld = (CldPtr)c; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
543 |
CLEAR_LEAKP(cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
544 |
return write_classloader(writer, cld, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
545 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
546 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
547 |
static void do_class_loader_data(ClassLoaderData* cld) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
548 |
do_previous_epoch_artifact(_subsystem_callback, cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
549 |
} |
50113 | 550 |
|
58823 | 551 |
class KlassCldFieldSelector { |
50113 | 552 |
public: |
553 |
typedef CldPtr TypePtr; |
|
554 |
static TypePtr select(KlassPtr klass) { |
|
555 |
assert(klass != NULL, "invariant"); |
|
58823 | 556 |
return get_cld(klass); |
557 |
} |
|
558 |
}; |
|
559 |
||
560 |
class ModuleCldFieldSelector { |
|
561 |
public: |
|
562 |
typedef CldPtr TypePtr; |
|
563 |
static TypePtr select(KlassPtr klass) { |
|
564 |
assert(klass != NULL, "invariant"); |
|
565 |
ModPtr mod = ModuleFieldSelector::select(klass); |
|
566 |
return mod != NULL ? mod->loader_data() : NULL; |
|
50113 | 567 |
} |
568 |
}; |
|
569 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
570 |
class CLDCallback : public CLDClosure { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
571 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
572 |
CLDCallback() {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
573 |
void do_cld(ClassLoaderData* cld) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
574 |
assert(cld != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
575 |
if (cld->is_unsafe_anonymous()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
576 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
577 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
578 |
do_class_loader_data(cld); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
579 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
580 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
581 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
582 |
static void do_class_loaders() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
583 |
CLDCallback cld_cb; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
584 |
ClassLoaderDataGraph::loaded_cld_do(&cld_cb); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
585 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
586 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
587 |
typedef SerializePredicate<CldPtr> CldPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
588 |
typedef JfrPredicatedTypeWriterImplHost<CldPtr, CldPredicate, write__classloader> CldWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
589 |
typedef JfrTypeWriterHost<CldWriterImpl, TYPE_CLASSLOADER> CldWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
590 |
typedef CompositeFunctor<CldPtr, CldWriter, ClearArtifact<CldPtr> > CldWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
591 |
typedef JfrArtifactCallbackHost<CldPtr, CldWriterWithClear> CldCallback; |
58823 | 592 |
typedef KlassToFieldEnvelope<KlassCldFieldSelector, CldWriter> KlassCldWriter; |
593 |
typedef KlassToFieldEnvelope<ModuleCldFieldSelector, CldWriter> ModuleCldWriter; |
|
594 |
typedef CompositeFunctor<KlassPtr, KlassCldWriter, ModuleCldWriter> KlassAndModuleCldWriter; |
|
50113 | 595 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
596 |
typedef LeakPredicate<CldPtr> LeakCldPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
597 |
typedef JfrPredicatedTypeWriterImplHost<CldPtr, LeakCldPredicate, write__classloader__leakp> LeakCldWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
598 |
typedef JfrTypeWriterHost<LeakCldWriterImpl, TYPE_CLASSLOADER> LeakCldWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
599 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
600 |
typedef CompositeFunctor<CldPtr, LeakCldWriter, CldWriter> CompositeCldWriter; |
58823 | 601 |
typedef KlassToFieldEnvelope<KlassCldFieldSelector, CompositeCldWriter> KlassCompositeCldWriter; |
602 |
typedef KlassToFieldEnvelope<ModuleCldFieldSelector, CompositeCldWriter> ModuleCompositeCldWriter; |
|
603 |
typedef CompositeFunctor<KlassPtr, KlassCompositeCldWriter, ModuleCompositeCldWriter> KlassAndModuleCompositeCldWriter; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
604 |
typedef CompositeFunctor<CldPtr, CompositeCldWriter, ClearArtifact<CldPtr> > CompositeCldWriterWithClear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
605 |
typedef JfrArtifactCallbackHost<CldPtr, CompositeCldWriterWithClear> CompositeCldCallback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
606 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
607 |
static void write_classloaders() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
608 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
609 |
CldWriter cldw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
610 |
KlassCldWriter kcw(&cldw); |
58823 | 611 |
ModuleCldWriter mcw(&cldw); |
612 |
KlassAndModuleCldWriter kmcw(&kcw, &mcw); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
613 |
if (current_epoch()) { |
58823 | 614 |
_artifacts->iterate_klasses(kmcw); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
615 |
_artifacts->tally(cldw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
616 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
617 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
618 |
assert(previous_epoch(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
619 |
if (_leakp_writer == NULL) { |
58823 | 620 |
_artifacts->iterate_klasses(kmcw); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
621 |
ClearArtifact<CldPtr> clear; |
50113 | 622 |
CldWriterWithClear cldwwc(&cldw, &clear); |
623 |
CldCallback callback(&cldwwc); |
|
624 |
_subsystem_callback = &callback; |
|
625 |
do_class_loaders(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
626 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
627 |
LeakCldWriter lcldw(_leakp_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
628 |
CompositeCldWriter ccldw(&lcldw, &cldw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
629 |
KlassCompositeCldWriter kccldw(&ccldw); |
58823 | 630 |
ModuleCompositeCldWriter mccldw(&ccldw); |
631 |
KlassAndModuleCompositeCldWriter kmccldw(&kccldw, &mccldw); |
|
632 |
_artifacts->iterate_klasses(kmccldw); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
633 |
ClearArtifact<CldPtr> clear; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
634 |
CompositeCldWriterWithClear ccldwwc(&ccldw, &clear); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
635 |
CompositeCldCallback callback(&ccldwwc); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
636 |
_subsystem_callback = &callback; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
637 |
do_class_loaders(); |
50113 | 638 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
639 |
_artifacts->tally(cldw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
640 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
641 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
642 |
static u1 get_visibility(MethodPtr method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
643 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
644 |
return const_cast<Method*>(method)->is_hidden() ? (u1)1 : (u1)0; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
645 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
646 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
647 |
template <> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
648 |
void set_serialized<Method>(MethodPtr method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
649 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
650 |
SET_METHOD_SERIALIZED(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
651 |
assert(IS_METHOD_SERIALIZED(method), "invariant"); |
50113 | 652 |
} |
653 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
654 |
static int write_method(JfrCheckpointWriter* writer, MethodPtr method, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
655 |
assert(writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
656 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
657 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
658 |
KlassPtr klass = method->method_holder(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
659 |
assert(klass != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
660 |
writer->write(method_id(klass, method)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
661 |
writer->write(artifact_id(klass)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
662 |
writer->write(mark_symbol(method->name(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
663 |
writer->write(mark_symbol(method->signature(), leakp)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
664 |
writer->write((u2)get_flags(method)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
665 |
writer->write(get_visibility(method)); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
666 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
667 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
668 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
669 |
int write__method(JfrCheckpointWriter* writer, const void* m) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
670 |
assert(m != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
671 |
MethodPtr method = (MethodPtr)m; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
672 |
set_serialized(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
673 |
return write_method(writer, method, false); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
674 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
675 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
676 |
int write__method__leakp(JfrCheckpointWriter* writer, const void* m) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
677 |
assert(m != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
678 |
MethodPtr method = (MethodPtr)m; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
679 |
return write_method(writer, method, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
680 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
681 |
|
58823 | 682 |
class BitMapFilter { |
683 |
ResourceBitMap _bitmap; |
|
684 |
public: |
|
685 |
explicit BitMapFilter(int length = 0) : _bitmap((size_t)length) {} |
|
686 |
bool operator()(size_t idx) { |
|
687 |
if (_bitmap.size() == 0) { |
|
688 |
return true; |
|
689 |
} |
|
690 |
if (_bitmap.at(idx)) { |
|
691 |
return false; |
|
692 |
} |
|
693 |
_bitmap.set_bit(idx); |
|
694 |
return true; |
|
695 |
} |
|
696 |
}; |
|
697 |
||
698 |
class AlwaysTrue { |
|
699 |
public: |
|
700 |
explicit AlwaysTrue(int length = 0) {} |
|
701 |
bool operator()(size_t idx) { |
|
702 |
return true; |
|
703 |
} |
|
704 |
}; |
|
705 |
||
706 |
template <typename MethodCallback, typename KlassCallback, class Filter, bool leakp> |
|
50113 | 707 |
class MethodIteratorHost { |
708 |
private: |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
709 |
MethodCallback _method_cb; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
710 |
KlassCallback _klass_cb; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
711 |
MethodUsedPredicate<leakp> _method_used_predicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
712 |
MethodFlagPredicate<leakp> _method_flag_predicate; |
50113 | 713 |
public: |
714 |
MethodIteratorHost(JfrCheckpointWriter* writer, |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
715 |
bool current_epoch = false, |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
716 |
bool class_unload = false, |
50113 | 717 |
bool skip_header = false) : |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
718 |
_method_cb(writer, class_unload, skip_header), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
719 |
_klass_cb(writer, class_unload, skip_header), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
720 |
_method_used_predicate(current_epoch), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
721 |
_method_flag_predicate(current_epoch) {} |
50113 | 722 |
|
723 |
bool operator()(KlassPtr klass) { |
|
724 |
if (_method_used_predicate(klass)) { |
|
58823 | 725 |
const InstanceKlass* ik = InstanceKlass::cast(klass); |
50113 | 726 |
const int len = ik->methods()->length(); |
58823 | 727 |
Filter filter(ik->previous_versions() != NULL ? len : 0); |
728 |
while (ik != NULL) { |
|
729 |
for (int i = 0; i < len; ++i) { |
|
730 |
MethodPtr method = ik->methods()->at(i); |
|
731 |
if (_method_flag_predicate(method) && filter(i)) { |
|
732 |
_method_cb(method); |
|
733 |
} |
|
50113 | 734 |
} |
58823 | 735 |
// There can be multiple versions of the same method running |
736 |
// due to redefinition. Need to inspect the complete set of methods. |
|
737 |
ik = ik->previous_versions(); |
|
50113 | 738 |
} |
739 |
} |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
740 |
return _klass_cb(klass); |
50113 | 741 |
} |
742 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
743 |
int count() const { return _method_cb.count(); } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
744 |
void add(int count) { _method_cb.add(count); } |
50113 | 745 |
}; |
746 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
747 |
template <typename T, template <typename> class Impl> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
748 |
class Wrapper { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
749 |
Impl<T> _t; |
50113 | 750 |
public: |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
751 |
Wrapper(JfrCheckpointWriter*, bool, bool) : _t() {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
752 |
bool operator()(T const& value) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
753 |
return _t(value); |
50113 | 754 |
} |
755 |
}; |
|
756 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
757 |
typedef SerializePredicate<MethodPtr> MethodPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
758 |
typedef JfrPredicatedTypeWriterImplHost<MethodPtr, MethodPredicate, write__method> MethodWriterImplTarget; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
759 |
typedef Wrapper<KlassPtr, Stub> KlassCallbackStub; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
760 |
typedef JfrTypeWriterHost<MethodWriterImplTarget, TYPE_METHOD> MethodWriterImpl; |
58823 | 761 |
typedef MethodIteratorHost<MethodWriterImpl, KlassCallbackStub, BitMapFilter, false> MethodWriter; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
762 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
763 |
typedef LeakPredicate<MethodPtr> LeakMethodPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
764 |
typedef JfrPredicatedTypeWriterImplHost<MethodPtr, LeakMethodPredicate, write__method__leakp> LeakMethodWriterImplTarget; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
765 |
typedef JfrTypeWriterHost<LeakMethodWriterImplTarget, TYPE_METHOD> LeakMethodWriterImpl; |
58823 | 766 |
typedef MethodIteratorHost<LeakMethodWriterImpl, KlassCallbackStub, BitMapFilter, true> LeakMethodWriter; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
767 |
typedef CompositeFunctor<KlassPtr, LeakMethodWriter, MethodWriter> CompositeMethodWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
768 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
769 |
static void write_methods() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
770 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
771 |
MethodWriter mw(_writer, current_epoch(), _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
772 |
if (_leakp_writer == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
773 |
_artifacts->iterate_klasses(mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
774 |
} else { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
775 |
LeakMethodWriter lpmw(_leakp_writer, current_epoch(), _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
776 |
CompositeMethodWriter cmw(&lpmw, &mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
777 |
_artifacts->iterate_klasses(cmw); |
50113 | 778 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
779 |
_artifacts->tally(mw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
780 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
781 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
782 |
template <> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
783 |
void set_serialized<JfrSymbolId::SymbolEntry>(SymbolEntryPtr ptr) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
784 |
assert(ptr != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
785 |
ptr->set_serialized(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
786 |
assert(ptr->is_serialized(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
787 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
788 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
789 |
template <> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
790 |
void set_serialized<JfrSymbolId::CStringEntry>(CStringEntryPtr ptr) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
791 |
assert(ptr != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
792 |
ptr->set_serialized(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
793 |
assert(ptr->is_serialized(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
794 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
795 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
796 |
static int write_symbol(JfrCheckpointWriter* writer, SymbolEntryPtr entry, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
797 |
assert(writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
798 |
assert(entry != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
799 |
ResourceMark rm; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
800 |
writer->write(create_symbol_id(entry->id())); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
801 |
writer->write(entry->value()->as_C_string()); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
802 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
803 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
804 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
805 |
int write__symbol(JfrCheckpointWriter* writer, const void* e) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
806 |
assert(e != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
807 |
SymbolEntryPtr entry = (SymbolEntryPtr)e; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
808 |
set_serialized(entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
809 |
return write_symbol(writer, entry, false); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
810 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
811 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
812 |
int write__symbol__leakp(JfrCheckpointWriter* writer, const void* e) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
813 |
assert(e != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
814 |
SymbolEntryPtr entry = (SymbolEntryPtr)e; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
815 |
return write_symbol(writer, entry, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
816 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
817 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
818 |
static int write_cstring(JfrCheckpointWriter* writer, CStringEntryPtr entry, bool leakp) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
819 |
assert(writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
820 |
assert(entry != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
821 |
writer->write(create_symbol_id(entry->id())); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
822 |
writer->write(entry->value()); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
823 |
return 1; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
824 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
825 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
826 |
int write__cstring(JfrCheckpointWriter* writer, const void* e) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
827 |
assert(e != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
828 |
CStringEntryPtr entry = (CStringEntryPtr)e; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
829 |
set_serialized(entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
830 |
return write_cstring(writer, entry, false); |
50113 | 831 |
} |
832 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
833 |
int write__cstring__leakp(JfrCheckpointWriter* writer, const void* e) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
834 |
assert(e != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
835 |
CStringEntryPtr entry = (CStringEntryPtr)e; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
836 |
return write_cstring(writer, entry, true); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
837 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
838 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
839 |
typedef SymbolPredicate<SymbolEntryPtr, false> SymPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
840 |
typedef JfrPredicatedTypeWriterImplHost<SymbolEntryPtr, SymPredicate, write__symbol> SymbolEntryWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
841 |
typedef JfrTypeWriterHost<SymbolEntryWriterImpl, TYPE_SYMBOL> SymbolEntryWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
842 |
typedef SymbolPredicate<CStringEntryPtr, false> CStringPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
843 |
typedef JfrPredicatedTypeWriterImplHost<CStringEntryPtr, CStringPredicate, write__cstring> CStringEntryWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
844 |
typedef JfrTypeWriterHost<CStringEntryWriterImpl, TYPE_SYMBOL> CStringEntryWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
845 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
846 |
typedef SymbolPredicate<SymbolEntryPtr, true> LeakSymPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
847 |
typedef JfrPredicatedTypeWriterImplHost<SymbolEntryPtr, LeakSymPredicate, write__symbol__leakp> LeakSymbolEntryWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
848 |
typedef JfrTypeWriterHost<LeakSymbolEntryWriterImpl, TYPE_SYMBOL> LeakSymbolEntryWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
849 |
typedef CompositeFunctor<SymbolEntryPtr, LeakSymbolEntryWriter, SymbolEntryWriter> CompositeSymbolWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
850 |
typedef SymbolPredicate<CStringEntryPtr, true> LeakCStringPredicate; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
851 |
typedef JfrPredicatedTypeWriterImplHost<CStringEntryPtr, LeakCStringPredicate, write__cstring__leakp> LeakCStringEntryWriterImpl; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
852 |
typedef JfrTypeWriterHost<LeakCStringEntryWriterImpl, TYPE_SYMBOL> LeakCStringEntryWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
853 |
typedef CompositeFunctor<CStringEntryPtr, LeakCStringEntryWriter, CStringEntryWriter> CompositeCStringWriter; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
854 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
855 |
static void write_symbols_with_leakp() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
856 |
assert(_leakp_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
857 |
SymbolEntryWriter sw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
858 |
LeakSymbolEntryWriter lsw(_leakp_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
859 |
CompositeSymbolWriter csw(&lsw, &sw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
860 |
_artifacts->iterate_symbols(csw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
861 |
CStringEntryWriter ccsw(_writer, _class_unload, true); // skip header |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
862 |
LeakCStringEntryWriter lccsw(_leakp_writer, _class_unload, true); // skip header |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
863 |
CompositeCStringWriter cccsw(&lccsw, &ccsw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
864 |
_artifacts->iterate_cstrings(cccsw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
865 |
sw.add(ccsw.count()); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
866 |
lsw.add(lccsw.count()); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
867 |
_artifacts->tally(sw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
868 |
} |
50113 | 869 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
870 |
static void write_symbols() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
871 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
872 |
if (_leakp_writer != NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
873 |
write_symbols_with_leakp(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
874 |
return; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
875 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
876 |
SymbolEntryWriter sw(_writer, _class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
877 |
_artifacts->iterate_symbols(sw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
878 |
CStringEntryWriter csw(_writer, _class_unload, true); // skip header |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
879 |
_artifacts->iterate_cstrings(csw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
880 |
sw.add(csw.count()); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
881 |
_artifacts->tally(sw); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
882 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
883 |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
884 |
static bool clear_artifacts = false; |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
885 |
|
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
886 |
void JfrTypeSet::clear() { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
887 |
clear_artifacts = true; |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
888 |
} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
889 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
890 |
typedef Wrapper<KlassPtr, ClearArtifact> ClearKlassBits; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
891 |
typedef Wrapper<MethodPtr, ClearArtifact> ClearMethodFlag; |
58823 | 892 |
typedef MethodIteratorHost<ClearMethodFlag, ClearKlassBits, AlwaysTrue, false> ClearKlassAndMethods; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
893 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
894 |
static size_t teardown() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
895 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
896 |
const size_t total_count = _artifacts->total_count(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
897 |
if (previous_epoch()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
898 |
assert(_writer != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
899 |
ClearKlassAndMethods clear(_writer); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
900 |
_artifacts->iterate_klasses(clear); |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
901 |
JfrTypeSet::clear(); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
902 |
++checkpoint_id; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
903 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
904 |
return total_count; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
905 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
906 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
907 |
static void setup(JfrCheckpointWriter* writer, JfrCheckpointWriter* leakp_writer, bool class_unload, bool flushpoint) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
908 |
_writer = writer; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
909 |
_leakp_writer = leakp_writer; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
910 |
_class_unload = class_unload; |
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
911 |
_flushpoint = flushpoint; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
912 |
if (_artifacts == NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
913 |
_artifacts = new JfrArtifactSet(class_unload); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
914 |
} else { |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
915 |
_artifacts->initialize(class_unload, clear_artifacts); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
916 |
} |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
917 |
clear_artifacts = false; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
918 |
assert(_artifacts != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
919 |
assert(!_artifacts->has_klass_entries(), "invariant"); |
50113 | 920 |
} |
921 |
||
922 |
/** |
|
923 |
* Write all "tagged" (in-use) constant artifacts and their dependencies. |
|
924 |
*/ |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
925 |
size_t JfrTypeSet::serialize(JfrCheckpointWriter* writer, JfrCheckpointWriter* leakp_writer, bool class_unload, bool flushpoint) { |
50113 | 926 |
assert(writer != NULL, "invariant"); |
927 |
ResourceMark rm; |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57870
diff
changeset
|
928 |
setup(writer, leakp_writer, class_unload, flushpoint); |
50113 | 929 |
// write order is important because an individual write step |
930 |
// might tag an artifact to be written in a subsequent step |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
931 |
if (!write_klasses()) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
932 |
return 0; |
50113 | 933 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
934 |
write_packages(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
935 |
write_modules(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
936 |
write_classloaders(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
937 |
write_methods(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
938 |
write_symbols(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
52586
diff
changeset
|
939 |
return teardown(); |
50113 | 940 |
} |