Path: blob/master/src/hotspot/share/jfr/leakprofiler/chains/edgeStore.hpp
41153 views
/*1* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_EDGESTORE_HPP25#define SHARE_JFR_LEAKPROFILER_CHAINS_EDGESTORE_HPP2627#include "jfr/leakprofiler/chains/edge.hpp"28#include "jfr/leakprofiler/utilities/unifiedOopRef.hpp"29#include "jfr/utilities/jfrHashtable.hpp"30#include "memory/allocation.hpp"3132typedef u8 traceid;3334class StoredEdge : public Edge {35private:36mutable traceid _gc_root_id;37size_t _skip_length;3839public:40StoredEdge();41StoredEdge(const Edge* parent, UnifiedOopRef reference);42StoredEdge(const Edge& edge);43StoredEdge(const StoredEdge& edge);4445traceid gc_root_id() const { return _gc_root_id; }46void set_gc_root_id(traceid root_id) const { _gc_root_id = root_id; }4748bool is_skip_edge() const { return _skip_length != 0; }49size_t skip_length() const { return _skip_length; }50void set_skip_length(size_t length) { _skip_length = length; }5152void set_parent(const Edge* edge) { this->_parent = edge; }5354StoredEdge* parent() const {55return const_cast<StoredEdge*>(static_cast<const StoredEdge*>(Edge::parent()));56}57};5859class EdgeStore : public CHeapObj<mtTracing> {60typedef HashTableHost<StoredEdge, traceid, JfrHashtableEntry, EdgeStore> EdgeHashTable;61typedef EdgeHashTable::HashEntry EdgeEntry;62template <typename,63typename,64template<typename, typename> class,65typename,66size_t>67friend class HashTableHost;68friend class EventEmitter;69friend class ObjectSampleWriter;70friend class ObjectSampleCheckpoint;71private:72static traceid _edge_id_counter;73EdgeHashTable* _edges;7475// Hash table callbacks76void on_link(EdgeEntry* entry);77bool on_equals(uintptr_t hash, const EdgeEntry* entry);78void on_unlink(EdgeEntry* entry);7980StoredEdge* get(UnifiedOopRef reference) const;81StoredEdge* put(UnifiedOopRef reference);82traceid gc_root_id(const Edge* edge) const;8384bool put_edges(StoredEdge** previous, const Edge** current, size_t length);85bool put_skip_edge(StoredEdge** previous, const Edge** current, size_t distance_to_root);86void put_chain_epilogue(StoredEdge* leak_context_edge, const Edge* root) const;8788StoredEdge* associate_leak_context_with_candidate(const Edge* edge);89void store_gc_root_id_in_leak_context_edge(StoredEdge* leak_context_edge, const Edge* root) const;90StoredEdge* link_new_edge(StoredEdge** previous, const Edge** current);91void link_with_existing_chain(const StoredEdge* current_stored, StoredEdge** previous, size_t previous_length);9293template <typename T>94void iterate(T& functor) const { _edges->iterate_value<T>(functor); }9596DEBUG_ONLY(bool contains(UnifiedOopRef reference) const;)9798public:99EdgeStore();100~EdgeStore();101102bool is_empty() const;103traceid get_id(const Edge* edge) const;104void put_chain(const Edge* chain, size_t length);105};106107#endif // SHARE_JFR_LEAKPROFILER_CHAINS_EDGESTORE_HPP108109110