< prev index next >

src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp

Print this page

  1 /*
  2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. 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  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/nmethod.hpp"
 27 #include "gc/g1/g1CodeBlobClosure.hpp"
 28 #include "gc/g1/g1CollectedHeap.inline.hpp"
 29 #include "gc/g1/g1ConcurrentMark.inline.hpp"
 30 #include "gc/g1/heapRegion.hpp"
 31 #include "gc/g1/heapRegionRemSet.inline.hpp"

 32 #include "oops/access.inline.hpp"
 33 #include "oops/compressedOops.inline.hpp"
 34 #include "oops/oop.inline.hpp"
 35 
 36 template <typename T>
 37 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop_work(T* p) {
 38   _work->do_oop(p);
 39   T oop_or_narrowoop = RawAccess<>::oop_load(p);
 40   if (!CompressedOops::is_null(oop_or_narrowoop)) {
 41     oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
 42     HeapRegion* hr = _g1h->heap_region_containing(o);
 43     assert(!_g1h->is_in_cset(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in collection set then evacuation failed and nm must already be in the remset");
 44     hr->add_strong_code_root(_nm);
 45   }
 46 }
 47 
 48 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(oop* o) {
 49   do_oop_work(o);
 50 }
 51 

 58   T oop_or_narrowoop = RawAccess<>::oop_load(p);
 59   if (!CompressedOops::is_null(oop_or_narrowoop)) {
 60     oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
 61     _cm->mark_in_next_bitmap(_worker_id, o);
 62   }
 63 }
 64 
 65 G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :
 66   _cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }
 67 
 68 void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {
 69   do_oop_work(o);
 70 }
 71 
 72 void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {
 73   do_oop_work(o);
 74 }
 75 
 76 void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {
 77   _oc.set_nm(nm);



 78   nm->oops_do(&_oc);
 79   nm->fix_oop_relocations();




 80 }
 81 
 82 void G1CodeBlobClosure::do_marking(nmethod* nm) {
 83   nm->oops_do(&_marking_oc);
 84 }
 85 
 86 class G1NmethodProcessor : public nmethod::OopsDoProcessor {
 87   G1CodeBlobClosure* _cl;
 88 
 89 public:
 90   G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }
 91 
 92   void do_regular_processing(nmethod* nm) {
 93     _cl->do_evacuation_and_fixup(nm);
 94   }
 95 
 96   void do_remaining_strong_processing(nmethod* nm) {
 97     _cl->do_marking(nm);
 98   }
 99 };

  1 /*
  2  * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 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  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/nmethod.hpp"
 27 #include "gc/g1/g1CodeBlobClosure.hpp"
 28 #include "gc/g1/g1CollectedHeap.inline.hpp"
 29 #include "gc/g1/g1ConcurrentMark.inline.hpp"
 30 #include "gc/g1/heapRegion.hpp"
 31 #include "gc/g1/heapRegionRemSet.inline.hpp"
 32 #include "gc/shared/barrierSetNMethod.hpp"
 33 #include "oops/access.inline.hpp"
 34 #include "oops/compressedOops.inline.hpp"
 35 #include "oops/oop.inline.hpp"
 36 
 37 template <typename T>
 38 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop_work(T* p) {
 39   _work->do_oop(p);
 40   T oop_or_narrowoop = RawAccess<>::oop_load(p);
 41   if (!CompressedOops::is_null(oop_or_narrowoop)) {
 42     oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
 43     HeapRegion* hr = _g1h->heap_region_containing(o);
 44     assert(!_g1h->is_in_cset(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in collection set then evacuation failed and nm must already be in the remset");
 45     hr->add_strong_code_root(_nm);
 46   }
 47 }
 48 
 49 void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(oop* o) {
 50   do_oop_work(o);
 51 }
 52 

 59   T oop_or_narrowoop = RawAccess<>::oop_load(p);
 60   if (!CompressedOops::is_null(oop_or_narrowoop)) {
 61     oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
 62     _cm->mark_in_next_bitmap(_worker_id, o);
 63   }
 64 }
 65 
 66 G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :
 67   _cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }
 68 
 69 void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {
 70   do_oop_work(o);
 71 }
 72 
 73 void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {
 74   do_oop_work(o);
 75 }
 76 
 77 void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {
 78   _oc.set_nm(nm);
 79   if (_keepalive_is_strong) {
 80     nm->mark_as_maybe_on_continuation();
 81   }
 82   nm->oops_do(&_oc);
 83   nm->fix_oop_relocations();
 84   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
 85   if (bs_nm != NULL) {
 86     bs_nm->disarm(nm);
 87   }
 88 }
 89 
 90 void G1CodeBlobClosure::do_marking(nmethod* nm) {
 91   nm->oops_do(&_marking_oc);
 92 }
 93 
 94 class G1NmethodProcessor : public nmethod::OopsDoProcessor {
 95   G1CodeBlobClosure* _cl;
 96 
 97 public:
 98   G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }
 99 
100   void do_regular_processing(nmethod* nm) {
101     _cl->do_evacuation_and_fixup(nm);
102   }
103 
104   void do_remaining_strong_processing(nmethod* nm) {
105     _cl->do_marking(nm);
106   }
107 };
< prev index next >