author | mgronlun |
Mon, 28 Oct 2019 21:17:47 +0100 | |
branch | JEP-349-branch |
changeset 58826 | fb51e2ae730e |
parent 58823 | 6a21dba79b81 |
child 58837 | 2bfbb50dd97d |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
2 |
* Copyright (c) 2017, 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
25 |
#ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_JFRTYPESETUTILS_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
26 |
#define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_JFRTYPESETUTILS_HPP |
50113 | 27 |
|
28 |
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp" |
|
29 |
#include "jfr/utilities/jfrAllocation.hpp" |
|
30 |
#include "jfr/utilities/jfrHashtable.hpp" |
|
31 |
#include "oops/klass.hpp" |
|
32 |
#include "oops/method.hpp" |
|
33 |
#include "utilities/growableArray.hpp" |
|
34 |
||
35 |
// Composite callback/functor building block |
|
36 |
template <typename T, typename Func1, typename Func2> |
|
37 |
class CompositeFunctor { |
|
38 |
private: |
|
39 |
Func1* _f; |
|
40 |
Func2* _g; |
|
41 |
public: |
|
42 |
CompositeFunctor(Func1* f, Func2* g) : _f(f), _g(g) { |
|
43 |
assert(f != NULL, "invariant"); |
|
44 |
assert(g != NULL, "invariant"); |
|
45 |
} |
|
46 |
bool operator()(T const& value) { |
|
47 |
return (*_f)(value) && (*_g)(value); |
|
48 |
} |
|
49 |
}; |
|
50 |
||
51 |
class JfrArtifactClosure { |
|
52 |
public: |
|
53 |
virtual void do_artifact(const void* artifact) = 0; |
|
54 |
}; |
|
55 |
||
56 |
template <typename T, typename Callback> |
|
57 |
class JfrArtifactCallbackHost : public JfrArtifactClosure { |
|
58 |
private: |
|
59 |
Callback* _callback; |
|
60 |
public: |
|
61 |
JfrArtifactCallbackHost(Callback* callback) : _callback(callback) {} |
|
62 |
void do_artifact(const void* artifact) { |
|
63 |
(*_callback)(reinterpret_cast<T const&>(artifact)); |
|
64 |
} |
|
65 |
}; |
|
66 |
||
67 |
template <typename FieldSelector, typename Letter> |
|
68 |
class KlassToFieldEnvelope { |
|
69 |
Letter* _letter; |
|
70 |
public: |
|
71 |
KlassToFieldEnvelope(Letter* letter) : _letter(letter) {} |
|
72 |
bool operator()(const Klass* klass) { |
|
73 |
typename FieldSelector::TypePtr t = FieldSelector::select(klass); |
|
74 |
return t != NULL ? (*_letter)(t) : true; |
|
75 |
} |
|
76 |
}; |
|
77 |
||
78 |
template <typename T> |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
79 |
class ClearArtifact { |
50113 | 80 |
public: |
81 |
bool operator()(T const& value) { |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
82 |
CLEAR_METHOD_AND_CLASS_PREV_EPOCH(value); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
83 |
CLEAR_SERIALIZED(value); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
84 |
assert(IS_NOT_SERIALIZED(value), "invariant"); |
50113 | 85 |
return true; |
86 |
} |
|
87 |
}; |
|
88 |
||
89 |
template <> |
|
90 |
class ClearArtifact<const Method*> { |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
91 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
92 |
bool operator()(const Method* method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
93 |
assert(METHOD_FLAG_USED_PREV_EPOCH(method), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
94 |
CLEAR_METHOD_FLAG_USED_PREV_EPOCH(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
95 |
CLEAR_METHOD_SERIALIZED(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
96 |
assert(METHOD_NOT_SERIALIZED(method), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
97 |
return true; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
98 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
99 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
100 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
101 |
template <typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
102 |
class SerializePredicate { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
103 |
bool _class_unload; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
104 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
105 |
SerializePredicate(bool class_unload) : _class_unload(class_unload) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
106 |
bool operator()(T const& value) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
107 |
assert(value != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
108 |
return _class_unload ? true : IS_NOT_SERIALIZED(value); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
109 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
110 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
111 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
112 |
template <> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
113 |
class SerializePredicate<const Method*> { |
50113 | 114 |
bool _class_unload; |
115 |
public: |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
116 |
SerializePredicate(bool class_unload) : _class_unload(class_unload) {} |
50113 | 117 |
bool operator()(const Method* method) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
118 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
119 |
return _class_unload ? true : METHOD_NOT_SERIALIZED(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
120 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
121 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
122 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
123 |
template <typename T, bool leakp> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
124 |
class SymbolPredicate { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
125 |
bool _class_unload; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
126 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
127 |
SymbolPredicate(bool class_unload) : _class_unload(class_unload) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
128 |
bool operator()(T const& value) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
129 |
assert(value != NULL, "invariant"); |
50113 | 130 |
if (_class_unload) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
131 |
return leakp ? value->is_leakp() : value->is_unloading(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
132 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
133 |
return leakp ? value->is_leakp() : !value->is_serialized(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
134 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
135 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
136 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
137 |
template <bool leakp> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
138 |
class MethodUsedPredicate { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
139 |
bool _current_epoch; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
140 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
141 |
MethodUsedPredicate(bool current_epoch) : _current_epoch(current_epoch) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
142 |
bool operator()(const Klass* klass) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
143 |
if (_current_epoch) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
144 |
return leakp ? IS_LEAKP(klass) : METHOD_USED_THIS_EPOCH(klass); |
50113 | 145 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
146 |
return leakp ? IS_LEAKP(klass) : METHOD_USED_PREV_EPOCH(klass); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
147 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
148 |
}; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
149 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
150 |
template <bool leakp> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
151 |
class MethodFlagPredicate { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
152 |
bool _current_epoch; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
153 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
154 |
MethodFlagPredicate(bool current_epoch) : _current_epoch(current_epoch) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
155 |
bool operator()(const Method* method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
156 |
if (_current_epoch) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
157 |
return leakp ? IS_METHOD_LEAKP_USED(method) : METHOD_FLAG_USED_THIS_EPOCH(method); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
158 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
159 |
return leakp ? IS_METHOD_LEAKP_USED(method) : METHOD_FLAG_USED_PREV_EPOCH(method); |
50113 | 160 |
} |
161 |
}; |
|
162 |
||
163 |
template <typename T> |
|
164 |
class LeakPredicate { |
|
165 |
public: |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
166 |
LeakPredicate(bool class_unload) {} |
50113 | 167 |
bool operator()(T const& value) { |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
168 |
return IS_LEAKP(value); |
50113 | 169 |
} |
170 |
}; |
|
171 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
172 |
template <> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
173 |
class LeakPredicate<const Method*> { |
50113 | 174 |
public: |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
175 |
LeakPredicate(bool class_unload) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
176 |
bool operator()(const Method* method) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
177 |
assert(method != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
178 |
return IS_METHOD_LEAKP_USED(method); |
50113 | 179 |
} |
180 |
}; |
|
181 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
182 |
template <typename T, typename IdType> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
183 |
class ListEntry : public JfrHashtableEntry<T, IdType> { |
50113 | 184 |
public: |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
185 |
ListEntry(uintptr_t hash, const T& data) : JfrHashtableEntry<T, IdType>(hash, data), |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
186 |
_list_next(NULL), _serialized(false), _unloading(false), _leakp(false) {} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
187 |
const ListEntry<T, IdType>* list_next() const { return _list_next; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
188 |
void reset() const { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
189 |
_list_next = NULL; _serialized = false; _unloading = false; _leakp = false; |
50113 | 190 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
191 |
void set_list_next(const ListEntry<T, IdType>* next) const { _list_next = next; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
192 |
bool is_serialized() const { return _serialized; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
193 |
void set_serialized() const { _serialized = true; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
194 |
bool is_unloading() const { return _unloading; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
195 |
void set_unloading() const { _unloading = true; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
196 |
bool is_leakp() const { return _leakp; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
197 |
void set_leakp() const { _leakp = true; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
198 |
private: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
199 |
mutable const ListEntry<T, IdType>* _list_next; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
200 |
mutable bool _serialized; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
201 |
mutable bool _unloading; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
202 |
mutable bool _leakp; |
50113 | 203 |
}; |
204 |
||
205 |
class JfrSymbolId : public JfrCHeapObj { |
|
206 |
template <typename, typename, template<typename, typename> class, typename, size_t> |
|
207 |
friend class HashTableHost; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
208 |
typedef HashTableHost<const Symbol*, traceid, ListEntry, JfrSymbolId> SymbolTable; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
209 |
typedef HashTableHost<const char*, traceid, ListEntry, JfrSymbolId> CStringTable; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
210 |
friend class JfrArtifactSet; |
50113 | 211 |
public: |
212 |
typedef SymbolTable::HashEntry SymbolEntry; |
|
213 |
typedef CStringTable::HashEntry CStringEntry; |
|
214 |
private: |
|
215 |
SymbolTable* _sym_table; |
|
216 |
CStringTable* _cstring_table; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
217 |
const SymbolEntry* _sym_list; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
218 |
const CStringEntry* _cstring_list; |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
219 |
const Symbol* _sym_query; |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
220 |
const char* _cstring_query; |
50113 | 221 |
traceid _symbol_id_counter; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
222 |
bool _class_unload; |
50113 | 223 |
|
224 |
// hashtable(s) callbacks |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
225 |
void on_link(const SymbolEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
226 |
bool on_equals(uintptr_t hash, const SymbolEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
227 |
void on_unlink(const SymbolEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
228 |
void on_link(const CStringEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
229 |
bool on_equals(uintptr_t hash, const CStringEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
230 |
void on_unlink(const CStringEntry* entry); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
231 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
232 |
template <typename Functor, typename T> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
233 |
void iterate(Functor& functor, const T* list) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
234 |
const T* symbol = list; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
235 |
while (symbol != NULL) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
236 |
const T* next = symbol->list_next(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
237 |
functor(symbol); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
238 |
symbol = next; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
239 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
240 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
241 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
242 |
traceid mark_unsafe_anonymous_klass_name(const InstanceKlass* k, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
243 |
bool is_unsafe_anonymous_klass(const Klass* k); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
244 |
uintptr_t unsafe_anonymous_klass_name_hash(const InstanceKlass* ik); |
50113 | 245 |
|
246 |
public: |
|
247 |
JfrSymbolId(); |
|
248 |
~JfrSymbolId(); |
|
249 |
||
250 |
void clear(); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
251 |
void set_class_unload(bool class_unload); |
50113 | 252 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
253 |
traceid mark(uintptr_t hash, const Symbol* sym, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
254 |
traceid mark(const Klass* k, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
255 |
traceid mark(const Symbol* symbol, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
256 |
traceid mark(uintptr_t hash, const char* str, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
257 |
traceid bootstrap_name(bool leakp); |
50113 | 258 |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
259 |
template <typename Functor> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
260 |
void iterate_symbols(Functor& functor) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
261 |
iterate(functor, _sym_list); |
50113 | 262 |
} |
263 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
264 |
template <typename Functor> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
265 |
void iterate_cstrings(Functor& functor) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
266 |
iterate(functor, _cstring_list); |
50113 | 267 |
} |
268 |
||
269 |
bool has_entries() const { return has_symbol_entries() || has_cstring_entries(); } |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
270 |
bool has_symbol_entries() const { return _sym_list != NULL; } |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
271 |
bool has_cstring_entries() const { return _cstring_list != NULL; } |
50113 | 272 |
}; |
273 |
||
274 |
/** |
|
275 |
* When processing a set of artifacts, there will be a need |
|
276 |
* to track transitive dependencies originating with each artifact. |
|
277 |
* These might or might not be explicitly "tagged" at that point. |
|
278 |
* With the introduction of "epochs" to allow for concurrent tagging, |
|
279 |
* we attempt to avoid "tagging" an artifact to indicate its use in a |
|
280 |
* previous epoch. This is mainly to reduce the risk for data races. |
|
281 |
* Instead, JfrArtifactSet is used to track transitive dependencies |
|
282 |
* during the write process itself. |
|
283 |
* |
|
284 |
* It can also provide opportunities for caching, as the ideal should |
|
285 |
* be to reduce the amount of iterations neccessary for locating artifacts |
|
286 |
* in the respective VM subsystems. |
|
287 |
*/ |
|
288 |
class JfrArtifactSet : public JfrCHeapObj { |
|
289 |
private: |
|
290 |
JfrSymbolId* _symbol_id; |
|
291 |
GrowableArray<const Klass*>* _klass_list; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
292 |
size_t _total_count; |
50113 | 293 |
|
294 |
public: |
|
295 |
JfrArtifactSet(bool class_unload); |
|
296 |
~JfrArtifactSet(); |
|
297 |
||
298 |
// caller needs ResourceMark |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
299 |
void initialize(bool class_unload, bool clear = false); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
300 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
301 |
traceid mark(uintptr_t hash, const Symbol* sym, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
302 |
traceid mark(const Klass* klass, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
303 |
traceid mark(const Symbol* symbol, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
304 |
traceid mark(uintptr_t hash, const char* const str, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
305 |
traceid mark_unsafe_anonymous_klass_name(const Klass* klass, bool leakp); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
306 |
traceid bootstrap_name(bool leakp); |
50113 | 307 |
|
308 |
const JfrSymbolId::SymbolEntry* map_symbol(const Symbol* symbol) const; |
|
309 |
const JfrSymbolId::SymbolEntry* map_symbol(uintptr_t hash) const; |
|
310 |
const JfrSymbolId::CStringEntry* map_cstring(uintptr_t hash) const; |
|
311 |
||
312 |
bool has_klass_entries() const; |
|
313 |
int entries() const; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
314 |
size_t total_count() const; |
50113 | 315 |
void register_klass(const Klass* k); |
316 |
||
317 |
template <typename Functor> |
|
318 |
void iterate_klasses(Functor& functor) const { |
|
319 |
for (int i = 0; i < _klass_list->length(); ++i) { |
|
320 |
if (!functor(_klass_list->at(i))) { |
|
321 |
break; |
|
322 |
} |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
template <typename T> |
|
327 |
void iterate_symbols(T& functor) { |
|
328 |
_symbol_id->iterate_symbols(functor); |
|
329 |
} |
|
330 |
||
331 |
template <typename T> |
|
332 |
void iterate_cstrings(T& functor) { |
|
333 |
_symbol_id->iterate_cstrings(functor); |
|
334 |
} |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
335 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
336 |
template <typename Writer> |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
337 |
void tally(Writer& writer) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
338 |
_total_count += writer.count(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
339 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
53244
diff
changeset
|
340 |
|
50113 | 341 |
}; |
342 |
||
343 |
class KlassArtifactRegistrator { |
|
344 |
private: |
|
345 |
JfrArtifactSet* _artifacts; |
|
346 |
public: |
|
347 |
KlassArtifactRegistrator(JfrArtifactSet* artifacts) : |
|
348 |
_artifacts(artifacts) { |
|
349 |
assert(_artifacts != NULL, "invariant"); |
|
350 |
} |
|
351 |
||
352 |
bool operator()(const Klass* klass) { |
|
353 |
assert(klass != NULL, "invariant"); |
|
354 |
_artifacts->register_klass(klass); |
|
355 |
return true; |
|
356 |
} |
|
357 |
}; |
|
358 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
359 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_JFRTYPESETUTILS_HPP |