< prev index next >

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

Print this page




   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 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 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
  24 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
  25 

  26 #include "gc/shenandoah/shenandoahAsserts.hpp"
  27 #include "gc/shenandoah/shenandoahClosures.hpp"
  28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"

  29 #include "oops/compressedOops.inline.hpp"
  30 #include "runtime/thread.hpp"
  31 
  32 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
  33   _mark_context(ShenandoahHeap::heap()->marking_context()) {
  34 }
  35 
  36 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
  37   if (CompressedOops::is_null(obj)) {
  38     return false;
  39   }
  40   obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
  41   shenandoah_assert_not_forwarded_if(NULL, obj,
  42                                      (ShenandoahHeap::heap()->is_concurrent_mark_in_progress() ||
  43                                      ShenandoahHeap::heap()->is_concurrent_traversal_in_progress()));
  44   return _mark_context->is_marked(obj);
  45 }
  46 
  47 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
  48   _mark_context(ShenandoahHeap::heap()->marking_context()) {


 113 
 114 void ShenandoahEvacUpdateOopStorageRootsClosure::do_oop(oop* p) {
 115   assert(_heap->is_evacuation_in_progress(), "Only do this when evacuation is in progress");
 116 
 117   oop obj = RawAccess<>::oop_load(p);
 118   if (! CompressedOops::is_null(obj)) {
 119     if (_heap->in_collection_set(obj)) {
 120       shenandoah_assert_marked(p, obj);
 121       oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
 122       if (oopDesc::equals_raw(resolved, obj)) {
 123         resolved = _heap->evacuate_object(obj, _thread);
 124       }
 125 
 126       Atomic::cmpxchg(resolved, p, obj);
 127     }
 128   }
 129 }
 130 
 131 void ShenandoahEvacUpdateOopStorageRootsClosure::do_oop(narrowOop* p) {
 132   ShouldNotReachHere();














 133 }
 134 
 135 #ifdef ASSERT
 136 template <class T>
 137 void ShenandoahAssertNotForwardedClosure::do_oop_work(T* p) {
 138   T o = RawAccess<>::oop_load(p);
 139   if (!CompressedOops::is_null(o)) {
 140     oop obj = CompressedOops::decode_not_null(o);
 141     shenandoah_assert_not_forwarded(p, obj);
 142   }
 143 }
 144 
 145 void ShenandoahAssertNotForwardedClosure::do_oop(narrowOop* p) { do_oop_work(p); }
 146 void ShenandoahAssertNotForwardedClosure::do_oop(oop* p)       { do_oop_work(p); }
 147 #endif
 148 
 149 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP


   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 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 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
  24 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
  25 
  26 #include "gc/shared/barrierSetNMethod.hpp"
  27 #include "gc/shenandoah/shenandoahAsserts.hpp"
  28 #include "gc/shenandoah/shenandoahClosures.hpp"
  29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  30 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  31 #include "oops/compressedOops.inline.hpp"
  32 #include "runtime/thread.hpp"
  33 
  34 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
  35   _mark_context(ShenandoahHeap::heap()->marking_context()) {
  36 }
  37 
  38 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
  39   if (CompressedOops::is_null(obj)) {
  40     return false;
  41   }
  42   obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
  43   shenandoah_assert_not_forwarded_if(NULL, obj,
  44                                      (ShenandoahHeap::heap()->is_concurrent_mark_in_progress() ||
  45                                      ShenandoahHeap::heap()->is_concurrent_traversal_in_progress()));
  46   return _mark_context->is_marked(obj);
  47 }
  48 
  49 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
  50   _mark_context(ShenandoahHeap::heap()->marking_context()) {


 115 
 116 void ShenandoahEvacUpdateOopStorageRootsClosure::do_oop(oop* p) {
 117   assert(_heap->is_evacuation_in_progress(), "Only do this when evacuation is in progress");
 118 
 119   oop obj = RawAccess<>::oop_load(p);
 120   if (! CompressedOops::is_null(obj)) {
 121     if (_heap->in_collection_set(obj)) {
 122       shenandoah_assert_marked(p, obj);
 123       oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
 124       if (oopDesc::equals_raw(resolved, obj)) {
 125         resolved = _heap->evacuate_object(obj, _thread);
 126       }
 127 
 128       Atomic::cmpxchg(resolved, p, obj);
 129     }
 130   }
 131 }
 132 
 133 void ShenandoahEvacUpdateOopStorageRootsClosure::do_oop(narrowOop* p) {
 134   ShouldNotReachHere();
 135 }
 136 
 137 ShenandoahCodeBlobAndDisarmClosure::ShenandoahCodeBlobAndDisarmClosure(OopClosure* cl) :
 138   CodeBlobToOopClosure(cl, true /* fix_relocations */),
 139    _bs(BarrierSet::barrier_set()->barrier_set_nmethod()) {
 140 }
 141 
 142 void ShenandoahCodeBlobAndDisarmClosure::do_code_blob(CodeBlob* cb) {
 143   nmethod* const nm = cb->as_nmethod_or_null();
 144   if (nm != NULL && !nm->test_set_oops_do_mark()) {
 145     assert(!ShenandoahNMethod::gc_data(nm)->is_unregistered(), "Should not be here");
 146     CodeBlobToOopClosure::do_code_blob(cb);
 147     _bs->disarm(nm);
 148   }
 149 }
 150 
 151 #ifdef ASSERT
 152 template <class T>
 153 void ShenandoahAssertNotForwardedClosure::do_oop_work(T* p) {
 154   T o = RawAccess<>::oop_load(p);
 155   if (!CompressedOops::is_null(o)) {
 156     oop obj = CompressedOops::decode_not_null(o);
 157     shenandoah_assert_not_forwarded(p, obj);
 158   }
 159 }
 160 
 161 void ShenandoahAssertNotForwardedClosure::do_oop(narrowOop* p) { do_oop_work(p); }
 162 void ShenandoahAssertNotForwardedClosure::do_oop(oop* p)       { do_oop_work(p); }
 163 #endif
 164 
 165 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP
< prev index next >