1 /*
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
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 *
224 bool _class_unload;
225
226 // hashtable(s) callbacks
227 void on_link(const SymbolEntry* entry);
228 bool on_equals(uintptr_t hash, const SymbolEntry* entry);
229 void on_unlink(const SymbolEntry* entry);
230 void on_link(const CStringEntry* entry);
231 bool on_equals(uintptr_t hash, const CStringEntry* entry);
232 void on_unlink(const CStringEntry* entry);
233
234 template <typename Functor, typename T>
235 void iterate(Functor& functor, const T* list) {
236 const T* symbol = list;
237 while (symbol != NULL) {
238 const T* next = symbol->list_next();
239 functor(symbol);
240 symbol = next;
241 }
242 }
243
244 traceid mark_unsafe_anonymous_klass_name(const InstanceKlass* k, bool leakp);
245 bool is_unsafe_anonymous_klass(const Klass* k);
246 uintptr_t unsafe_anonymous_klass_name_hash(const InstanceKlass* ik);
247
248 public:
249 JfrSymbolId();
250 ~JfrSymbolId();
251
252 void clear();
253 void set_class_unload(bool class_unload);
254
255 traceid mark(uintptr_t hash, const Symbol* sym, bool leakp);
256 traceid mark(const Klass* k, bool leakp);
257 traceid mark(const Symbol* symbol, bool leakp);
258 traceid mark(uintptr_t hash, const char* str, bool leakp);
259 traceid bootstrap_name(bool leakp);
260
261 template <typename Functor>
262 void iterate_symbols(Functor& functor) {
263 iterate(functor, _sym_list);
264 }
265
266 template <typename Functor>
287 * be to reduce the amount of iterations neccessary for locating artifacts
288 * in the respective VM subsystems.
289 */
290 class JfrArtifactSet : public JfrCHeapObj {
291 private:
292 JfrSymbolId* _symbol_id;
293 GrowableArray<const Klass*>* _klass_list;
294 size_t _total_count;
295
296 public:
297 JfrArtifactSet(bool class_unload);
298 ~JfrArtifactSet();
299
300 // caller needs ResourceMark
301 void initialize(bool class_unload, bool clear = false);
302
303 traceid mark(uintptr_t hash, const Symbol* sym, bool leakp);
304 traceid mark(const Klass* klass, bool leakp);
305 traceid mark(const Symbol* symbol, bool leakp);
306 traceid mark(uintptr_t hash, const char* const str, bool leakp);
307 traceid mark_unsafe_anonymous_klass_name(const Klass* klass, bool leakp);
308 traceid bootstrap_name(bool leakp);
309
310 const JfrSymbolId::SymbolEntry* map_symbol(const Symbol* symbol) const;
311 const JfrSymbolId::SymbolEntry* map_symbol(uintptr_t hash) const;
312 const JfrSymbolId::CStringEntry* map_cstring(uintptr_t hash) const;
313
314 bool has_klass_entries() const;
315 int entries() const;
316 size_t total_count() const;
317 void register_klass(const Klass* k);
318
319 template <typename Functor>
320 void iterate_klasses(Functor& functor) const {
321 for (int i = 0; i < _klass_list->length(); ++i) {
322 if (!functor(_klass_list->at(i))) {
323 break;
324 }
325 }
326 }
327
|
1 /*
2 * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
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 *
224 bool _class_unload;
225
226 // hashtable(s) callbacks
227 void on_link(const SymbolEntry* entry);
228 bool on_equals(uintptr_t hash, const SymbolEntry* entry);
229 void on_unlink(const SymbolEntry* entry);
230 void on_link(const CStringEntry* entry);
231 bool on_equals(uintptr_t hash, const CStringEntry* entry);
232 void on_unlink(const CStringEntry* entry);
233
234 template <typename Functor, typename T>
235 void iterate(Functor& functor, const T* list) {
236 const T* symbol = list;
237 while (symbol != NULL) {
238 const T* next = symbol->list_next();
239 functor(symbol);
240 symbol = next;
241 }
242 }
243
244 traceid mark_hidden_or_anon_klass_name(const InstanceKlass* k, bool leakp);
245 bool is_hidden_or_anon_klass(const Klass* k);
246 uintptr_t hidden_or_anon_klass_name_hash(const InstanceKlass* ik);
247
248 public:
249 JfrSymbolId();
250 ~JfrSymbolId();
251
252 void clear();
253 void set_class_unload(bool class_unload);
254
255 traceid mark(uintptr_t hash, const Symbol* sym, bool leakp);
256 traceid mark(const Klass* k, bool leakp);
257 traceid mark(const Symbol* symbol, bool leakp);
258 traceid mark(uintptr_t hash, const char* str, bool leakp);
259 traceid bootstrap_name(bool leakp);
260
261 template <typename Functor>
262 void iterate_symbols(Functor& functor) {
263 iterate(functor, _sym_list);
264 }
265
266 template <typename Functor>
287 * be to reduce the amount of iterations neccessary for locating artifacts
288 * in the respective VM subsystems.
289 */
290 class JfrArtifactSet : public JfrCHeapObj {
291 private:
292 JfrSymbolId* _symbol_id;
293 GrowableArray<const Klass*>* _klass_list;
294 size_t _total_count;
295
296 public:
297 JfrArtifactSet(bool class_unload);
298 ~JfrArtifactSet();
299
300 // caller needs ResourceMark
301 void initialize(bool class_unload, bool clear = false);
302
303 traceid mark(uintptr_t hash, const Symbol* sym, bool leakp);
304 traceid mark(const Klass* klass, bool leakp);
305 traceid mark(const Symbol* symbol, bool leakp);
306 traceid mark(uintptr_t hash, const char* const str, bool leakp);
307 traceid mark_hidden_or_anon_klass_name(const Klass* klass, bool leakp);
308 traceid bootstrap_name(bool leakp);
309
310 const JfrSymbolId::SymbolEntry* map_symbol(const Symbol* symbol) const;
311 const JfrSymbolId::SymbolEntry* map_symbol(uintptr_t hash) const;
312 const JfrSymbolId::CStringEntry* map_cstring(uintptr_t hash) const;
313
314 bool has_klass_entries() const;
315 int entries() const;
316 size_t total_count() const;
317 void register_klass(const Klass* k);
318
319 template <typename Functor>
320 void iterate_klasses(Functor& functor) const {
321 for (int i = 0; i < _klass_list->length(); ++i) {
322 if (!functor(_klass_list->at(i))) {
323 break;
324 }
325 }
326 }
327
|