< prev index next >

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

Print this page




  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/shenandoahRootProcessor.inline.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.hpp"
  33 #include "gc/shenandoah/shenandoahHeuristics.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 "gc/shared/weakProcessor.inline.hpp"
  39 #include "memory/allocation.inline.hpp"
  40 #include "memory/iterator.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "memory/universe.hpp"
  43 #include "runtime/thread.hpp"
  44 #include "services/management.hpp"
  45 
  46 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  47   _claimed(false), _oops_do(oops_do), _phase(phase) {
  48 }
  49 
  50 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  51   if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
  52     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  53     ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
  54     _oops_do(cl);
  55   }
  56 }
  57 
  58 ShenandoahSerialRoots::ShenandoahSerialRoots() :
  59   _universe_root(&Universe::oops_do, ShenandoahPhaseTimings::UniverseRoots),
  60   _object_synchronizer_root(&ObjectSynchronizer::oops_do, ShenandoahPhaseTimings::ObjectSynchronizerRoots),
  61   _management_root(&Management::oops_do, ShenandoahPhaseTimings::ManagementRoots),
  62   _system_dictionary_root(&SystemDictionary::oops_do, ShenandoahPhaseTimings::SystemDictionaryRoots),
  63   _jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots) {

  64 }
  65 
  66 void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
  67   _universe_root.oops_do(cl, worker_id);
  68   _object_synchronizer_root.oops_do(cl, worker_id);
  69   _management_root.oops_do(cl, worker_id);
  70   _system_dictionary_root.oops_do(cl, worker_id);
  71   _jvmti_root.oops_do(cl, worker_id);
  72 }
  73 
  74 ShenandoahJNIHandleRoots::ShenandoahJNIHandleRoots() :
  75   ShenandoahSerialRoot(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
  76 }
  77 
  78 ShenandoahThreadRoots::ShenandoahThreadRoots(bool is_par) : _is_par(is_par) {
  79   Threads::change_thread_claim_token();
  80 }
  81 
  82 void ShenandoahThreadRoots::oops_do(OopClosure* oops_cl, CodeBlobClosure* code_cl, uint worker_id) {
  83   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  84   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
  85   ResourceMark rm;
  86   Threads::possibly_parallel_oops_do(_is_par, oops_cl, code_cl);
  87 }
  88 
  89 void ShenandoahThreadRoots::threads_do(ThreadClosure* tc, uint worker_id) {
  90   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  91   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
  92   ResourceMark rm;
  93   Threads::possibly_parallel_threads_do(_is_par, tc);
  94 }
  95 


 145 
 146 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 147   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 148   _heap->phase_timings()->record_workers_end(_phase);
 149 }
 150 
 151 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 152   ShenandoahRootProcessor(phase),
 153   _thread_roots(n_workers > 1),
 154   _weak_roots(n_workers) {
 155 }
 156 
 157 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 158   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);
 159   CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 160   CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
 161 
 162   AlwaysTrueClosure always_true;
 163 
 164   _serial_roots.oops_do(oops, worker_id);
 165   _jni_roots.oops_do(oops, worker_id);
 166 
 167   _thread_roots.oops_do(oops, NULL, worker_id);
 168   _cld_roots.clds_do(&clds, &clds, worker_id);
 169   _code_roots.code_blobs_do(&blobsCl, worker_id);
 170 
 171   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
 172   _dedup_roots.oops_do(&always_true, oops, worker_id);
 173 }
 174 
 175 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool update_code_cache) :
 176   ShenandoahRootProcessor(phase),
 177   _thread_roots(n_workers > 1),
 178   _weak_roots(n_workers),
 179   _update_code_cache(update_code_cache) {
 180 }
 181 
 182 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 183   ShenandoahRootProcessor(phase),
 184   _thread_roots(n_workers > 1),
 185   _weak_roots(n_workers) {
 186   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 187 }
 188 
 189 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 190   CodeBlobToOopClosure adjust_code_closure(oops, CodeBlobToOopClosure::FixRelocations);
 191   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 192   AlwaysTrueClosure always_true;
 193 
 194   _serial_roots.oops_do(oops, worker_id);
 195   _jni_roots.oops_do(oops, worker_id);
 196 
 197   _thread_roots.oops_do(oops, NULL, worker_id);
 198   _cld_roots.clds_do(&adjust_cld_closure, NULL, worker_id);
 199   _code_roots.code_blobs_do(&adjust_code_closure, worker_id);
 200 
 201   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
 202   _dedup_roots.oops_do(&always_true, oops, worker_id);
 203 }


  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/shenandoahRootProcessor.inline.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.hpp"
  33 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  34 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  35 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  36 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  37 #include "gc/shenandoah/shenandoahUtils.hpp"
  38 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  39 #include "gc/shared/weakProcessor.inline.hpp"
  40 #include "memory/allocation.inline.hpp"
  41 #include "memory/iterator.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "memory/universe.hpp"
  44 #include "runtime/thread.hpp"
  45 #include "services/management.hpp"
  46 
  47 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  48   _claimed(false), _oops_do(oops_do), _phase(phase) {
  49 }
  50 
  51 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  52   if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
  53     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  54     ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
  55     _oops_do(cl);
  56   }
  57 }
  58 
  59 ShenandoahSerialRoots::ShenandoahSerialRoots() :
  60   _universe_root(&Universe::oops_do, ShenandoahPhaseTimings::UniverseRoots),
  61   _object_synchronizer_root(&ObjectSynchronizer::oops_do, ShenandoahPhaseTimings::ObjectSynchronizerRoots),
  62   _management_root(&Management::oops_do, ShenandoahPhaseTimings::ManagementRoots),
  63   _system_dictionary_root(&SystemDictionary::oops_do, ShenandoahPhaseTimings::SystemDictionaryRoots),
  64   _jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots),
  65   _jni_handle_root(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
  66 }
  67 
  68 void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
  69   _universe_root.oops_do(cl, worker_id);
  70   _object_synchronizer_root.oops_do(cl, worker_id);
  71   _management_root.oops_do(cl, worker_id);
  72   _system_dictionary_root.oops_do(cl, worker_id);
  73   _jvmti_root.oops_do(cl, worker_id);
  74   _jni_handle_root.oops_do(cl, worker_id);



  75 }
  76 
  77 ShenandoahThreadRoots::ShenandoahThreadRoots(bool is_par) : _is_par(is_par) {
  78   Threads::change_thread_claim_token();
  79 }
  80 
  81 void ShenandoahThreadRoots::oops_do(OopClosure* oops_cl, CodeBlobClosure* code_cl, uint worker_id) {
  82   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  83   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
  84   ResourceMark rm;
  85   Threads::possibly_parallel_oops_do(_is_par, oops_cl, code_cl);
  86 }
  87 
  88 void ShenandoahThreadRoots::threads_do(ThreadClosure* tc, uint worker_id) {
  89   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  90   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
  91   ResourceMark rm;
  92   Threads::possibly_parallel_threads_do(_is_par, tc);
  93 }
  94 


 144 
 145 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 146   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 147   _heap->phase_timings()->record_workers_end(_phase);
 148 }
 149 
 150 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 151   ShenandoahRootProcessor(phase),
 152   _thread_roots(n_workers > 1),
 153   _weak_roots(n_workers) {
 154 }
 155 
 156 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 157   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);
 158   CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 159   CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
 160 
 161   AlwaysTrueClosure always_true;
 162 
 163   _serial_roots.oops_do(oops, worker_id);

 164 
 165   _thread_roots.oops_do(oops, NULL, worker_id);
 166   _cld_roots.clds_do(&clds, &clds, worker_id);
 167   _code_roots.code_blobs_do(&blobsCl, worker_id);
 168 
 169   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
 170   _dedup_roots.oops_do(&always_true, oops, worker_id);
 171 }
 172 
 173 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool update_code_cache) :
 174   ShenandoahRootProcessor(phase),
 175   _thread_roots(n_workers > 1),
 176   _weak_roots(n_workers),
 177   _update_code_cache(update_code_cache) {
 178 }
 179 
 180 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 181   ShenandoahRootProcessor(phase),
 182   _thread_roots(n_workers > 1),
 183   _weak_roots(n_workers) {
 184   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 185 }
 186 
 187 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 188   CodeBlobToOopClosure adjust_code_closure(oops, CodeBlobToOopClosure::FixRelocations);
 189   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 190   AlwaysTrueClosure always_true;
 191 
 192   _serial_roots.oops_do(oops, worker_id);

 193 
 194   _thread_roots.oops_do(oops, NULL, worker_id);
 195   _cld_roots.clds_do(&adjust_cld_closure, NULL, worker_id);
 196   _code_roots.code_blobs_do(&adjust_code_closure, worker_id);
 197 
 198   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
 199   _dedup_roots.oops_do(&always_true, oops, worker_id);
 200 }
< prev index next >