Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/shenandoahBarrierSetClone.inline.hpp
38920 views
/*1* Copyright (c) 2013, 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*/2223#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP24#define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP2526#include "gc_implementation/shenandoah/shenandoahBarrierSet.inline.hpp"27#include "gc_implementation/shenandoah/shenandoahCollectionSet.inline.hpp"28#include "gc_implementation/shenandoah/shenandoahEvacOOMHandler.hpp"29#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"30#include "memory/iterator.hpp"31#include "oops/oop.inline.hpp"3233template <bool HAS_FWD, bool EVAC, bool ENQUEUE>34class ShenandoahUpdateRefsForOopClosure: public ExtendedOopClosure {35private:36ShenandoahHeap* const _heap;37ShenandoahBarrierSet* const _bs;38const ShenandoahCollectionSet* const _cset;39Thread* const _thread;4041template <class T>42inline void do_oop_work(T* p) {43T o = oopDesc::load_heap_oop(p);44if (!oopDesc::is_null(o)) {45oop obj = oopDesc::decode_heap_oop_not_null(o);46if (HAS_FWD && _cset->is_in(obj)) {47oop fwd = _bs->resolve_forwarded_not_null(obj);48if (EVAC && obj == fwd) {49fwd = _heap->evacuate_object(obj, _thread);50}51assert(obj != fwd || _heap->cancelled_gc(), "must be forwarded");52ShenandoahHeap::cas_oop(fwd, p, o);53obj = fwd;54}55if (ENQUEUE) {56_bs->enqueue(obj);57}58}59}60public:61ShenandoahUpdateRefsForOopClosure() :62_heap(ShenandoahHeap::heap()),63_bs(ShenandoahBarrierSet::barrier_set()),64_cset(_heap->collection_set()),65_thread(Thread::current()) {66}6768virtual void do_oop(oop* p) { do_oop_work(p); }69virtual void do_oop(narrowOop* p) { do_oop_work(p); }70};7172void ShenandoahBarrierSet::clone_marking(oop obj) {73assert(_heap->is_concurrent_mark_in_progress(), "only during marking");74assert(ShenandoahStoreValEnqueueBarrier, "only with incremental-update");75if (!_heap->marking_context()->allocated_after_mark_start(obj)) {76ShenandoahUpdateRefsForOopClosure</* has_fwd = */ false, /* evac = */ false, /* enqueue */ true> cl;77obj->oop_iterate(&cl);78}79}8081void ShenandoahBarrierSet::clone_evacuation(oop obj) {82assert(_heap->is_evacuation_in_progress(), "only during evacuation");83if (need_bulk_update(cast_from_oop<HeapWord*>(obj))) {84ShenandoahEvacOOMScope oom_evac_scope;85ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ true, /* enqueue */ false> cl;86obj->oop_iterate(&cl);87}88}8990void ShenandoahBarrierSet::clone_update(oop obj) {91assert(_heap->is_update_refs_in_progress(), "only during update-refs");92if (need_bulk_update(cast_from_oop<HeapWord*>(obj))) {93ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ false, /* enqueue */ false> cl;94obj->oop_iterate(&cl);95}96}9798void ShenandoahBarrierSet::clone_barrier(oop obj) {99assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");100shenandoah_assert_correct(NULL, obj);101102int gc_state = _heap->gc_state();103if ((gc_state & ShenandoahHeap::MARKING) != 0) {104clone_marking(obj);105} else if ((gc_state & ShenandoahHeap::EVACUATION) != 0) {106clone_evacuation(obj);107} else {108clone_update(obj);109}110}111112#endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP113114115