Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/leakprofiler/chains/rootSetClosure.cpp
38922 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#include "precompiled.hpp"25#include "classfile/classLoaderData.hpp"26#include "classfile/systemDictionary.hpp"27#include "jfr/leakprofiler/chains/bfsClosure.hpp"28#include "jfr/leakprofiler/chains/dfsClosure.hpp"29#include "jfr/leakprofiler/chains/edgeQueue.hpp"30#include "jfr/leakprofiler/chains/rootSetClosure.hpp"31#include "jfr/leakprofiler/utilities/saveRestore.hpp"32#include "jfr/leakprofiler/utilities/unifiedOop.hpp"33#include "memory/universe.hpp"34#include "oops/oop.inline.hpp"35#include "prims/jvmtiExport.hpp"36#include "runtime/jniHandles.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");48// We discard unaligned root references because49// our reference tagging scheme will use50// the lowest bit in a represented reference51// to indicate the reference is narrow.52// It is mainly roots delivered via nmethods::do_oops()53// that come in unaligned. It should be ok to duck these54// since they are supposedly weak.55if (!is_aligned(ref, HeapWordSize)) {56return;57}5859assert(is_aligned(ref, HeapWordSize), "invariant");60if (*ref != NULL) {61_delegate->do_root(ref);62}63}6465template <typename Delegate>66void RootSetClosure<Delegate>::do_oop(narrowOop* ref) {67assert(ref != NULL, "invariant");68assert(is_aligned(ref, sizeof(narrowOop)), "invariant");69const oop pointee = oopDesc::load_decode_heap_oop(ref);70if (pointee != NULL) {71_delegate->do_root(UnifiedOop::encode(ref));72}73}7475class RootSetClosureMarkScope : public MarkingCodeBlobClosure::MarkScope {};7677template <typename Delegate>78void RootSetClosure<Delegate>::process() {79RootSetClosureMarkScope mark_scope;80CLDToOopClosure cldt_closure(this);81ClassLoaderDataGraph::always_strong_cld_do(&cldt_closure);82CodeBlobToOopClosure blobs(this, false);83Threads::oops_do(this, NULL, &blobs); // XXX set CLDClosure to NULL84ObjectSynchronizer::oops_do(this);85Universe::oops_do(this);86JNIHandles::oops_do(this);87JvmtiExport::oops_do(this);88SystemDictionary::oops_do(this);89Management::oops_do(this);90StringTable::oops_do(this);91}9293template class RootSetClosure<BFSClosure>;94template class RootSetClosure<DFSClosure>;959697