Path: blob/master/src/hotspot/share/gc/shared/gcBehaviours.cpp
40957 views
/*1* Copyright (c) 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 "code/compiledMethod.hpp"26#include "code/nmethod.hpp"27#include "gc/shared/gcBehaviours.hpp"2829IsUnloadingBehaviour* IsUnloadingBehaviour::_current = NULL;3031class IsCompiledMethodUnloadingOopClosure: public OopClosure {32BoolObjectClosure *_cl;33bool _is_unloading;3435public:36IsCompiledMethodUnloadingOopClosure(BoolObjectClosure* cl)37: _cl(cl),38_is_unloading(false)39{ }4041virtual void do_oop(oop* p) {42if (_is_unloading) {43return;44}45oop obj = *p;46if (obj == NULL) {47return;48}49if (!_cl->do_object_b(obj)) {50_is_unloading = true;51}52}5354virtual void do_oop(narrowOop* p) {55ShouldNotReachHere();56}5758bool is_unloading() const {59return _is_unloading;60}61};6263bool ClosureIsUnloadingBehaviour::is_unloading(CompiledMethod* cm) const {64if (cm->is_nmethod()) {65IsCompiledMethodUnloadingOopClosure cl(_cl);66static_cast<nmethod*>(cm)->oops_do(&cl, true /* allow_dead */);67return cl.is_unloading();68} else {69return false;70}71}727374