< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp

Print this page




  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 
  24 #include "precompiled.hpp"
  25 
  26 #include "classfile/classLoaderDataGraph.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "code/codeCache.hpp"


  30 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.hpp"
  32 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  33 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  34 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  35 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  36 #include "jfr/jfr.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "memory/universe.hpp"
  40 #include "runtime/thread.hpp"
  41 #include "services/management.hpp"
  42 
  43 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  44   _oops_do(oops_do), _phase(phase) {
  45 }
  46 
  47 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  48   if (_claimed.try_set()) {
  49     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();


 142 }
 143 
 144 void ShenandoahStringDedupRoots::oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id) {
 145   if (ShenandoahStringDedup::is_enabled()) {
 146     ShenandoahStringDedup::parallel_oops_do(is_alive, keep_alive, worker_id);
 147   }
 148 }
 149 
 150 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
 151   _heap(ShenandoahHeap::heap()),
 152   _phase(phase) {
 153   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 154   _heap->phase_timings()->record_workers_start(_phase);
 155 }
 156 
 157 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 158   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 159   _heap->phase_timings()->record_workers_end(_phase);
 160 }
 161 
 162 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool include_concurrent_roots) :



 163   ShenandoahRootProcessor(phase),
 164   _thread_roots(n_workers > 1),
 165   _include_concurrent_roots(include_concurrent_roots) {

 166 }
 167 
 168 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 169   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);




 170   AlwaysTrueClosure always_true;
 171 
 172   _serial_roots.oops_do(oops, worker_id);
 173   _serial_weak_roots.weak_oops_do(oops, worker_id);
 174   if (_include_concurrent_roots) {
 175     CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 176     _vm_roots.oops_do<OopClosure>(oops, worker_id);
 177     _cld_roots.cld_do(&clds, worker_id);
 178     _weak_roots.oops_do<OopClosure>(oops, worker_id);
 179   }
 180 
 181   _thread_roots.oops_do(oops, NULL, worker_id);
 182   _code_roots.code_blobs_do(&blobsCl, worker_id);




 183 
 184   _dedup_roots.oops_do(&always_true, oops, worker_id);
 185 }
 186 
 187 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 188   ShenandoahRootProcessor(phase),
 189   _thread_roots(n_workers > 1) {
 190 }
 191 
 192 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 193   ShenandoahRootProcessor(phase),
 194   _thread_roots(n_workers > 1) {
 195   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 196 }
 197 
 198 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 199   CodeBlobToOopClosure adjust_code_closure(oops, CodeBlobToOopClosure::FixRelocations);




 200   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 201   AlwaysTrueClosure always_true;
 202 
 203   _serial_roots.oops_do(oops, worker_id);
 204   _vm_roots.oops_do(oops, worker_id);
 205 
 206   _thread_roots.oops_do(oops, NULL, worker_id);
 207   _cld_roots.cld_do(&adjust_cld_closure, worker_id);
 208   _code_roots.code_blobs_do(&adjust_code_closure, worker_id);
 209 
 210   _serial_weak_roots.weak_oops_do(oops, worker_id);
 211   _weak_roots.oops_do<OopClosure>(oops, worker_id);
 212   _dedup_roots.oops_do(&always_true, oops, worker_id);
 213 }
 214 
 215  ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner() :
 216    ShenandoahRootProcessor(ShenandoahPhaseTimings::_num_phases),
 217    _thread_roots(false /*is par*/) {
 218  }
 219 
 220  void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
 221    assert(Thread::current()->is_VM_thread(), "Only by VM thread");
 222    // Must use _claim_none to avoid interfering with concurrent CLDG iteration
 223    CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 224    MarkingCodeBlobClosure code(oops, !CodeBlobToOopClosure::FixRelocations);
 225    ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, NULL);
 226    ResourceMark rm;
 227 
 228    _serial_roots.oops_do(oops, 0);


  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 
  24 #include "precompiled.hpp"
  25 
  26 #include "classfile/classLoaderDataGraph.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  31 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
  32 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  33 #include "gc/shenandoah/shenandoahHeap.hpp"
  34 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  35 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  36 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  37 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  38 #include "jfr/jfr.hpp"
  39 #include "memory/iterator.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "memory/universe.hpp"
  42 #include "runtime/thread.hpp"
  43 #include "services/management.hpp"
  44 
  45 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  46   _oops_do(oops_do), _phase(phase) {
  47 }
  48 
  49 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  50   if (_claimed.try_set()) {
  51     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();


 144 }
 145 
 146 void ShenandoahStringDedupRoots::oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id) {
 147   if (ShenandoahStringDedup::is_enabled()) {
 148     ShenandoahStringDedup::parallel_oops_do(is_alive, keep_alive, worker_id);
 149   }
 150 }
 151 
 152 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
 153   _heap(ShenandoahHeap::heap()),
 154   _phase(phase) {
 155   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 156   _heap->phase_timings()->record_workers_start(_phase);
 157 }
 158 
 159 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 160   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 161   _heap->phase_timings()->record_workers_end(_phase);
 162 }
 163 
 164 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers,
 165                                                  ShenandoahPhaseTimings::Phase phase,
 166                                                  bool include_concurrent_roots,
 167                                                  bool include_concurrent_code_roots) :
 168   ShenandoahRootProcessor(phase),
 169   _thread_roots(n_workers > 1),
 170   _include_concurrent_roots(include_concurrent_roots),
 171   _include_concurrent_code_roots(include_concurrent_code_roots) {
 172 }
 173 
 174 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 175   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);
 176   ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops);
 177   CodeBlobToOopClosure* codes_cl = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ?
 178                                    static_cast<CodeBlobToOopClosure*>(&blobs_and_disarm_Cl) :
 179                                    static_cast<CodeBlobToOopClosure*>(&blobsCl);
 180   AlwaysTrueClosure always_true;
 181 
 182   _serial_roots.oops_do(oops, worker_id);
 183   _serial_weak_roots.weak_oops_do(oops, worker_id);
 184   if (_include_concurrent_roots) {
 185     CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 186     _vm_roots.oops_do<OopClosure>(oops, worker_id);
 187     _cld_roots.cld_do(&clds, worker_id);
 188     _weak_roots.oops_do<OopClosure>(oops, worker_id);
 189   }
 190 
 191   if (_include_concurrent_code_roots) {
 192     _code_roots.code_blobs_do(codes_cl, worker_id);
 193     _thread_roots.oops_do(oops, NULL, worker_id);
 194   } else {
 195     _thread_roots.oops_do(oops, codes_cl, worker_id);
 196   }
 197 
 198   _dedup_roots.oops_do(&always_true, oops, worker_id);
 199 }
 200 
 201 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 202   ShenandoahRootProcessor(phase),
 203   _thread_roots(n_workers > 1) {
 204 }
 205 
 206 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 207   ShenandoahRootProcessor(phase),
 208   _thread_roots(n_workers > 1) {
 209   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 210 }
 211 
 212 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 213   CodeBlobToOopClosure code_blob_cl(oops, CodeBlobToOopClosure::FixRelocations);
 214   ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops);
 215   CodeBlobToOopClosure* adjust_code_closure = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ?
 216                                               static_cast<CodeBlobToOopClosure*>(&blobs_and_disarm_Cl) :
 217                                               static_cast<CodeBlobToOopClosure*>(&code_blob_cl);
 218   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 219   AlwaysTrueClosure always_true;
 220 
 221   _serial_roots.oops_do(oops, worker_id);
 222   _vm_roots.oops_do(oops, worker_id);
 223 
 224   _thread_roots.oops_do(oops, NULL, worker_id);
 225   _cld_roots.cld_do(&adjust_cld_closure, worker_id);
 226   _code_roots.code_blobs_do(adjust_code_closure, worker_id);
 227 
 228   _serial_weak_roots.weak_oops_do(oops, worker_id);
 229   _weak_roots.oops_do<OopClosure>(oops, worker_id);
 230   _dedup_roots.oops_do(&always_true, oops, worker_id);
 231 }
 232 
 233  ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner() :
 234    ShenandoahRootProcessor(ShenandoahPhaseTimings::_num_phases),
 235    _thread_roots(false /*is par*/) {
 236  }
 237 
 238  void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
 239    assert(Thread::current()->is_VM_thread(), "Only by VM thread");
 240    // Must use _claim_none to avoid interfering with concurrent CLDG iteration
 241    CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 242    MarkingCodeBlobClosure code(oops, !CodeBlobToOopClosure::FixRelocations);
 243    ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, NULL);
 244    ResourceMark rm;
 245 
 246    _serial_roots.oops_do(oops, 0);
< prev index next >