src/share/vm/jfr/leakprofiler/chains/edgeStore.hpp

Wed, 09 Oct 2019 16:11:58 +0800

author
ddong
date
Wed, 09 Oct 2019 16:11:58 +0800
changeset 9885
8e875c964f41
parent 9858
b985cbb00e68
permissions
-rw-r--r--

8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
Reviewed-by: egahlin, rwestberg

apetushkov@9858 1 /*
apetushkov@9858 2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
apetushkov@9858 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
apetushkov@9858 4 *
apetushkov@9858 5 * This code is free software; you can redistribute it and/or modify it
apetushkov@9858 6 * under the terms of the GNU General Public License version 2 only, as
apetushkov@9858 7 * published by the Free Software Foundation.
apetushkov@9858 8 *
apetushkov@9858 9 * This code is distributed in the hope that it will be useful, but WITHOUT
apetushkov@9858 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
apetushkov@9858 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
apetushkov@9858 12 * version 2 for more details (a copy is included in the LICENSE file that
apetushkov@9858 13 * accompanied this code).
apetushkov@9858 14 *
apetushkov@9858 15 * You should have received a copy of the GNU General Public License version
apetushkov@9858 16 * 2 along with this work; if not, write to the Free Software Foundation,
apetushkov@9858 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
apetushkov@9858 18 *
apetushkov@9858 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
apetushkov@9858 20 * or visit www.oracle.com if you need additional information or have any
apetushkov@9858 21 * questions.
apetushkov@9858 22 *
apetushkov@9858 23 */
apetushkov@9858 24
apetushkov@9858 25 #ifndef SHARE_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP
apetushkov@9858 26 #define SHARE_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP
apetushkov@9858 27
ddong@9885 28 #include "jfr/leakprofiler/chains/edge.hpp"
apetushkov@9858 29 #include "jfr/utilities/jfrHashtable.hpp"
apetushkov@9858 30 #include "memory/allocation.hpp"
apetushkov@9858 31
apetushkov@9858 32 typedef u8 traceid;
apetushkov@9858 33
ddong@9885 34 class StoredEdge : public Edge {
apetushkov@9858 35 private:
ddong@9885 36 mutable traceid _gc_root_id;
ddong@9885 37 size_t _skip_length;
apetushkov@9858 38
apetushkov@9858 39 public:
ddong@9885 40 StoredEdge();
ddong@9885 41 StoredEdge(const Edge* parent, const oop* reference);
ddong@9885 42 StoredEdge(const Edge& edge);
ddong@9885 43 StoredEdge(const StoredEdge& edge);
ddong@9885 44 void operator=(const StoredEdge& edge);
apetushkov@9858 45
ddong@9885 46 traceid gc_root_id() const { return _gc_root_id; }
ddong@9885 47 void set_gc_root_id(traceid root_id) const { _gc_root_id = root_id; }
ddong@9885 48
ddong@9885 49 bool is_skip_edge() const { return _skip_length != 0; }
apetushkov@9858 50 size_t skip_length() const { return _skip_length; }
ddong@9885 51 void set_skip_length(size_t length) { _skip_length = length; }
apetushkov@9858 52
ddong@9885 53 void set_parent(const Edge* edge) { this->_parent = edge; }
ddong@9885 54
ddong@9885 55 StoredEdge* parent() const {
ddong@9885 56 return const_cast<StoredEdge*>(static_cast<const StoredEdge*>(Edge::parent()));
apetushkov@9858 57 }
apetushkov@9858 58 };
apetushkov@9858 59
apetushkov@9858 60 class EdgeStore : public CHeapObj<mtTracing> {
ddong@9885 61 typedef HashTableHost<StoredEdge, traceid, Entry, EdgeStore> EdgeHashTable;
apetushkov@9858 62 typedef EdgeHashTable::HashEntry EdgeEntry;
apetushkov@9858 63 template <typename,
apetushkov@9858 64 typename,
apetushkov@9858 65 template<typename, typename> class,
apetushkov@9858 66 typename,
apetushkov@9858 67 size_t>
apetushkov@9858 68 friend class HashTableHost;
ddong@9885 69 friend class EventEmitter;
ddong@9885 70 friend class ObjectSampleWriter;
ddong@9885 71 friend class ObjectSampleCheckpoint;
apetushkov@9858 72 private:
apetushkov@9858 73 static traceid _edge_id_counter;
apetushkov@9858 74 EdgeHashTable* _edges;
apetushkov@9858 75
apetushkov@9858 76 // Hash table callbacks
apetushkov@9858 77 void assign_id(EdgeEntry* entry);
apetushkov@9858 78 bool equals(const Edge& query, uintptr_t hash, const EdgeEntry* entry);
apetushkov@9858 79
ddong@9885 80 StoredEdge* get(const oop* reference) const;
ddong@9885 81 StoredEdge* put(const oop* reference);
ddong@9885 82 traceid gc_root_id(const Edge* edge) const;
ddong@9885 83
ddong@9885 84 bool put_edges(StoredEdge** previous, const Edge** current, size_t length);
ddong@9885 85 bool put_skip_edge(StoredEdge** previous, const Edge** current, size_t distance_to_root);
ddong@9885 86 void put_chain_epilogue(StoredEdge* leak_context_edge, const Edge* root) const;
ddong@9885 87
ddong@9885 88 StoredEdge* associate_leak_context_with_candidate(const Edge* edge);
ddong@9885 89 void store_gc_root_id_in_leak_context_edge(StoredEdge* leak_context_edge, const Edge* root) const;
ddong@9885 90 StoredEdge* link_new_edge(StoredEdge** previous, const Edge** current);
ddong@9885 91 void link_with_existing_chain(const StoredEdge* current_stored, StoredEdge** previous, size_t previous_length);
ddong@9885 92
ddong@9885 93 template <typename T>
ddong@9885 94 void iterate(T& functor) const { _edges->iterate_value<T>(functor); }
ddong@9885 95
ddong@9885 96 DEBUG_ONLY(bool contains(const oop* reference) const;)
apetushkov@9858 97
apetushkov@9858 98 public:
apetushkov@9858 99 EdgeStore();
apetushkov@9858 100 ~EdgeStore();
apetushkov@9858 101
apetushkov@9858 102 bool is_empty() const;
apetushkov@9858 103 traceid get_id(const Edge* edge) const;
ddong@9885 104 void put_chain(const Edge* chain, size_t length);
apetushkov@9858 105 };
apetushkov@9858 106
apetushkov@9858 107 #endif // SHARE_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP

mercurial