Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/leakprofiler/utilities/saveRestore.cpp
38922 views
/*1* Copyright (c) 2017, 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 "jfr/leakprofiler/utilities/saveRestore.hpp"27#include "oops/oop.inline.hpp"2829MarkOopContext::MarkOopContext() : _obj(NULL), _mark_oop(NULL) {}3031MarkOopContext::MarkOopContext(const oop obj) : _obj(obj), _mark_oop(obj->mark()) {32assert(_obj->mark() == _mark_oop, "invariant");33// now we will "poison" the mark word of the object34// to the intermediate monitor INFLATING state.35// This is an "impossible" state during a safepoint,36// hence we will use it to quickly identify objects37// during the reachability search from gc roots.38assert(NULL == markOopDesc::INFLATING(), "invariant");39_obj->set_mark(markOopDesc::INFLATING());40assert(NULL == obj->mark(), "invariant");41}4243MarkOopContext::~MarkOopContext() {44if (_obj != NULL) {45_obj->set_mark(_mark_oop);46assert(_obj->mark() == _mark_oop, "invariant");47}48}4950MarkOopContext::MarkOopContext(const MarkOopContext& rhs) : _obj(NULL), _mark_oop(NULL) {51swap(const_cast<MarkOopContext&>(rhs));52}5354void MarkOopContext::operator=(MarkOopContext rhs) {55swap(rhs);56}5758void MarkOopContext::swap(MarkOopContext& rhs) {59oop temp_obj = rhs._obj;60markOop temp_mark_oop = rhs._mark_oop;61rhs._obj = _obj;62rhs._mark_oop = _mark_oop;63_obj = temp_obj;64_mark_oop = temp_mark_oop;65}6667CLDClaimContext::CLDClaimContext() : _cld(NULL) {}6869CLDClaimContext::CLDClaimContext(ClassLoaderData* cld) : _cld(cld) {70assert(_cld->claimed(), "invariant");71_cld->clear_claimed();72}7374CLDClaimContext::~CLDClaimContext() {75if (_cld != NULL) {76_cld->claim();77assert(_cld->claimed(), "invariant");78}79}8081CLDClaimContext::CLDClaimContext(const CLDClaimContext& rhs) : _cld(NULL) {82swap(const_cast<CLDClaimContext&>(rhs));83}8485void CLDClaimContext::operator=(CLDClaimContext rhs) {86swap(rhs);87}8889void CLDClaimContext::swap(CLDClaimContext& rhs) {90ClassLoaderData* temp_cld = rhs._cld;91rhs._cld = _cld;92_cld = temp_cld;93}9495CLDClaimStateClosure::CLDClaimStateClosure() : CLDClosure(), _state() {}9697void CLDClaimStateClosure::do_cld(ClassLoaderData* cld) {98assert(cld != NULL, "invariant");99if (cld->claimed()) {100_state.save(cld);101}102}103104SaveRestoreCLDClaimBits::SaveRestoreCLDClaimBits() : _claim_state_closure() {105ClassLoaderDataGraph::cld_do(&_claim_state_closure);106}107108SaveRestoreCLDClaimBits::~SaveRestoreCLDClaimBits() {109ClassLoaderDataGraph::clear_claimed_marks();110}111112113