Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/shenandoahClosures.inline.hpp
38920 views
/*1* Copyright (c) 2019, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/22#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP23#define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP2425#include "gc_implementation/shenandoah/shenandoahAsserts.hpp"26#include "gc_implementation/shenandoah/shenandoahClosures.hpp"27#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"28#include "runtime/thread.hpp"2930ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :31_mark_context(ShenandoahHeap::heap()->marking_context()) {32}3334bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {35if (oopDesc::is_null(obj)) {36return false;37}38obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);39shenandoah_assert_not_forwarded_if(NULL, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());40return _mark_context->is_marked(obj);41}4243ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :44_mark_context(ShenandoahHeap::heap()->marking_context()) {45}4647bool ShenandoahIsAliveClosure::do_object_b(oop obj) {48if (oopDesc::is_null(obj)) {49return false;50}51shenandoah_assert_not_forwarded(NULL, obj);52return _mark_context->is_marked(obj);53}5455BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() {56return ShenandoahHeap::heap()->has_forwarded_objects() ?57reinterpret_cast<BoolObjectClosure*>(&_fwd_alive_cl) :58reinterpret_cast<BoolObjectClosure*>(&_alive_cl);59}6061ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() :62_heap(ShenandoahHeap::heap()) {63}6465template <class T>66void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {67T o = oopDesc::load_heap_oop(p);68if (!oopDesc::is_null(o)) {69oop obj = oopDesc::decode_heap_oop_not_null(o);70_heap->update_with_forwarded_not_null(p, obj);71}72}7374void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }75void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }7677ShenandoahEvacuateUpdateRootsClosure::ShenandoahEvacuateUpdateRootsClosure() :78_heap(ShenandoahHeap::heap()), _thread(Thread::current()) {79}8081template <class T>82void ShenandoahEvacuateUpdateRootsClosure::do_oop_work(T* p) {83assert(_heap->is_evacuation_in_progress(), "Only do this when evacuation is in progress");8485T o = oopDesc::load_heap_oop(p);86if (! oopDesc::is_null(o)) {87oop obj = oopDesc::decode_heap_oop_not_null(o);88if (_heap->in_collection_set(obj)) {89shenandoah_assert_marked(p, obj);90oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);91if (resolved == obj) {92resolved = _heap->evacuate_object(obj, _thread);93}94oopDesc::encode_store_heap_oop(p, resolved);95}96}97}9899void ShenandoahEvacuateUpdateRootsClosure::do_oop(oop* p) {100do_oop_work(p);101}102103void ShenandoahEvacuateUpdateRootsClosure::do_oop(narrowOop* p) {104do_oop_work(p);105}106107#ifdef ASSERT108template <class T>109void ShenandoahAssertNotForwardedClosure::do_oop_work(T* p) {110T o = oopDesc::load_heap_oop(p);111if (!oopDesc::is_null(o)) {112oop obj = oopDesc::decode_heap_oop_not_null(o);113shenandoah_assert_not_forwarded(p, obj);114}115}116117void ShenandoahAssertNotForwardedClosure::do_oop(narrowOop* p) { do_oop_work(p); }118void ShenandoahAssertNotForwardedClosure::do_oop(oop* p) { do_oop_work(p); }119#endif120121#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP122123124