Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/src/share/vm/jfr/leakprofiler/chains/edgeStore.hpp
83410 views
/*1* Copyright (c) 2014, 2018, 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_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP25#define SHARE_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP2627#include "jfr/leakprofiler/chains/edge.hpp"28#include "jfr/utilities/jfrHashtable.hpp"29#include "memory/allocation.hpp"3031typedef u8 traceid;3233class StoredEdge : public Edge {34private:35mutable traceid _gc_root_id;36size_t _skip_length;3738public:39StoredEdge();40StoredEdge(const Edge* parent, const oop* reference);41StoredEdge(const Edge& edge);42StoredEdge(const StoredEdge& edge);43void operator=(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, Entry, 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 assign_id(EdgeEntry* entry);77bool equals(const Edge& query, uintptr_t hash, const EdgeEntry* entry);7879StoredEdge* get(const oop* reference) const;80StoredEdge* put(const oop* reference);81traceid gc_root_id(const Edge* edge) const;8283bool put_edges(StoredEdge** previous, const Edge** current, size_t length);84bool put_skip_edge(StoredEdge** previous, const Edge** current, size_t distance_to_root);85void put_chain_epilogue(StoredEdge* leak_context_edge, const Edge* root) const;8687StoredEdge* associate_leak_context_with_candidate(const Edge* edge);88void store_gc_root_id_in_leak_context_edge(StoredEdge* leak_context_edge, const Edge* root) const;89StoredEdge* link_new_edge(StoredEdge** previous, const Edge** current);90void link_with_existing_chain(const StoredEdge* current_stored, StoredEdge** previous, size_t previous_length);9192template <typename T>93void iterate(T& functor) const { _edges->iterate_value<T>(functor); }9495DEBUG_ONLY(bool contains(const oop* reference) const;)9697public:98EdgeStore();99~EdgeStore();100101bool is_empty() const;102traceid get_id(const Edge* edge) const;103void put_chain(const Edge* chain, size_t length);104};105106#endif // SHARE_VM_LEAKPROFILER_CHAINS_EDGESTORE_HPP107108109