< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp

Print this page

  1 /*
  2  * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.

  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 31 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 32 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
 33 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 35 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
 36 #include "memory/iterator.inline.hpp"
 37 #include "oops/compressedOops.inline.hpp"
 38 #include "runtime/atomic.hpp"
 39 #include "runtime/javaThread.hpp"
 40 
 41 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
 42   _mark_context(ShenandoahHeap::heap()->marking_context()) {
 43 }
 44 
 45 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
 46   if (CompressedOops::is_null(obj)) {
 47     return false;
 48   }
 49   obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
 50   shenandoah_assert_not_forwarded_if(nullptr, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
 51   return _mark_context->is_marked(obj);
 52 }
 53 
 54 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
 55   _mark_context(ShenandoahHeap::heap()->marking_context()) {
 56 }
 57 
 58 bool ShenandoahIsAliveClosure::do_object_b(oop obj) {
 59   if (CompressedOops::is_null(obj)) {
 60     return false;
 61   }
 62   shenandoah_assert_not_forwarded(nullptr, obj);
 63   return _mark_context->is_marked(obj);
 64 }
 65 
 66 BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() {
 67   return ShenandoahHeap::heap()->has_forwarded_objects() ?
 68          reinterpret_cast<BoolObjectClosure*>(&_fwd_alive_cl) :
 69          reinterpret_cast<BoolObjectClosure*>(&_alive_cl);
 70 }
 71 
 72 void ShenandoahOopClosureBase::do_nmethod(nmethod* nm) {
 73   nm->run_nmethod_entry_barrier();
 74 }
 75 
 76 ShenandoahKeepAliveClosure::ShenandoahKeepAliveClosure() :
 77   _bs(ShenandoahBarrierSet::barrier_set()) {
 78 }
 79 
 80 void ShenandoahKeepAliveClosure::do_oop(oop* p) {
 81   do_oop_work(p);
 82 }
 83 
 84 void ShenandoahKeepAliveClosure::do_oop(narrowOop* p) {
 85   do_oop_work(p);
 86 }
 87 
 88 template <typename T>
 89 void ShenandoahKeepAliveClosure::do_oop_work(T* p) {
 90   assert(ShenandoahHeap::heap()->is_concurrent_mark_in_progress(), "Only for concurrent marking phase");
 91   assert(!ShenandoahHeap::heap()->has_forwarded_objects(), "Not expected");
 92 
 93   T o = RawAccess<>::oop_load(p);
 94   if (!CompressedOops::is_null(o)) {
 95     oop obj = CompressedOops::decode_not_null(o);
 96     _bs->enqueue(obj);
 97   }
 98 }
 99 
100 ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() :
101   _heap(ShenandoahHeap::heap()) {
102 }
103 
104 template <class T>
105 void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {
106   _heap->update_with_forwarded(p);
107 }
108 
109 void ShenandoahUpdateRefsClosure::do_oop(oop* p)       { do_oop_work(p); }
110 void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
111 

  1 /*
  2  * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *

 32 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 33 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
 34 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 35 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 36 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
 37 #include "memory/iterator.inline.hpp"
 38 #include "oops/compressedOops.inline.hpp"
 39 #include "runtime/atomic.hpp"
 40 #include "runtime/javaThread.hpp"
 41 
 42 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
 43   _mark_context(ShenandoahHeap::heap()->marking_context()) {
 44 }
 45 
 46 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
 47   if (CompressedOops::is_null(obj)) {
 48     return false;
 49   }
 50   obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
 51   shenandoah_assert_not_forwarded_if(nullptr, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
 52   return _mark_context->is_marked_or_old(obj);
 53 }
 54 
 55 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
 56   _mark_context(ShenandoahHeap::heap()->marking_context()) {
 57 }
 58 
 59 bool ShenandoahIsAliveClosure::do_object_b(oop obj) {
 60   if (CompressedOops::is_null(obj)) {
 61     return false;
 62   }
 63   shenandoah_assert_not_forwarded(nullptr, obj);
 64   return _mark_context->is_marked_or_old(obj);
 65 }
 66 
 67 BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() {
 68   return ShenandoahHeap::heap()->has_forwarded_objects() ?
 69          reinterpret_cast<BoolObjectClosure*>(&_fwd_alive_cl) :
 70          reinterpret_cast<BoolObjectClosure*>(&_alive_cl);
 71 }
 72 
 73 void ShenandoahOopClosureBase::do_nmethod(nmethod* nm) {
 74   nm->run_nmethod_entry_barrier();
 75 }
 76 
 77 ShenandoahKeepAliveClosure::ShenandoahKeepAliveClosure() :
 78   _bs(ShenandoahBarrierSet::barrier_set()) {
 79 }
 80 
 81 void ShenandoahKeepAliveClosure::do_oop(oop* p) {
 82   do_oop_work(p);
 83 }
 84 
 85 void ShenandoahKeepAliveClosure::do_oop(narrowOop* p) {
 86   do_oop_work(p);
 87 }
 88 
 89 template <typename T>
 90 void ShenandoahKeepAliveClosure::do_oop_work(T* p) {
 91   assert(ShenandoahHeap::heap()->is_concurrent_mark_in_progress(), "Only for concurrent marking phase");
 92   assert(ShenandoahHeap::heap()->is_concurrent_old_mark_in_progress() || !ShenandoahHeap::heap()->has_forwarded_objects(), "Not expected");
 93 
 94   T o = RawAccess<>::oop_load(p);
 95   if (!CompressedOops::is_null(o)) {
 96     oop obj = CompressedOops::decode_not_null(o);
 97     _bs->enqueue(obj);
 98   }
 99 }
100 
101 ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() :
102   _heap(ShenandoahHeap::heap()) {
103 }
104 
105 template <class T>
106 void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {
107   _heap->update_with_forwarded(p);
108 }
109 
110 void ShenandoahUpdateRefsClosure::do_oop(oop* p)       { do_oop_work(p); }
111 void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
112 
< prev index next >