Path: blob/master/src/hotspot/share/jfr/leakprofiler/chains/rootSetClosure.cpp
41153 views
/*1* Copyright (c) 2014, 2021, 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#include "precompiled.hpp"25#include "classfile/classLoaderDataGraph.hpp"26#include "classfile/stringTable.hpp"27#include "gc/shared/oopStorage.inline.hpp"28#include "gc/shared/oopStorageSet.inline.hpp"29#include "gc/shared/strongRootsScope.hpp"30#include "jfr/leakprofiler/chains/bfsClosure.hpp"31#include "jfr/leakprofiler/chains/dfsClosure.hpp"32#include "jfr/leakprofiler/chains/edgeQueue.hpp"33#include "jfr/leakprofiler/chains/rootSetClosure.hpp"34#include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp"35#include "oops/access.inline.hpp"36#include "oops/oop.inline.hpp"37#include "runtime/synchronizer.hpp"38#include "runtime/thread.hpp"39#include "services/management.hpp"40#include "utilities/align.hpp"4142template <typename Delegate>43RootSetClosure<Delegate>::RootSetClosure(Delegate* delegate) : _delegate(delegate) {}4445template <typename Delegate>46void RootSetClosure<Delegate>::do_oop(oop* ref) {47assert(ref != NULL, "invariant");48assert(is_aligned(ref, HeapWordSize), "invariant");49if (*ref != NULL) {50_delegate->do_root(UnifiedOopRef::encode_in_native(ref));51}52}5354template <typename Delegate>55void RootSetClosure<Delegate>::do_oop(narrowOop* ref) {56assert(ref != NULL, "invariant");57assert(is_aligned(ref, sizeof(narrowOop)), "invariant");58if (!CompressedOops::is_null(*ref)) {59_delegate->do_root(UnifiedOopRef::encode_in_native(ref));60}61}6263class RootSetClosureMarkScope : public MarkScope {};6465template <typename Delegate>66void RootSetClosure<Delegate>::process() {67RootSetClosureMarkScope mark_scope;68CLDToOopClosure cldt_closure(this, ClassLoaderData::_claim_none);69ClassLoaderDataGraph::always_strong_cld_do(&cldt_closure);70// We don't follow code blob oops, because they have misaligned oops.71Threads::oops_do(this, NULL);72OopStorageSet::strong_oops_do(this);73}7475template class RootSetClosure<BFSClosure>;76template class RootSetClosure<DFSClosure>;777879